Skip to main content

Connect AI coding assistants and autonomous agents to Flaggr using the official @flaggr/mcp-server package

Last updated September 14, 2026

Model Context Protocol (MCP) Server

The Flaggr MCP Server (@flaggr/mcp-server) connects AI coding assistants—such as Claude Desktop, Cursor, VS Code Copilot, and Antigravity—directly to your Flaggr instance.

With the MCP server, AI assistants can:

  • List, create, update, evaluate, and toggle feature flags
  • Inspect post-toggle safety, health, and error rate drift
  • Profile distributed traces and detect server-side latency hotspots
  • Measure true SSE real-time stream propagation latency (RTT)
  • Inspect granular audit logs with path-scoped diffs
  • Execute staged canary rollouts and A/B test experiments

Installation & Setup

1. Claude Desktop

Add @flaggr/mcp-server to your claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "flaggr": {
      "command": "npx",
      "args": ["-y", "@flaggr/mcp-server"],
      "env": {
        "FLAGGR_API_URL": "https://flaggr.dev",
        "FLAGGR_API_TOKEN": "fgr_your_token_here"
      }
    }
  }
}

Tip: If you have already authenticated using the Flaggr CLI (flaggr login), the MCP server will automatically discover your credentials from ~/.flaggr/config.json. You can omit FLAGGR_API_TOKEN.

2. Cursor IDE

Add to your project's .cursor/mcp.json or Global Cursor Settings:

{
  "mcpServers": {
    "flaggr": {
      "command": "npx",
      "args": ["-y", "@flaggr/mcp-server"],
      "env": {
        "FLAGGR_API_URL": "https://flaggr.dev",
        "FLAGGR_API_TOKEN": "fgr_your_token_here"
      }
    }
  }
}

Authentication Methods

The Flaggr MCP server supports three authentication methods:

  1. Auto-Discovery via Flaggr CLI: Reads ~/.flaggr/config.json minted by flaggr login. Zero configuration required.
  2. Interactive OAuth via login Tool: Prompt the agent: "Log in to Flaggr". The agent calls the login tool, opening your browser to authorize and select a project.
  3. Direct Environment Variable: Set FLAGGR_API_TOKEN in your MCP configuration.

Tool Catalog

The MCP server exposes 30+ tools organized into functional domains:

Feature Flag Operations

ToolParametersDescription
list_flagsprojectId, serviceId?, environment?List all flags with current states
get_flagkey, serviceId, environmentRetrieve complete flag configuration
create_flagkey, name, type, defaultValue, projectId, serviceId, ...Create a new boolean, string, number, or object flag
update_flagkey, serviceId, environment, name?, description?, ...Modify flag properties, descriptions, and default values
toggle_flagkey, serviceId, environment?, enabled?Toggle flag or set explicit boolean state
delete_flagkey, serviceId, environmentPermanently delete a feature flag
evaluate_flagflagKey, serviceId?, environment?, context?Evaluate flag with targeting context and reason
check_and_rollback_flagflagKey, serviceId, environment?, dryRun?, maxErrorRateDelta?Evaluates drift safety and triggers automated rollback if degraded
get_stale_flagsprojectIdDiscovers stale, inactive, and launch-ready flags with technical debt scoring and code cleanup advice

Post-Toggle Safety & Analytics

ToolParametersDescription
get_flag_toggle_impactflagKey, serviceId, environment?, range?, windowMinutes?Evaluates pre- vs post-toggle error rates, P99 latency shifts, volume ratio, and returns an automated health badge (healthy, warning, degraded) with rollback advice
get_flag_metricsflagKey, serviceId, environment?, range?Detailed volume, realtime evals/sec, percentiles, breakdowns, and time series
get_sdk_analyticsserviceId?, environment?, flagKey?, range?Retrieves client-side SDK analytics: evaluation summaries, Core Web Vitals (LCP, CLS, FCP) correlated to active flags, client error rates, and SDK diagnostics
get_evaluation_heatmapprojectId, range?, serviceId?, environment?Grid of evaluation activity across all flag x service cells
get_project_healthprojectIdAggregated platform health score and active issues

Distributed Tracing & Hotspot Detection

ToolParametersDescription
get_tracetraceIdRenders an ASCII flamechart waterfall for an OpenTelemetry trace with hotspot analysis
get_flag_tracesflagKey?, serviceId?, environment?, limit?Queries recent evaluation traces for bottlenecks
trace_flag_evaluationflagKey, serviceId?, context?Evaluates flag on-demand, captures full trace, and returns flamechart

Real-Time Streaming & RTT

ToolParametersDescription
measure_round_tripkey, serviceId, environment?, enabled?Connects to SSE stream, mutates flag, and measures millisecond propagation time
watch_flag_updatesserviceId, environment?, flagKey?, durationSeconds?Listens to live Server-Sent Events updates

Audit & Revision History

ToolParametersDescription
get_audit_logprojectId, limit?, cursor?, action?, search?Query audit log with path-scoped diffs (e.g. targeting[0].percentage: 50 -> 75)
get_flag_historyflagKey, serviceId, environment?, limit?Version history and per-version deep diffs

Progressive Canary Delivery & Rollouts

ToolParametersDescription
start_canary_rolloutflagKey, serviceId, environment?, initialRolloutPercent?, targetRolloutPercent?, rampStepPercent?, soakPeriodMinutes?, errorRateGateDelta?, latencyGateDeltaMs?, autoRollbackOnBreach?Start an automated progressive canary rollout (e.g. 5% -> 25% -> 50% -> 100%) with metric health gates
get_canary_statusflagKey, serviceId, environment?Query current canary pipeline status, stage progress, soak time remaining, and real-time metric health assessment
advance_canary_stageflagKey, serviceId, environment?, force?Advance a canary rollout to its next progressive stage after verifying metric health gates
abort_canary_rolloutflagKey, serviceId, environment?, reason?Immediately abort a canary rollout and automatically revert the flag to its pre-canary baseline snapshot

Targeting Rule Explanation & Blast-Radius Simulator

ToolParametersDescription
explain_flag_evaluationflagKey, serviceId, environment?, context?, defaultValue?Step-by-step diagnostic evaluation debugger explaining clause-by-clause why a user context resolved to a specific variant
simulate_flag_targetingflagKey, serviceId, environment?, candidateFlag?, cohortSize?, cohortAttributes?Counterfactual blast-radius simulation comparing current baseline flag vs proposed candidate flag across synthetic user cohorts

Adaptive Multi-Armed Bandits & Experimentation

ToolParametersDescription
list_bandit_experimentsprojectId?, serviceId?, flagKey?, environment?List active Multi-Armed Bandit experiments
create_bandit_experimentname, projectId, serviceId, flagKey, algorithm?, epsilon?, minExplorationFloor?, confidenceThreshold?, autoRolloutWinner?Initialize Bayesian Thompson Sampling or Epsilon-Greedy bandit on a feature flag
get_bandit_statusexperimentIdGet real-time conversion rates, Beta prior parameters, and posterior win probabilities
reallocate_bandit_trafficexperimentIdDynamically rebalance feature flag variant weights and auto-rollout winner if confident
record_bandit_rewardexperimentId, variantName, converted?Ingest evaluation trial and conversion reward for a bandit variant

Reusable Customer Cohorts & Dynamic Segments

ToolParametersDescription
list_cohortsprojectIdList reusable customer cohorts and dynamic audience segments in a project
get_cohortprojectId, cohortIdGet cohort definition, audience rules, and static member count by ID
create_cohortprojectId, name, type, description?, rules?, members?Create a new reusable customer cohort (static list or rule-based dynamic predicate)
evaluate_cohort_membershipprojectId, cohortId, userId, context?Test whether a user targeting key and evaluation context match an audience cohort

MCP Resources

Agents can read context directly via dynamic resource URIs:

  • flaggr://auth/status — Active token preview, current project, and connection status
  • flaggr://projects — List of all accessible projects
  • flaggr://project/{slug}/flags — Feature flags in a project
  • flaggr://flag/{key}/health — Flag health status
  • flaggr://flag/{key}/toggle-impact — Post-toggle safety and drift analysis

MCP Prompts

The server provides pre-packaged prompt templates for complex flag management tasks:

verify_toggle_safety

Prompts the agent to inspect the safety of a recent flag toggle:

Verify post-toggle safety for flag "checkout-v2" in service "web-app".

The agent calls get_flag_toggle_impact, analyzes before/after error rates and P99 latencies, and proposes rolling back if health is degraded.

gradual_rollout

Guides an agent through a staged percentage rollout (5% → 25% → 50% → 100%), verifying health metrics at each step before advancing.

ab_test_setup

Designs an experiment with treatment and control variants, sets traffic allocation, and configures outcome metrics.


Autonomous Agent Workflow Examples

Example: Verifying a Production Flag Toggle

Ask your assistant:

"Check if toggling new-payment-engine in production was safe or if there was any error drift."

The assistant invokes:

{
  "tool": "get_flag_toggle_impact",
  "arguments": {
    "flagKey": "new-payment-engine",
    "serviceId": "checkout-service",
    "environment": "production"
  }
}

The MCP server responds with:

============================================================
FLAG TOGGLE IMPACT REPORT: new-payment-engine
============================================================
Status: [HEALTHY]
Latest Toggle Event:
  - Transition: false -> true
  - Actor:      lead-dev@flaggr.dev
  - Timestamp:  2026-09-12T08:00:00.000Z
  - Propagation Latency: 38ms
 
Before vs After Comparison (±30m window):
┌──────────────────────┬─────────────┬─────────────┬────────────────┐
│ Metric               │ Before      │ After       │ Delta / Ratio  │
├──────────────────────┼─────────────┼─────────────┼────────────────┤
│ Evaluations          │ 2450        │ 2480        │ 1.01x          │
│ Errors               │ 1           │ 1           │ +0             │
│ Error Rate           │ 0.04%       │ 0.04%       │ +0.00%         │
│ Avg Latency          │ 1.35ms      │ 1.34ms      │ -              │
│ P99 Latency          │ 3.80ms      │ 3.75ms      │ -0.05ms        │
└──────────────────────┴─────────────┴─────────────┴────────────────┘
 
Automated Recommendation:
Healthy: Post-toggle metrics are stable with no significant error or latency regression.
============================================================

The assistant summarizes the findings and confirms the deployment is stable.


Next Steps