RE

Reflag MCP Server: Create and Manage Feature Flags

Create and manage feature flags on an MCP server with Reflag to control rollouts, A/B tests, and user targeting.

Overview

The Reflag MCP Server implements the Model Context Protocol (MCP) for managing feature flags, rollouts, and evaluation contexts. It is intended to be used alongside the Reflag CLI to create, update and evaluate flags locally or in a development environment. By exposing a simple HTTP/JSON evaluation API and a set of CLI commands, the MCP server lets teams prototype and test feature rollouts, A/B experiments, and user targeting without requiring a hosted feature flag service.

Using an MCP server is useful when you want a reproducible, versioned source of truth for flags and evaluation logic that integrates with local tooling and CI pipelines. It stores flag models, environments, and targeting rules, and can evaluate flags against a supplied model context (for example, a user object). The same models can be used by client SDKs or a gateway in production, so development and staging behavior matches production expectations.

Features

  • Create and edit feature flags, variants and default values
  • Define environments (development, staging, production) with independent rules
  • Target users or groups using attributes in the model context
  • Percentage rollouts and A/B testing via variant weightings or deterministic bucketing
  • Local evaluation API that accepts a model context (e.g., user) and returns flag values
  • Import/export of flag definitions to JSON for versioning and CI
  • CLI-first workflow that integrates into scripts and pipelines

Installation / Configuration

Install the Reflag CLI (contains MCP server subcommands). You can use npm/yarn or run with npx:

# Install globally
npm install -g @reflag/cli

# Or run via npx without global install
npx @reflag/cli mcp server --help

Start a local MCP server (example):

# start server on port 8080 with a local data directory
npx @reflag/cli mcp server start --port 8080 --data ./mcp-data

Minimal configuration file (reflag.mcp.json):

{
  "port": 8080,
  "dataDir": "./mcp-data",
  "environments": ["development", "staging", "production"],
  "defaultEnvironment": "development"
}

Environment variables (optional):

  • REFLAG_MCP_PORT — port the server listens on (e.g., 8080)
  • REFLAG_MCP_DATA_DIR — path to persist flag models and exports

Create a flag from the CLI (example):

npx @reflag/cli mcp flag create \
  --name "new_checkout" \
  --type boolean \
  --default false \
  --env development

Export/import flag definitions for version control:

# Export all flags to a JSON file
npx @reflag/cli mcp export --out flags-export.json

# Import flags from a JSON file
npx @reflag/cli mcp import --file flags-export.json

Available Resources

  • GitHub repository (source and packages): https://github.com/reflagcom/javascript/tree/main/packages/cli#model-context-protocol
  • CLI help: run npx @reflag/cli mcp --help or npx @reflag/cli mcp server --help
  • Model Context Protocol (MCP): use the server’s evaluation contract to send model contexts (user, session, request attributes) to the server for deterministic evaluation

Common server endpoints (illustrative):

EndpointMethodDescription
/v1/flagsGETList flags and metadata
/v1/flags/:idGET/PUT/DELETERead/update/delete a flag
/v1/evaluatePOSTEvaluate one or more flags against a model context

Example evaluate request (POST /v1/evaluate):

{
  "environment": "development",
  "modelContext": {
    "user": {
      "id": "user-123",
      "email": "[email protected]",
      "country": "US",
      "segment": ["beta_testers"]
    }
  },
  "flags": ["new_checkout", "pricing_experiment"]
}

Response example:

{
  "evaluations": {
    "new_checkout": { "value": true, "reason": "rule:beta_testers" },
    "pricing_experiment": { "value": "variant_b", "reason": "rollout:50%" }
  }
}

Use Cases

  • Gradual rollout
    • Create a boolean flag with a default of false, and add a percentage rollout rule for a small subset of