# Statsig MCP Server

This server implements the Model Context Protocol (MCP) for Statsig API integration, supporting both stdio and SSE transports. It allows AI assistants to interact with your Statsig feature flags, experiments, and analytics data.

## Quick Start (Recommended)

The easiest way to get started is using our CLI installer:

```bash
npx @statsig/mcp
```

This will:
- 🚀 Install and build the MCP server
- 🔑 Prompt for your Statsig API key
- 📋 Generate and copy the configuration to your clipboard
- ✨ Provide step-by-step instructions

## Manual Installation

If you prefer to install manually:

```bash
npm install @statsig/mcp
```

Then build the project:

```bash
npm run build
```

## Configuration

### Integration with MCP Client Config

To use this server with an MCP client, configure your `mcp.json` as follows:

#### Using stdio transport (default)

```json
{
  "mcpServers": {
    "Statsig": {
      "command": "node /path/to/node_modules/@statsig/mcp/build/index.js",
      "env": {
        "STATSIG_API_KEY": "console-YOUR-CONSOLE-KEY"
      }
    }
  }
}
```

#### Using SSE transport

For clients that support SSE transport (like some web-based interfaces):

```json
{
  "mcpServers": {
    "Statsig": {
      "url": "http://localhost:3000/sse?STATSIG_API_KEY=console-<your-console-key>"
    }
  }
}
```

⚠️ **Security Note**: SSE transport passes the API key in the URL. While this data is encrypted when using HTTPS, we recommend proceeding with caution in production environments.

## Getting Your API Key

1. Visit [Statsig Console](https://console.statsig.com/api_keys)
2. Create a new Console API key
3. Copy the key (it should start with `console-`)

## Features

This MCP server provides access to:
- 🎯 Feature Gates
- 🧪 Dynamic Configs  
- 📊 Experiments
- 📈 Metrics and Analytics
- 👥 User Segments
- 🏷️ Tags and Organization

## Support

- 📖 [MCP Documentation](https://modelcontextprotocol.io/)
- 🐛 [Report Issues](https://github.com/statsig-io/mcp-statsig/issues)
- 💬 [Statsig Slack Community](https://statsig.com/slack)