# Statsig MCP with Claude Code

## Installation and authentication with OAuth

{% callout type="note" %}
MCP OAuth only supports Personal Console API Keys. Ensure your Statsig org
owner has enabled Personal Console API Keys creation for your role
[here](https://console.statsig.com/settings?tab=organization){" "}
{% /callout %}

On Claude Code, use OAuth and the HTTP transport directly. Run this command:

```bash
claude mcp add --transport http statsig https://api.statsig.com/v1/mcp
```

This command:

* Adds the Statsig MCP server to your Claude Code configuration
* Configures it to use HTTP transport with OAuth authentication
* Sets up the connection to Statsig's MCP endpoint

To authenticate with OAuth, run `/mcp` in Claude Code and follow the setup instructions:

1. Claude Code opens a browser window.
2. Sign in to your Statsig account.
3. Authorize the MCP server to access your Statsig project.
4. Claude Code saves the authentication for future sessions.

{% accordion title="Using API key instead of OAuth" %}
OAuth is the recommended setup, but you can also authenticate with your Console API key. Run this command on the command line:

```bash
claude mcp add --transport http statsig-local https://api.statsig.com/v1/mcp \
  --header "statsig-api-key: console-YOUR-CONSOLE-API-KEY"
```

Replace `console-YOUR-CONSOLE-API-KEY` with your actual Statsig Console API key, which you can retrieve [here](https://console.statsig.com/api_keys). Ensure your API key has the required permissions: read-only keys can view data, while write keys can make changes to your project.
{% /accordion %}

## Verify the connection

After installation, verify the connection:

1. Open Claude Code.
2. Ask Claude to list your Statsig experiments or gates.
3. Confirm that Claude can access your Statsig data.

## Using Statsig MCP with Claude Code

After configuration, you can interact with your Statsig data through Claude Code:

* **Query Experiments**: "What experiments are currently running?"
* **Manage Gates**: "List all my feature flags"
* **Get Details**: "Show me the configuration for gate 'new-feature'"
* **Create Entities**: "Create a new experiment called 'checkout-test'"

## Troubleshooting

If you encounter issues:

* Make sure you have the latest version of Claude Code.
* Verify your Statsig account has the necessary API permissions.
* Check that the MCP server URL is correct: `https://api.statsig.com/v1/mcp`.
* Try re-running the installation command.

## Related resources

* [MCP capabilities](https://docs.statsig.com/integrations/mcp/overview#current-mcp-capabilities)
* [Use cases](https://docs.statsig.com/integrations/mcp/overview#use-cases) for Statsig MCP
* Set up Statsig MCP in other tools: [Cursor](https://docs.statsig.com/integrations/mcp/cursor), [Codex CLI](https://docs.statsig.com/integrations/mcp/codex)
