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:
Before you begin, make sure you have the following:
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:
Requirements: Visual Studio Code 1.102 or later with GitHub Copilot extension.
Create a file at .vscode/mcp.json in your project root:
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.
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):
The Unleash MCP server exposes the following tools.
| 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 |
list_projects | Lists Unleash projects available to the configured token, with optional pagination. | Discovering available projects |
list_flags | Lists feature flags in a project (active by default; set archived=true for archived flags). | Auditing flag inventory; discovering existing flags before creating new ones |
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 |
The Unleash MCP server supports three use cases: evaluate and wrap code in feature flags, manage rollouts across environments, and clean up after rollout.
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:
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.
Use this workflow to enable a flag in staging for testing while keeping it disabled in production.
Copilot calls get_flag_state and returns the flag metadata, enabled environments, and active strategies.
AI assistants can make mistakes and toggle the wrong flag. Enable change requests on production environments to require human approval before changes take effect. See the MCP server documentation for details.
Use this workflow when a feature has been fully rolled out and the flag is no longer needed.
Copilot calls cleanup_flag and returns:
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.
Use this workflow to take inventory of existing flags before creating new ones, or to run a periodic audit for cleanup candidates.
If you don’t already know the target project, Copilot calls list_projects to enumerate projects the configured token can access. Skip this step if UNLEASH_DEFAULT_PROJECT is set.
Copilot calls list_flags with the target projectId. The default response returns active (non-archived) flags only.
For a full audit, Copilot calls list_flags a second time with archived=true. Active and archived flags are disjoint result sets in Unleash; both calls are needed for complete inventory.
Copilot compares the returned flags against references in your code. Flags present in Unleash but unused in code (especially archived ones) are cleanup candidates — chain into the Clean up after rollout workflow to remove them safely.
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:
With these instructions in place, when a developer asks Copilot to “add Stripe payments,” Copilot automatically evaluates, detects, creates, and wraps without explicit prompting.
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:
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:
Expected behavior: Copilot calls detect_flag and presents matches with confidence levels.
Intent: Enable, disable, or query a flag in a specific environment.
Prompts:
Expected behavior: Copilot calls toggle_flag_environment or get_flag_state.
Intent: Safely remove flagged code and delete unused flags.
Prompts:
Expected behavior: Copilot calls cleanup_flag and provides removal instructions.
.vscode/mcp.json is in the project root.Run MCP: List Servers from the Command Palette and select Show Output to view server logs.
UNLEASH_BASE_URL does not include /api at the end.Visual Studio Code limits a single chat session to 128 tools. If you have many MCP servers installed:
When using Dev Containers, WSL, or SSH remote development:
.vscode/mcp.json or in the customizations.vscode.mcp section of devcontainer.json.Some IDEs (JetBrains, Visual Studio) do not support the envFile property. In these cases:
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.