# MCP server

AI agents like Claude Code can create feature flags, turn them on and write the
code that checks them through Flagbearer's MCP server:

```
https://mcp.flagbearer.dev
```

## Connect an agent

Add the server with just its URL. The first time the agent uses it, Flagbearer
opens in your browser. Pick the organization it can use and the access,
**Editor** or **Viewer**, and click **Connect**.

- **Claude Code:** run
  `claude mcp add --transport http flagbearer https://mcp.flagbearer.dev`, then
  `/mcp`, and choose flagbearer to sign in.
- **Claude.ai and Claude Desktop:** add a custom connector with the URL
  `https://mcp.flagbearer.dev`.

The agent appears on the organization's **API tokens** tab as a connected
app. Disconnect it there to end its access right away.

### With a personal API token

For clients that can't sign in through the browser:

1. Open your organization's **API tokens** tab and create a token. Pick
   **Editor** so the agent can create and change flags.
2. Add the server with the token as a header. In Claude Code:

   ```sh
   claude mcp add --transport http flagbearer https://mcp.flagbearer.dev \
     --header "Authorization: Bearer fb_pat_…"
   ```

For a team, commit an `.mcp.json` that reads each person's own token from their
environment, so no secret is in the repository:

```json
{
  "mcpServers": {
    "flagbearer": {
      "type": "http",
      "url": "https://mcp.flagbearer.dev",
      "headers": { "Authorization": "Bearer ${FLAGBEARER_TOKEN}" }
    }
  }
}
```

Other MCP clients take the same URL and header in their own settings.

## Tools

| Tool                  | What it does                                                                                                                  |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `list_organizations`  | The organizations you belong to                                                                                               |
| `list_applications`   | An organization's applications                                                                                                |
| `list_flags`          | An application's flags, on or off with their rollout, everywhere                                                              |
| `create_flag`         | Creates a flag, off in every environment                                                                                      |
| `set_flag`            | Turns a flag on or off in one environment                                                                                     |
| `generate_flag_types` | The typed flag keys file for a TypeScript project, which the agent saves                                                      |
| `get_sdk_docs`        | These SDK docs for React, the browser, Node, Python, Go, Java, .NET, Ruby, Rust, C++ or PHP, with an environment's client key |

Before an agent writes code that checks a flag, it's told to read the SDK docs
for the platform the code runs on, so it follows the same guidance you see
here. It never gets a server key: those are shown once, in the dashboard.

## Safeguards

- **Who gets a flag.** Turning a flag on without a percentage reaches only the
  environment's testers. The agent is told to ask whether it should be on for
  everyone.
- **Production.** The agent must confirm with you before changing the
  `production` environment.
- **Access.** The agent works in the one organization you picked, as you,
  capped at the access you picked. It stops working if you leave the
  organization.
- **Limits.** Each token can make 60 changes a minute.
