*** title: Integrate Unleash with GitHub Copilot 'og:site\_name': Unleash Documentation 'og:title': Integrate Unleash with GitHub Copilot for AI-powered feature flag management description: >- Configure the Unleash MCP server to automate feature flag management in GitHub Copilot across VS Code, JetBrains, Visual Studio, Neovim, and Copilot CLI. keywords: >- github copilot, mcp, model context protocol, ai, llm, coding assistants, feature flags, automation, vs code, jetbrains, visual studio, neovim max-toc-depth: 3 slug: integrate/github-copilot ------------------------------ The [Unleash MCP server](/integrate/mcp) connects [GitHub Copilot](https://github.com/features/copilot) to your Unleash instance, enabling AI-assisted feature flag management directly in your IDE. You can evaluate code changes, create flags, automatically wrap changes in feature flags, manage rollouts, and clean up flags without leaving your editor. GitHub Copilot supports MCP in several environments: * [Visual Studio Code](https://code.visualstudio.com/) with full MCP support available in versions 1.102+. * [JetBrains IDEs](https://www.jetbrains.com/) with IntelliJ IDEA, PyCharm, WebStorm, and others AI Assistant. * [Visual Studio](https://visualstudio.microsoft.com/) with the GitHub Copilot extension. * [Neovim](https://neovim.io/) with community plugins like [mcphub.nvim](https://github.com/ravitemer/mcphub.nvim). * [Copilot CLI](https://github.com/features/copilot/cli), a command-line interface. * On [GitHub.com](https://github.com/features/copilot), a web-based Copilot (no MCP support). ## Prerequisites Before you begin, make sure you have the following: * Node.js 18 or later: the MCP server is distributed as an npm package. * A supported IDE, see environment-specific requirements [here](#configure-your-ide). * An Unleash instance: cloud or self-hosted, with API access enabled. * A [personal access token](/concepts/api-tokens-and-client-keys#personal-access-tokens) (PAT) with permissions to create and manage feature flags. ## Install the MCP server The Unleash MCP server runs as a local stdio process. Configuration differs by environment, but all IDEs use the same npm package and credentials. First, create a shared credentials file that works across all environments: ### Configure your IDE **Requirements:** Visual Studio Code 1.102 or later with GitHub Copilot extension. Create a file at `.vscode/mcp.json` in your project root: ```json title=".vscode/mcp.json" { "servers": { "unleash-mcp": { "name": "Unleash MCP", "type": "stdio", "command": "npx", "args": ["-y", "@unleash/mcp@latest", "--log-level", "error"], "envFile": "~/.unleash/mcp.env" } } } ``` After saving the file, reload Visual Studio Code by running **Developer: Reload window** from the Command Palette. The MCP server starts automatically when you open the project. 1. Open the Chat view (`Cmd+Shift+I` on Mac, `Ctrl+Alt+I` on Windows/Linux). 2. Click the **Tools** icon in the chat toolbar. 3. Select the Unleash MCP tools in the list. If the tools don't appear, run **MCP: List Servers** from the Command Palette and select **Show Output** to view server logs. **Global configuration:** To use the MCP server across all projects, run **MCP: Add Server** from the Command Palette and choose **Global**. **Remote development:** For Dev Containers, WSL, or SSH, define the server in the remote `.vscode/mcp.json` or in the `customizations.vscode.mcp` section of `devcontainer.json`. **Requirements:** IntelliJ IDEA, PyCharm, WebStorm, or another JetBrains IDE with AI Assistant plugin. JetBrains AI Assistant MCP support is evolving. Check the [JetBrains AI Assistant documentation](https://www.jetbrains.com/help/idea/ai-assistant.html) for the latest capabilities. Go to **Settings > Tools > AI Assistant > MCP Servers**. Click **Add** and configure: * **Name:** `Unleash MCP` * **Command:** `npx` * **Arguments:** `-y @unleash/mcp@latest --log-level error` * **Environment variables:** * `UNLEASH_BASE_URL`: Your Unleash API URL * `UNLEASH_PAT`: Your personal access token * `UNLEASH_DEFAULT_PROJECT`: Your default project Ensure the server is enabled and restart the IDE if prompted. JetBrains does not currently support `envFile`. You must configure environment variables directly in the settings or use system environment variables. **Requirements:** Visual Studio 2022 or later with GitHub Copilot extension. Visual Studio MCP support is currently in preview. Check the [Visual Studio Copilot documentation](https://learn.microsoft.com/en-us/visualstudio/ide/visual-studio-github-copilot-extension) for the latest capabilities. Go to **Tools** → **Options** → **GitHub Copilot** → **MCP Servers**. Click **Add** and configure: * **Name:** `Unleash MCP` * **Command:** `npx -y @unleash/mcp@latest --log-level error` * **Working directory:** Your project root * **Environment variables:** Configure `UNLEASH_BASE_URL`, `UNLEASH_PAT`, and `UNLEASH_DEFAULT_PROJECT` Restart Visual Studio to activate the MCP server. **Requirements:** Neovim 0.9+ with a Copilot plugin and MCP support. The official copilot.vim plugin does not support MCP. Use community plugins like [mcphub.nvim](https://github.com/ravitemer/mcphub.nvim) for MCP integration. Add mcphub.nvim to your plugin manager. For example, with lazy.nvim: ```lua title="init.lua" { "ravitemer/mcphub.nvim", dependencies = { "nvim-lua/plenary.nvim" }, config = function() require("mcphub").setup({ servers = { ["unleash-mcp"] = { command = "npx", args = { "-y", "@unleash/mcp@latest", "--log-level", "error" }, env = { UNLEASH_BASE_URL = os.getenv("UNLEASH_BASE_URL"), UNLEASH_PAT = os.getenv("UNLEASH_PAT"), UNLEASH_DEFAULT_PROJECT = os.getenv("UNLEASH_DEFAULT_PROJECT"), }, }, }, }) end, } ``` Export the required variables in your shell configuration: ```bash title="~/.zshrc or ~/.bashrc" export UNLEASH_BASE_URL="https://your-instance.getunleash.io/api" export UNLEASH_PAT="your-personal-access-token" export UNLEASH_DEFAULT_PROJECT="default" ``` Restart Neovim and verify the MCP server is available. **Requirements:** [GitHub Copilot CLI](https://github.com/github/copilot-cli) installed and authenticated. GitHub Copilot CLI is a terminal-native interface to GitHub Copilot's coding agent. It supports custom MCP servers via the `/mcp add` slash command, which means you can use the Unleash MCP server directly from your terminal. Copilot CLI is in public preview. The configuration interface may change. Check the [official Copilot CLI documentation](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/use-copilot-cli#add-an-mcp-server) for the latest instructions. Choose your preferred installation method: ```bash brew install copilot-cli ``` ```bash winget install GitHub.Copilot ``` ```bash npm install -g @github/copilot ``` Navigate to your project directory and launch the CLI: ```bash cd /path/to/your/project copilot ``` If prompted, trust the current directory and authenticate with `/login`. Use the `/mcp add` slash command: ```text /mcp add ``` Fill in the following details (use Tab to move between fields): | Field | Value | | ----------- | ---------------------------------------------- | | **Name** | `unleash-mcp` | | **Type** | `local` | | **Command** | `npx -y @unleash/mcp@latest --log-level error` | | **Tools** | `*` | For environment variables, add: * `UNLEASH_BASE_URL`: `https://your-instance.getunleash.io/api` * `UNLEASH_PAT`: Your personal access token * `UNLEASH_DEFAULT_PROJECT`: `default` Press `Ctrl+S` to save the configuration. You will see a confirmation message such as "MCP configuration saved successfully! Changes will take effect immediately." Run the `/mcp show` command to confirm the server is configured: ```text /mcp show ``` You should see `unleash-mcp` listed with its tools. Alternatively, ask Copilot to evaluate a change or create a feature flag to confirm the tools are working. If Copilot cannot see the Unleash MCP server, check the `~/.copilot/mcp-config.json` file and verify if the environment variables have been configured correctly. Configuration is stored in `~/.copilot/mcp-config.json`. You can also edit this file directly using the [MCP JSON structure](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#writing-a-json-configuration-for-mcp-servers). **Status:** No MCP support GitHub Copilot on github.com is designed for code review, issue triage, and pull request descriptions. It does not currently support custom MCP servers for feature flag management. **Recommended workflow:** * Use your IDE for feature flag creation and wrapping. * Use github.com Copilot for reviewing flag-related pull requests. ## Verify the installation After configuring your IDE, verify that the Unleash MCP tools are available (full list below). Try one of the following prompts (or the [prompt patterns](#prompt-patterns) below): ``` 1. Show me the available tools of the Unleash MCP server. 2. Use the Unleash MCP server to get the flag state of `your-flag-name` 3. Use the Unleash MCP server to wrap the current change in a feature flag ``` ## Tool reference The Unleash MCP server exposes nine tools. The following table summarizes each tool and when to use it. | Tool | Description | When to use | | ------------------------- | --------------------------------------------------------------------------------- | --------------------------------- | | `evaluate_change` | Analyzes a code change and determines whether it should be behind a feature flag. | Before implementing risky changes | | `detect_flag` | Searches for existing flags that match a description to prevent duplicates. | Before creating new flags | | `create_flag` | Creates a new feature flag with proper naming, typing, and metadata. | When no suitable flag exists | | `wrap_change` | Generates framework-specific code to guard a feature behind a flag. | After creating a flag | | `get_flag_state` | Returns the current state, strategies, and metadata for a flag. | Debugging, status checks | | `set_flag_rollout` | Configures rollout percentages and activation strategies. | Gradual releases | | `toggle_flag_environment` | Enables or disables a flag in a specific environment. | Testing, staged rollouts | | `remove_flag_strategy` | Deletes a rollout strategy from a flag. | Simplifying flag configuration | | `cleanup_flag` | Returns file locations and instructions for removing a flag after rollout. | After full rollout | ## Workflows This section describes common workflows for using the Unleash MCP server with GitHub Copilot. ### Evaluate and wrap a risky change Use this workflow when you're implementing a change that might affect production stability, such as a payment integration, authentication flow, or external API call. Ask Copilot to assess whether the change needs a feature flag: ```text Evaluate whether the Stripe payment integration should be behind a feature flag. The change modifies the checkout service and handles credit card processing. ``` Copilot calls `evaluate_change` and returns a recommendation with a suggested flag name. Copilot automatically calls `detect_flag` to search for existing flags. If a suitable flag exists, Copilot suggests reusing it instead of creating a duplicate. If no suitable flag exists, ask Copilot to create one: ```text Create a release flag for the Stripe payment integration. ``` Copilot calls `create_flag` with the appropriate name, type, and description. The flag is created in Unleash, disabled by default. Generate framework-specific guard code: ```text Wrap the Stripe checkout handler with the stripe-payment-integration flag. This is a Node.js Express application. ``` Copilot calls `wrap_change` and returns code like this: ```javascript title="checkout.js" const { isEnabled } = require('unleash-client'); app.post('/checkout', async (req, res) => { const context = { userId: req.user.id }; if (isEnabled('stripe-payment-integration', context)) { // New Stripe payment flow const result = await stripeService.processPayment(req.body); return res.json(result); } else { // Existing payment flow const result = await legacyPaymentService.process(req.body); return res.json(result); } }); ``` ### Manage rollouts across environments Use this workflow to enable a flag in staging for testing while keeping it disabled in production. ```text What is the current state and rollout strategies for stripe-payment-integration? ``` Copilot calls `get_flag_state` and returns the flag metadata, enabled environments, and active strategies. ```text Enable stripe-payment-integration in the staging environment. ``` Copilot calls `toggle_flag_environment` to enable the flag in staging while keeping it disabled in production. ```text Set up a gradual rollout for stripe-payment-integration: 10% for 24 hours, then 50% for 48 hours, then 100%. ``` Copilot calls `set_flag_rollout` to configure the rollout strategy. ### Clean up after rollout Use this workflow when a feature has been fully rolled out and the flag is no longer needed. ```text Clean up the stripe-payment-integration flag. The feature is fully rolled out. ``` Copilot calls `cleanup_flag` and returns: * All files and line numbers where the flag is used. * Which code path to preserve (the "enabled" branch). * Suggestions for tests to run after removal. Review the list, remove the conditional branches, and delete the flag from Unleash. Feature flags should be temporary. Regularly clean up flags after successful rollouts to prevent technical debt. ## Define custom instructions You can configure project-level instructions to make feature flag evaluation automatic. When custom instructions are present, Copilot considers them on every interaction. Create a file at `.github/copilot-instructions.md` in your repository: ```markdown title=".github/copilot-instructions.md" ## Feature flag policy When implementing new features or modifying high-risk code paths: 1. Always use the `evaluate_change` tool to assess whether the change needs a feature flag 2. Prefer reusing existing flags over creating new ones (use `detect_flag`) 3. Follow kebab-case naming: `domain-action-variant` 4. All payment, authentication, and external API changes MUST be flagged 5. Use `wrap_change` to generate framework-appropriate guard code Default project: `checkout-team` ``` With these instructions in place, when a developer asks Copilot to "add Stripe payments," Copilot automatically evaluates, detects, creates, and wraps without explicit prompting. ## Prompt patterns The following prompt patterns help you use the MCP tools effectively. **Intent:** Determine if a change requires a feature flag, create it if needed and wrap the code in the flag. **Prompt:** ```text Evaluate whether the [description of change] should be behind a feature flag. The change modifies [component/service]. ``` **Expected behavior:** Copilot calls `evaluate_change`, then `detect_flag`, `create_flag`, and `wrap_change` as needed. **Intent:** Avoid duplicate flags when similar functionality exists. **Prompt:** ```text Before creating a new flag for [feature], check if a similar flag already exists and suggest reusing it if appropriate. ``` **Expected behavior:** Copilot calls `detect_flag` and presents matches with confidence levels. **Intent:** Enable, disable, or query a flag in a specific environment. **Prompts:** ```text Enable [flagName] in the staging environment. ``` ```text What is the current state and rollout strategies for [flagName]? ``` **Expected behavior:** Copilot calls `toggle_flag_environment` or `get_flag_state`. **Intent:** Safely remove flagged code and delete unused flags. **Prompts:** ```text Clean up the [flagName] flag now that the feature has fully shipped. ``` ```text Clean up the [flagName] flag after the A/B testing experiment, only keep [variant]. ``` **Expected behavior:** Copilot calls `cleanup_flag` and provides removal instructions. ## Troubleshooting * Check that `.vscode/mcp.json` is in the project root. * Verify the env file path is correct and the file exists. * Confirm Node.js and npm are available in your terminal. * Check that your Unleash PAT has the required permissions. Run **MCP: List Servers** from the Command Palette and select **Show Output** to view server logs. * Verify the AI Assistant plugin is installed and enabled. * Check that the MCP server is listed in **Settings > Tools > AI Assistant > MCP Servers**. * Confirm environment variables are set correctly. * Restart the IDE after making changes. * Verify mcphub.nvim or your MCP plugin is installed correctly. * Check that environment variables are exported in your shell. * Run `:checkhealth` to verify plugin status. * Check plugin logs for connection errors. * Verify the server was saved after running `/mcp add`. * Check `~/.copilot/mcp-config.json` for syntax errors. * Confirm environment variables are set in the server configuration. * Restart the Copilot CLI session after adding a new server. * Check that Node.js and npm are available in your PATH. * Confirm your Unleash PAT is valid and has permissions to create and manage feature flags. * Check that `UNLEASH_BASE_URL` includes `/api` at the end. * For GitHub Enterprise plans, ensure the "MCP servers in Copilot" policy is enabled. Visual Studio Code limits a single chat session to 128 tools. If you have many MCP servers installed: * Create a tool set with only the Unleash tools you need. * Deselect tools from other MCP servers you're not actively using. When using Dev Containers, WSL, or SSH remote development: * Define the server in the remote `.vscode/mcp.json` or in the `customizations.vscode.mcp` section of `devcontainer.json`. * Ensure Node.js is available in the container. Some IDEs (JetBrains, Visual Studio) do not support the `envFile` property. In these cases: * Set environment variables directly in the IDE's MCP configuration. * Use system-level environment variables in your shell profile. * For CI/CD, use secrets management to inject variables. ## Best practices Follow these guidelines for effective feature flag management with AI assistants. While the MCP server can automate flag creation, high-risk changes should involve human review. Approve flag creation, rollout plans, and cleanup decisions. Establish organization-wide standards for flag names (e.g., `domain-action-variant`) and types (release, experiment, kill-switch). The MCP server enforces these rules. Always use `detect_flag` before creating new flags. This keeps naming consistent and reduces fragmentation across microservices. Feature flags should be removed after successful rollouts. Use `cleanup_flag` regularly to prevent technical debt. ## Related resources * [Unleash MCP server on GitHub](https://github.com/Unleash/unleash-mcp) * [GitHub Copilot meets progressive delivery](https://getunleash.io/blog/github-copilot-meets-progressive-delivery) * [How to automate feature flags in GitHub Copilot](https://getunleash.io/blog/automate-feature-flags-github-copilot) * [Impact Metrics](/concepts/impact-metrics) * [Unleash architecture overview](/get-started/unleash-overview) * [Visual Studio Code MCP server documentation](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)