npm package: @mcp-packages/flagsmith-server
Description: MCP server for Flagsmith — feature flag listing, search, inspection, and toggling via the Model Context Protocol
Latest version: 0.1.0

# @mcp-packages/flagsmith-server

MCP server for [Flagsmith](https://flagsmith.com) — list, search, inspect, and toggle feature flags via the Model Context Protocol.

Designed for self-hosted Flagsmith instances. Connects to the Flagsmith Admin API over VPN.

## Setup

### 1. Create an API Token

1. Log in to your Flagsmith dashboard
2. Go to **Organisation Settings** → **API Keys**
3. Create an Admin API token
4. Note your **Project ID** (visible in the dashboard URL: `/project/<id>/...`)

### 2. Environment Variables

| Variable | Required | Description |
|---|---|---|
| `FLAGSMITH_API_TOKEN` | Yes | Admin API token for authentication |
| `FLAGSMITH_BASE_URL` | Yes | Base URL of your Flagsmith API (e.g., `https://flagsmith.yourcompany.com/api/v1`) |
| `FLAGSMITH_PROJECT_ID` | Yes | Numeric project ID |

### 3. Configure Your IDE

#### Cursor (`.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "flagsmith": {
      "command": "npx",
      "args": ["-y", "@mcp-packages/flagsmith-server"],
      "env": {
        "FLAGSMITH_API_TOKEN": "${FLAGSMITH_API_TOKEN}",
        "FLAGSMITH_BASE_URL": "https://flagsmith.yourcompany.com/api/v1",
        "FLAGSMITH_PROJECT_ID": "12345"
      }
    }
  }
}
```

#### Claude Code

```bash
claude mcp add flagsmith -- npx -y @mcp-packages/flagsmith-server
```

Set environment variables in your shell profile (`~/.zshrc`):

```bash
export FLAGSMITH_API_TOKEN="your-token"
export FLAGSMITH_BASE_URL="https://flagsmith.yourcompany.com/api/v1"
export FLAGSMITH_PROJECT_ID="12345"
```

## Tools

| Tool | Description |
|---|---|
| `list_flags` | List all feature flags in the project |
| `search_flags` | Search flags by name substring |
| `get_flag` | Get flag details including state across all environments |
| `get_environment_flags` | Get all flag states for a specific environment |
| `toggle_flag` | Enable or disable a flag in an environment |
| `update_flag_value` | Update a flag's remote config value in an environment |

### Tool Details

#### `list_flags`

No parameters. Returns all flags with name, description, tags, default enabled state, and type.

#### `search_flags`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `query` | string | Yes | Search term to match against flag names |

#### `get_flag`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flagName` | string | Yes | Exact name of the feature flag |

Returns flag metadata plus enabled state and value for every environment.

#### `get_environment_flags`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `environmentKey` | string | Yes | Flagsmith environment API key (e.g., `ser.abc123...`) |

#### `toggle_flag`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flagName` | string | Yes | Exact name of the feature flag |
| `environmentKey` | string | Yes | Flagsmith environment API key |
| `enabled` | boolean | Yes | `true` to enable, `false` to disable |

#### `update_flag_value`

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flagName` | string | Yes | Exact name of the feature flag |
| `environmentKey` | string | Yes | Flagsmith environment API key |
| `value` | string | Yes | New remote config value (plain string or JSON) |

## Development

```bash
# Install dependencies (from monorepo root)
npm install

# Build
npm run build -w @mcp-packages/flagsmith-server

# Watch mode
npm run dev -w @mcp-packages/flagsmith-server
```