A purpose-driven Model Context Protocol (MCP) server for managing Unleash feature flags. This server enables LLM-powered coding assistants to create and manage feature flags following Unleash best practices.
This MCP server provides tools that integrate with the Unleash Admin API. It evaluates code changes to decide when a feature flag is needed, creates flags with proper validation and typing, and detects existing flags to prevent duplicates or encourage reuse. The server streams progress for visibility during operations, handles errors gracefully with helpful hints, and follows best practices from the Unleash documentation.
Every tool falls into one of these use cases:
See the Tool reference section for detailed parameters and output for each tool.
The sections below walk through each use case. For agent-specific prompt examples and setup, see the dedicated integration guides for Claude Code, Cursor, GitHub Copilot, Kiro, and OpenCode.
Use this workflow when implementing a change that might affect production stability, such as a payment integration, authentication flow, or external API call.
The assistant calls evaluate_change to assess the code change, score its risk, and recommend whether a feature flag is needed.
detect_flag runs automatically as part of evaluation to search for existing flags. If a suitable flag exists, the assistant suggests reusing it instead of creating a duplicate.
You have two ways to run the Unleash MCP server:
This section covers the different ways to install and run the Unleash MCP server locally. You can either follow a setup for agents (such as Claude Code and Codex), run the MCP as a standalone process using npx, or use a local development setup.
Before you can run the server locally, you need the following:
You can add the MCP server directly to Claude Code or Codex. Agent configurations are path-specific. You must run the following command from the root directory of the project where you want to use the MCP.
For Claude Code:
Check out the dedicated Claude Code integration guide for additional guidance and best practices.
For Codex:
For other agents, see the dedicated integration guides:
You can run the MCP server as a standalone process without cloning the repository using npx. Provide configuration through environment variables or a local .env file in the directory where you run the command:
The CLI supports the same flags as the local build (for example, --dry-run, --log-level).
Follow these steps to set up the project for local development.
Clone the repository and install dependencies using Yarn.
Copy .env.example to .env and fill in your Unleash credentials:
Edit .env:
Output will be in the dist/ directory.
Run type checking, linting, and tests:
Development mode with hot reload
Production mode
With CLI flags
The remote MCP server lets LLM clients connect to a Streamable HTTP MCP server hosted by your Unleash instance, without installing anything locally. This is useful when developers cannot run MCP servers on their laptops, or when you want to manage MCP access centrally.
When enabled, your Unleash instance exposes an MCP endpoint at:
The remote MCP server exposes the same tools as the local server.
To enable the remote MCP server on your instance:
Only enable the remote MCP server if your organization allows the OAuth 2.0 Dynamic Client Registration (DCR) authorization workflow. DCR lets MCP clients self-register with your instance without prior administrator approval, which is required to support clients such as Claude Code that do not pre-register OAuth clients. Review your organization’s policy before enabling this.
The remote MCP server authenticates requests using standard Unleash personal access tokens (PATs). Once the remote MCP server is enabled, users can exchange their current login session for a PAT that is valid for 24 hours, and the MCP client uses that token to call the endpoint.
Once the remote MCP server is enabled, point your MCP client at the endpoint shown in Admin settings > Remote MCP server and complete the authentication flow in your browser to issue a PAT for the client.
This section describes each of the core tools in detail, including its purpose, parameters, and output.
The create_flag tool creates a new feature flag in Unleash with comprehensive validation and progress tracking.
Use this tool when you have already determined that a feature flag is required (for example, after running evaluate_change) and you are ready to create it with the correct type and metadata.
The tool accepts the following parameters:
name (required): Unique feature flag name within the project.type (required): Feature flag type indicating lifecycle and intent.
release: Gradual feature rollouts to users.experiment: A/B tests and experiments.operational: System behavior and operational toggles.kill-switch: Emergency shutdowns or circuit breakers.permission: Control feature access based on user roles or entitlements.description (required): Clear explanation of what the flag controls and why it exists.projectId (optional): Target project (defaults to UNLEASH_DEFAULT_PROJECT).impressionData (optional): Enable analytics tracking (defaults to false).Agent prompt
Tool payload
Tool output
On success, the tool returns a JSON object containing the new feature flag’s URL in the Unleash Admin UI, an MCP resource link for programmatic access, creation timestamp, and configuration details.
The evaluate_change tool evaluates whether a code change should be behind a feature flag. It examines the structure, context, and potential risk of the change and returns a recommendation with an explanation and next steps.
Use evaluate_change at the beginning of a feature or modification when you want to understand whether the work requires a feature flag. This tool is also helpful when you are unsure which flag type to use or want guidance on rollout planning.
The tool returns detailed, markdown-formatted guidance for the LLM assistant based on Unleash best practices.
The guidance includes:
When evaluate_change determines a flag is needed, it provides explicit instructions to:
create_flag tool to create the feature flag.wrap_change tool to get language-specific code wrapping guidance.The evaluation process
The tool follows a clear evaluation process:
Risk assessment
The tool uses language-agnostic patterns to score risk:
Parent flag detection
The tool looks for common patterns across languages, such as:
if (isEnabled('flag')), if client.is_enabled('flag'):const enabled = useFlag('flag')const enabled = useFlag('flag') → {enabled && <Component />}if (!isEnabled('flag')) return;withFeatureFlag('flag', () => {...})All parameters are optional, but more context leads to better recommendations:
repository (string): Repository name or path.branch (string): Current branch name.files (array): List of files being changed.description (string): Description of the change.riskLevel (enum): low, medium, high, or critical, as assessed by the user.codeContext (string): Surrounding code for parent flag detection.Agent prompt
Simple usage where you let the agent gather context:
Explicit instructions:
Tool payload
Tool output
Returns a JSON object with the evaluation result, including a needsFlag boolean, a recommendation (e.g., “create_new”), a suggested flag name, risk level, and a detailed explanation.
The detect_flag tool finds existing feature flags in the codebase so you can reuse them instead of creating duplicates. This tool is automatically integrated into the evaluate_change workflow but can also be used manually.
Use this tool before creating a new feature flag or during code evaluation to check for existing flags that might already cover your use case. This helps prevent flag duplication.
The tool returns comprehensive search instructions and uses multiple detection strategies:
The tool then follows a scoring process:
Confidence levels
The tool returns candidates with confidence scores:
≥0.7: Strong match; reuse is recommended.0.4-0.7: Possible match; review manually.<0.4: Weak match; likely create a new flag.description (required): Description of the change or feature. For example, "payment processing with Stripe", "new checkout flow".files (optional): Files being modified. For example, ["src/payments/stripe.ts", "src/checkout/flow.ts"].codeContext (optional): Nearby code to scan for flags.Agent prompt
Check for existing flags before creating a flag:
Integrated automatically in evaluation:
Tool payload
Tool output
Returns a JSON object indicating if a flag was found. If flagFound is true, it includes a candidate object with the flag’s name, location, confidence score, and the reason for the match.
Match found:
No match found:
The tool wrap_change generates language-specific code snippets and guidance for wrapping code with feature flags. It helps LLMs and developers follow existing patterns in the codebase and use flags correctly.
Use this tool after you have created a feature flag (with create_flag) and need to implement it in your code. It’s especially useful when you want to ensure you are following existing codebase patterns or need framework-specific examples (e.g., React, Django).
This tool is the final step in the evaluate_change → create_flag → wrap_change workflow.
The tool provides the following guidance in its response:
Supported languages and frameworks:
flagName (required): Feature flag name to wrap the code with. For example: "new-checkout-flow", or "stripe-integration".language (optional): Programming language (auto-detected from fileName if not provided). Supported: typescript, javascript, python, go, ruby, php, csharp, java, rustfileName (optional): File name being modified (helps detect language), For example: "checkout.ts", "payment.py", or "handler.go".codeContext (optional): Surrounding code to help detect existing patterns.frameworkHint (optional): Framework for specialized templates. For example, "React", "Express", "Django", "Rails", or "Spring Boot".Agent prompt
Tool payload
Tool output
Returns a comprehensive, markdown-formatted string that guides the user on how to wrap their code. This includes a quickstart, search instructions, wrapping instructions with placeholders, all available templates for the language, and links to SDK documentation.
The server follows a focused, purpose-driven design.
{code, message, hint} format.This section provides a quick reference for all configuration options.
Environment variables:
UNLEASH_BASE_URL: Your Unleash instance URL (required).UNLEASH_PAT: Personal access token (required).UNLEASH_DEFAULT_PROJECT: The default project ID the MCP should use (optional).CLI flags:
--dry-run: Simulate operations without making actual API calls.--log-level: Set logging verbosity (debug, info, warn, error).AI assistants can make mistakes and toggle the wrong flag. When change requests are enabled for an environment, the MCP server submits a change request instead of applying the change directly. A human must approve the request before it takes effect, preventing accidental changes whether made manually or by an AI assistant.
Enable change requests on any environment where unreviewed changes pose a risk, especially production. For configuration steps, see change requests.
This server encourages Unleash best practices from the official documentation:
new-checkout-flowenable-ai-recommendations not flag1.mobile-push-notifications.This server uses the Unleash Admin API. For complete API documentation, see:
POST /api/admin/projects/{projectId}/features - Create feature flagError: “UNLEASH_BASE_URL must be a valid URL”: Ensure your base URL is complete, including protocol. For example, https://app.unleash-hosted.com/instance. Remove any trailing slashes.
Error: “UNLEASH_PAT is required”: Check that your .env file exists and contains UNLEASH_PAT={{your-personal-access-token}}. Verify that the token is valid in Unleash.
Error: “HTTP_401”: Your personal access token may be invalid or expired. Generate a new token under Profile > View Profile settings > Personal API tokens > New token.
Error: “HTTP_403”: Your token doesn’t have permission to create flags in this project. Review your role and permissions in Unleash.
Error: “HTTP_404”: The project ID doesn’t exist. Confirm the project ID in Unleash Admin UI.
Error: “HTTP_409”: A flag with this name already exists in the project. Use a different name or reuse the existing flag.
MIT
This is a purpose-driven project with a focused scope. Contributions should: