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:
@anthropics/claude-code-action.Before you begin, make sure you have the following:
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:
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.
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.
Run the following command from your project directory:
Syntax notes:
unleash) comes before the -e flag-e${VAR} preserve the literal string for runtime expansionThe 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.
The Unleash MCP server exposes the following tools.
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 implementing a change that might affect production stability, such as a payment integration, authentication flow, or external API call.
Tell Claude Code what you are working on:
Claude Code calls evaluate_change and returns a recommendation with a suggested flag name.
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.
Use this workflow to enable a flag in staging for testing while keeping it disabled in production.
Claude Code 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.
Claude Code 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, Claude Code calls list_projects to enumerate projects the configured token can access. Skip this step if UNLEASH_DEFAULT_PROJECT is set.
Claude Code calls list_flags with the target projectId. The default response returns active (non-archived) flags only.
For a full audit, Claude Code 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.
Claude Code 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.
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.
Commit your CLAUDE.md file to version control so all team members share the same policies.
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.
For operations that only need Unleash data, ask Claude Code directly:
The following prompt patterns help you use the MCP tools effectively.
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.
Intent: Avoid duplicate flags when similar functionality exists.
Prompt:
Expected behavior: Claude Code calls detect_flag and presents matches with confidence levels.
Intent: Enable, disable, or query a flag in a specific environment.
Prompts:
Expected behavior: Claude Code calls toggle_flag_environment or get_flag_state.
Intent: Safely remove flagged code and delete unused flags.
Prompts:
Expected behavior: Claude Code calls cleanup_flag and provides removal instructions.
For enterprise deployments, IT administrators can deploy centralized MCP configuration using managed settings.
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.
Use allowedMcpServers and deniedMcpServers in managed settings to restrict which servers users can configure while still allowing some flexibility.
claude mcp listecho $UNLEASH_BASE_URLcurl -H "Authorization: $UNLEASH_PAT" "$UNLEASH_BASE_URL/api/admin/projects"~/.zshrc or ~/.bashrcexport UNLEASH_BASE_URL UNLEASH_PATclaude mcp add command to prevent premature expansionUNLEASH_BASE_URL does not include /api at the endClaude 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.
Local servers using npx require Node.js 18+. Verify with node --version. If Node.js is installed but not found, check your PATH.
On native Windows (not WSL), local MCP servers using npx require the cmd /c wrapper:
For WSL environments, use the standard Unix syntax.
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.
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.