Integrate Unleash with Claude Code
The Unleash MCP server connects Claude Code to your Unleash instance, enabling AI-assisted feature flag management. You can evaluate code changes, create flags, generate wrapping code, manage rollouts, and clean up flags from your terminal or IDE.
Claude Code supports MCP across multiple interfaces:
- Terminal CLI — The primary interface, built for developers who live in the terminal.
- VS Code — Extension for Visual Studio Code.
- JetBrains IDEs — Plugin for IntelliJ IDEA, PyCharm, WebStorm, and others.
- Desktop app — Standalone application.
- GitHub Actions — CI/CD automation with
@anthropics/claude-code-action.
Prerequisites
Before you begin, make sure you have the following:
- Node.js 18 or later: the MCP server is distributed as an npm package.
- Claude Code, installed via your preferred method (see installation tabs).
- 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 interface, but all use the same npm package and credentials.
Claude Code uses environment variable expansion, and we recommend creating a credentials file and source it from your shell profile:
Configure your interface
Terminal CLI
VS Code
JetBrains IDEs
Desktop App
GitHub Actions
Requirements: Claude Code CLI installed.
The terminal CLI is Claude Code’s native interface. Use the claude mcp add command to register the Unleash MCP server.
Add the Unleash MCP server
You can either run the claude mcp add command or create the .mcp.json file manually.
Both approaches create the same .mcp.json file at your project root. Choose whichever you prefer.
CLI command
Create file manually
Run the following command from your project directory:
Syntax notes:
- The server name (
unleash) comes before the-eflag - Multiple environment variables are space-separated after a single
-e - Single quotes around
${VAR}preserve the literal string for runtime expansion
The resulting .mcp.json file can be committed to version control since it contains no credentials, only variable references that expand at runtime.
Installation scopes:
For team collaboration, use --scope project so the configuration is stored in .mcp.json and can be committed to version control.
Tool reference
The Unleash MCP server exposes nine tools. The following table summarizes each tool and when to use it.
Workflows
This section describes common workflows for using the Unleash MCP server with Claude Code.
Evaluate and wrap a risky change
Use this workflow when implementing a change that might affect production stability, such as a payment integration, authentication flow, or external API call.
Evaluate the change
Tell Claude Code what you are working on:
Claude Code calls evaluate_change and returns a recommendation with a suggested flag name.
Check for duplicates
Claude Code automatically calls detect_flag to search for existing flags. If a suitable flag exists, Claude Code suggests reusing it instead of creating a duplicate.
Manage rollouts across environments
Use this workflow to enable a flag in staging for testing while keeping it disabled in production.
Check flag state
Enable in staging
Configure rollout
Claude Code 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.
Claude Code 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.
CLAUDE.md templates
Claude Code reads a CLAUDE.md file at the project root and applies its guidance automatically. You can encode your team’s feature flag policies in this file so Claude Code considers them on every interaction.
Basic template
Advanced template with domain rules
Commit your CLAUDE.md file to version control so all team members share the same policies.
Piped workflow recipes
Claude Code’s pipe-friendly interface enables batch operations. Combine standard Unix tools with Claude Code to process data that the MCP server cannot access directly.
Find commits that should have been flagged
Analyze a diff before merging
Pre-commit hook for flag evaluation
Find flag references and check their state
Direct Unleash queries
For operations that only need Unleash data, ask Claude Code directly:
Prompt patterns
The following prompt patterns help you use the MCP tools effectively.
Evaluate and create a flag
Intent: Determine if a change requires a feature flag, then create and wrap it.
Prompt:
Expected behavior: Claude Code calls evaluate_change, then detect_flag, create_flag, and wrap_change as needed.
Detect and reuse existing flags
Intent: Avoid duplicate flags when similar functionality exists.
Prompt:
Expected behavior: Claude Code calls detect_flag and presents matches with confidence levels.
Toggle or check flag state
Intent: Enable, disable, or query a flag in a specific environment.
Prompts:
Expected behavior: Claude Code calls toggle_flag_environment or get_flag_state.
Clean up a flag
Intent: Safely remove flagged code and delete unused flags.
Prompts:
Expected behavior: Claude Code calls cleanup_flag and provides removal instructions.
Enterprise governance
For enterprise deployments, IT administrators can deploy centralized MCP configuration using managed settings.
Managed MCP configuration
Deploy managed-mcp.json to system directories to control which MCP servers are available:
When this file is present, users cannot add, modify, or use any MCP servers other than those defined in the file.
Policy-based control
Use allowedMcpServers and deniedMcpServers in managed settings to restrict which servers users can configure while still allowing some flexibility.
Troubleshooting
MCP tools not showing up
- Verify the server is listed with
claude mcp list - Check that environment variables are exported:
echo $UNLEASH_BASE_URL - Test credentials directly:
curl -H "Authorization: $UNLEASH_PAT" "$UNLEASH_BASE_URL/api/admin/projects" - Restart your terminal after modifying your shell profile
Environment variables not expanding
- Restart your terminal after modifying
~/.zshrcor~/.bashrc - Verify variables are exported:
export UNLEASH_BASE_URL UNLEASH_PAT - Check that single quotes were used in the
claude mcp addcommand to prevent premature expansion
Authentication failed
- Confirm your Unleash PAT is valid and has not expired
- Check that the PAT has permissions to create and manage feature flags
- Verify that
UNLEASH_BASE_URLincludes/apiat the end - For self-hosted instances, ensure the API is accessible from your machine
Server crashes repeatedly
Claude Code automatically restarts MCP servers that crash. If a server fails repeatedly, it will be disabled for the session. Check your credentials and restart Claude Code.
Node.js not found
Local servers using npx require Node.js 18+. Verify with node --version. If Node.js is installed but not found, check your PATH.
Windows-specific issues
On native Windows (not WSL), local MCP servers using npx require the cmd /c wrapper:
For WSL environments, use the standard Unix syntax.
Tool results truncated
Claude Code limits tool output size to prevent context overflow. If results appear truncated, use filters (such as specific projects or flag types) to reduce result size. For current limits, see the Claude Code MCP documentation.
Best practices
Follow these guidelines for effective feature flag management with Claude Code.
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-feature-variant) and types. Encode these in your CLAUDE.md file.
Always use detect_flag before creating new flags. This keeps naming consistent and reduces fragmentation across services.
Feature flags should be removed after successful rollouts. Use cleanup_flag regularly to prevent technical debt.
Configure MCP servers with --scope project so the .mcp.json file is shared via version control. All team members get the same configuration.
Write your feature flag guidelines in CLAUDE.md. Claude Code reads this file and applies its guidance automatically.