Integrate Unleash with GitHub Copilot

The Unleash MCP server connects GitHub 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:

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.
  • An Unleash instance: cloud or self-hosted, with API access enabled.
  • A personal access token (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:

~/.unleash/mcp.env
$UNLEASH_BASE_URL={{UNLEASH_BASE_URL}}
$UNLEASH_PAT={{UNLEASH_PAT}}
$UNLEASH_DEFAULT_PROJECT={{UNLEASH_DEFAULT_PROJECT}}

Configure your IDE

Requirements: Visual Studio Code 1.102 or later with GitHub Copilot extension.

1

Create the configuration file

Create a file at .vscode/mcp.json in your project root:

.vscode/mcp.json
1{
2 "servers": {
3 "unleash-mcp": {
4 "name": "Unleash MCP",
5 "type": "stdio",
6 "command": "npx",
7 "args": ["-y", "@unleash/mcp@latest", "--log-level", "error"],
8 "envFile": "~/.unleash/mcp.env"
9 }
10 }
11}
2

Reload VS Code

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.

3

Verify the installation

  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.

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 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.

ToolDescriptionWhen to use
evaluate_changeAnalyzes a code change and determines whether it should be behind a feature flag.Before implementing risky changes
detect_flagSearches for existing flags that match a description to prevent duplicates.Before creating new flags
create_flagCreates a new feature flag with proper naming, typing, and metadata.When no suitable flag exists
wrap_changeGenerates framework-specific code to guard a feature behind a flag.After creating a flag
get_flag_stateReturns the current state, strategies, and metadata for a flag.Debugging, status checks
set_flag_rolloutConfigures rollout percentages and activation strategies.Gradual releases
toggle_flag_environmentEnables or disables a flag in a specific environment.Testing, staged rollouts
remove_flag_strategyDeletes a rollout strategy from a flag.Simplifying flag configuration
cleanup_flagReturns 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.

1

Evaluate the change

Ask Copilot to assess whether the change needs a feature flag:

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.

2

Check for duplicates

Copilot automatically calls detect_flag to search for existing flags. If a suitable flag exists, Copilot suggests reusing it instead of creating a duplicate.

3

Create the flag

If no suitable flag exists, ask Copilot to create one:

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.

4

Wrap the code

Generate framework-specific guard code:

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:

checkout.js
1const { isEnabled } = require('unleash-client');
2
3app.post('/checkout', async (req, res) => {
4 const context = { userId: req.user.id };
5
6 if (isEnabled('stripe-payment-integration', context)) {
7 // New Stripe payment flow
8 const result = await stripeService.processPayment(req.body);
9 return res.json(result);
10 } else {
11 // Existing payment flow
12 const result = await legacyPaymentService.process(req.body);
13 return res.json(result);
14 }
15});

Manage rollouts across environments

Use this workflow to enable a flag in staging for testing while keeping it disabled in production.

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.

Clean up after rollout

Use this workflow when a feature has been fully rolled out and the flag is no longer needed.

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:

.github/copilot-instructions.md
1## Feature flag policy
2
3When implementing new features or modifying high-risk code paths:
4
51. Always use the `evaluate_change` tool to assess whether the change needs a feature flag
62. Prefer reusing existing flags over creating new ones (use `detect_flag`)
73. Follow kebab-case naming: `domain-action-variant`
84. All payment, authentication, and external API changes MUST be flagged
95. Use `wrap_change` to generate framework-appropriate guard code
10
11Default 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:

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:

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:

Enable [flagName] in the staging environment.
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:

Clean up the [flagName] flag now that the feature has fully shipped.
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.

  • 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.

Keep humans in the loop

While the MCP server can automate flag creation, high-risk changes should involve human review. Approve flag creation, rollout plans, and cleanup decisions.

Define naming conventions

Establish organization-wide standards for flag names (e.g., domain-action-variant) and types (release, experiment, kill-switch). The MCP server enforces these rules.

Prevent duplication

Always use detect_flag before creating new flags. This keeps naming consistent and reduces fragmentation across microservices.

Keep flags temporary

Feature flags should be removed after successful rollouts. Use cleanup_flag regularly to prevent technical debt.

Architecture

The following diagram shows how the Unleash MCP server fits into your development workflow.

┌────────────────────────────────────────────────────────────┐
│ Developer workflow │
├────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────────┐ │
│ │ Your IDE │ MCP │ Unleash MCP │ │
│ │ + Copilot │◄─────────►│ server (local) │ │
│ └──────────────┘ stdio └────────┬─────────┘ │
│ │ │
│ VS Code, JetBrains, │ HTTPS │
│ Visual Studio, Neovim │ │
│ ┌───────▼───────────┐ │
│ │ Unleash Admin API │ │
│ └───────┬───────────┘ │
│ │ │
├───────────────────────────────────────│────────────────────┤
│ Runtime evaluation │
├───────────────────────────────────────│────────────────────┤
│ │ │
│ ┌──────────────────┐ ┌─────▼─────────────┐ │
│ │ Your application │◄────────►│ Unleash SDK / Edge│ │
│ └──────────────────┘ Feature └───────────────────┘ │
│ flags │
│ │
└────────────────────────────────────────────────────────────┘

Key points:

  • The MCP server runs locally on your machine as a stdio process.
  • It communicates with the Unleash Admin API using your PAT.
  • Feature flag evaluations happen locally in your application via SDKs or Unleash Edge.
  • No user data is sent to the Unleash server during flag evaluation.