> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Connect Claude and other AI assistants to your analytics

> Connect Claude Code, claude.ai, Cursor, VS Code, Codex or Windsurf to the CrispStats MCP server with a read-only API key, then ask about your numbers or let a coding agent check its install.

CrispStats runs a remote MCP server at `https://crispstats.com/api/mcp`. Add it to your AI client with a secret API key that has only the **Read** scope, and the assistant can answer questions from the same reports as the dashboard, give a coding agent the exact install code for your project and check that the install works. It cannot change anything.

The server uses the Streamable HTTP transport and authenticates with an `Authorization: Bearer cs_sk_…` header.

## Connect from the dashboard

**1. Open the connect screen**

Open the site's **Settings**, **Tracking code** and scroll to **Connect an AI assistant**.

**2. Create a read-only key**

Owners and admins select **Create read-only key**. It has only the **Read** scope and reads only the current site. It is shown once and fills in every setup below it. To cover every site instead, create a key under **API keys** on the [workspace page](https://docs.crispstats.com/account/api-keys.md#create-a-key) with **Read** checked and **Every site in** your workspace.

**3. Add the server to your client**

Pick your client. Copy the command or config with its copy button, or use **Add to Cursor**. The setups are the same as on this page.

## Each client

Replace `cs_sk_your_read_key` with your key. Where a client can read the key from an environment variable, the config does, so the key never sits in a file you might commit.

> [tab] Claude Code
>
> Run once in a terminal. `--scope user` makes the server available in every project:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> claude mcp add --transport http --scope user crispstats https://crispstats.com/api/mcp \
>   --header "Authorization: Bearer cs_sk_your_read_key"
> ```
>
> Run `claude mcp list`: `crispstats` shows as connected. In a session, `/mcp` lists its tools, and the prompts appear as slash commands such as `/mcp__crispstats__install_crispstats`.
>
> For a project's shared `.mcp.json`, read the key from the environment instead:
>
> ```json .mcp.json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "mcpServers": {
>     "crispstats": {
>       "type": "http",
>       "url": "https://crispstats.com/api/mcp",
>       "headers": { "Authorization": "Bearer ${CRISPSTATS_API_KEY}" }
>     }
>   }
> }
> ```

> [tab] claude.ai
>
> In claude.ai, open **Customize**, **Connectors**, select **Add** and **Add custom connector**, and enter:
>
> | Field | Value |
> | - | - |
> | Name | `CrispStats` |
> | Remote MCP server URL | `https://crispstats.com/api/mcp` |
> | Authentication | No sign in |
> | Request headers | `Authorization`: `Bearer cs_sk_your_read_key` |
>
> Claude Desktop and the mobile apps use the same connector. On Team and Enterprise plans an owner adds it under **Organization settings**, **Connectors**, and everyone who uses it reads with that one key. Free plans allow one custom connector.

> [tab] Cursor
>
> Use **Add to Cursor** on the connect screen, or add the server to `~/.cursor/mcp.json` for every project (`.cursor/mcp.json` for one), with the key in the `CRISPSTATS_API_KEY` environment variable:
>
> ```json ~/.cursor/mcp.json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "mcpServers": {
>     "crispstats": {
>       "url": "https://crispstats.com/api/mcp",
>       "headers": { "Authorization": "Bearer ${env:CRISPSTATS_API_KEY}" }
>     }
>   }
> }
> ```
>
> Restart Cursor and open **Cursor Settings**, **MCP**: `crispstats` is listed with its tools.

> [tab] VS Code
>
> Add the server to `.vscode/mcp.json`. VS Code asks for the key the first time the server starts and stores it securely:
>
> ```json .vscode/mcp.json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "inputs": [
>     {
>       "type": "promptString",
>       "id": "crispstats-key",
>       "description": "CrispStats API key (cs_sk_…)",
>       "password": true
>     }
>   ],
>   "servers": {
>     "crispstats": {
>       "type": "http",
>       "url": "https://crispstats.com/api/mcp",
>       "headers": { "Authorization": "Bearer ${input:crispstats-key}" }
>     }
>   }
> }
> ```
>
> Or add it to your user profile for every workspace with one command:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> code --add-mcp '{"name":"crispstats","type":"http","url":"https://crispstats.com/api/mcp","headers":{"Authorization":"Bearer cs_sk_your_read_key"}}'
> ```
>
> Start the server from the MCP servers list, then use it from Copilot Chat in agent mode.

> [tab] Codex
>
> Add the server to `~/.codex/config.toml`. Codex sends the key from the environment variable named in `bearer_token_env_var`:
>
> ```toml ~/.codex/config.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
> [mcp_servers.crispstats]
> url = "https://crispstats.com/api/mcp"
> bearer_token_env_var = "CRISPSTATS_API_KEY"
> ```
>
> Then set the variable in your shell profile and start Codex:
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> export CRISPSTATS_API_KEY="cs_sk_your_read_key"
> ```
>
> Run `/mcp` in Codex: `crispstats` is listed.

> [tab] Windsurf
>
> In Cascade, open **Manage MCPs**, then **View raw config**, and add the server to `mcp_config.json`:
>
> ```json mcp_config.json theme={"theme":{"light":"github-light","dark":"github-dark"}}
> {
>   "mcpServers": {
>     "crispstats": {
>       "serverUrl": "https://crispstats.com/api/mcp",
>       "headers": { "Authorization": "Bearer ${env:CRISPSTATS_API_KEY}" }
>     }
>   }
> }
> ```
>
> Set `CRISPSTATS_API_KEY` in your shell profile, then refresh the MCP list. On Teams and Enterprise plans an admin may need to allow remote MCP servers.

> [!WARNING]
>
> The key reads every site it covers until you revoke it. Keep config files that contain it out of version control, and revoke it under **API keys** on the workspace page when you stop using the assistant.

### Check the connection with curl

To confirm the key works before you configure a client, call `list_sites` directly:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://crispstats.com/api/mcp \
  -H "Authorization: Bearer cs_sk_your_read_key" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_sites","arguments":{}}}'
```

The response's `structuredContent.sites` lists the sites the key can read, with each site's `id`, `name`, `domain`, `timezone`, `currency`, `createdAt` and `installed`.

## Example prompts

* "Which sources brought the most revenue in the last 30 days?"
* "Compare this week's visitors with last week's and tell me what changed."
* "Which landing pages do ChatGPT and Perplexity send people to?"
* "Where do people drop off in my signup funnel?"
* "Which pages have the worst LCP on mobile?"
* "Install CrispStats in this project, then check that events arrive."
* "Wire the CrispStats visitor id into our Stripe checkout."

The server also offers three ready prompts: `install_crispstats`, `connect_payments` and `explain_last_week`. Clients show them as slash commands or in a prompt menu. See [install with an AI agent](https://docs.crispstats.com/install/ai-agents.md) for the install flow.

## What the assistant can do

Every tool is read-only. Each one except `list_sites` takes an optional `site` id, which can be left out when the key can read exactly one site.

| Tool | What it returns |
| - | - |
| `list_sites` | The sites this key can read. |
| `get_stats`, `get_timeseries`, `get_breakdown`, `get_realtime` | Traffic: key metrics, over time, by dimension, and right now. |
| `get_revenue_summary`, `list_payments` | Revenue totals and individual payments. |
| `list_goals`, `list_events`, `get_event_properties` | Goals, custom events and their properties. |
| `list_funnels`, `get_funnel`, `get_retention` | Funnels and retention cohorts. |
| `get_web_vitals`, `get_errors`, `get_uptime` | Site health. |
| `get_ai_traffic` | Visitors from AI assistants and AI crawler hits. |
| `list_visitors`, `get_visitor` | Anonymous visitors and a visitor's journey. |
| `get_install_guide` | The script element and proxy handler for a framework and host, with this site's values. |
| `check_installation` | Whether events arrive, from which hostnames, and whether the proxy forwards the visitor's address without cookies. |
| `get_revenue_setup` | The checkout wiring for a payment provider and whether it is connected. |

Money is integer minor units in the stated currency, rates are numbers from 0 to 1 and durations are seconds. The [MCP reference](https://docs.crispstats.com/api-reference/mcp.md) documents every tool's inputs and the error codes.

## Limits and errors

* **Rate limits.** MCP requests count against the same limits as the REST API: your plan's daily API requests per key, a workspace ceiling of five times that across all keys, plus a burst limit of 20 requests in 10 seconds. Each request in a POST counts once, including `initialize` and `tools/list`; a batch may hold at most 20 requests. See [rate limits](https://docs.crispstats.com/api-reference/rate-limits.md). MCP requests do not use [Ask AI](https://docs.crispstats.com/ai/ask-ai.md) messages.
* **Bad or revoked key.** HTTP `401` with JSON-RPC error code `-32001`. Create a new key under **API keys** on the workspace page.
* **Key without the Read scope.** HTTP `403`, also with code `-32001`.
* **Over a rate limit.** HTTP `429` with code `-32002` and a `Retry-After` header.
* **A tool fails**, for example on an invalid `range`. The tool result has `isError: true` and a message the assistant can read and correct.

Without an `Authorization` header the server only reads the public demo site, `demo`, under a lower limit of 500 requests a day and 10 in 10 seconds. If `list_sites` returns only that site, your client is not sending the header.

## Learn more on crispstats.com

* Glossary: [MCP](https://crispstats.com/glossary/mcp). Feature: [Ask AI](https://crispstats.com/features/ask-ai), the same read-only tools inside the dashboard.

## Next steps

> [card] [Install with an AI agent](https://docs.crispstats.com/install/ai-agents.md)
>
> One prompt for the whole install.

> [card] [MCP reference](https://docs.crispstats.com/api-reference/mcp.md)
>
> Transport, tools, prompts and error codes.

> [card] [API keys](https://docs.crispstats.com/account/api-keys.md)
>
> Create, limit, revoke and delete secret keys.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.