# MCP

Pagebee runs one remote MCP server. Connect it to Claude Code, Cursor, Codex or any client that can send a header, and your agent can answer questions about your numbers or set up a new property end to end.

```text
https://api.pagebee.ai/mcp
```

Streamable HTTP, stateless. Authenticate with an API key in the `Authorization` header.

## 1. Make a key

In workspace settings, API keys and MCP, create a key:

- **Read** keys can query your numbers and change nothing.
- **Dev** keys can also create sites, keys, goals, channels and hostname rules.

You can limit a key to some sites and apps. The key starts with `pb_ak_` and is shown once.

## 2. Connect your client

### Claude Code

```bash
claude mcp add --transport http pagebee https://api.pagebee.ai/mcp \
  --header "Authorization: Bearer pb_ak_your_key"
```

### Cursor

```json title="~/.cursor/mcp.json"
{
  "mcpServers": {
    "pagebee": {
      "url": "https://api.pagebee.ai/mcp",
      "headers": { "Authorization": "Bearer pb_ak_your_key" }
    }
  }
}
```

### Codex

```toml title="~/.codex/config.toml"
[mcp_servers.pagebee]
url = "https://api.pagebee.ai/mcp"
bearer_token_env_var = "PAGEBEE_API_KEY"
```

One-click connection from Claude.ai needs OAuth, which is on the way. Until then, use a key.

## 3. Ask

To set up the project you're in:

```text
Add Pagebee analytics to this project. Create a property for it, install the snippet, make preview deploys count as preview, add a goal for sign-ups, then verify the install and tell me what you saw.
```

To read your numbers: "How did the 2.0 launch do?", "Why did sign-ups drop on Tuesday?", "Which pages bring the most installs?"

## Intelligence tools (read keys)

| Tool | What it does |
| --- | --- |
| `list_sites` | Every site and app the key can see |
| `get_schema` | Metrics, dimensions, event names, goals, funnels and environments for a site |
| `query_metrics` | Any metric, filtered and broken down, for any range |
| `get_top` | Top pages, referrers, channels, countries, devices, campaigns or events |
| `get_timeseries` | Metrics by hour, day, week or month |
| `get_funnel` | Step counts for a saved or ad hoc funnel |
| `compare_periods` | A range against the previous period or last year |
| `get_realtime` | Visitors in the last 5 and 30 minutes |
| `explain_change` | The sources, pages, countries or versions behind a change |

## Dev tools (dev keys, adds to read)

| Tool | What it does |
| --- | --- |
| `create_site` | Add a website, iOS, Mac, Android or server property |
| `update_site_settings` | Domains, timezone, currency, excluded paths and hostname rules |
| `get_install_snippet` | The script tag, Swift or Kotlin setup, or a server example |
| `verify_install` | Check the snippet is live and production events arrived |
| `list_recent_events` | The latest raw events, without visitor identifiers |
| `upsert_goal` | Create or update a goal |
| `delete_goal` | Remove a goal; asks for confirmation |
| `create_api_key` | Ingest keys, or read-only API keys |
| `create_channel` | A feed channel with an emoji and push setting |
| `send_test_event` | One test event, end to end, not counted |

## Safety

Read tools are marked read-only to the client and `delete_goal` is marked destructive. Every dev call is written to the workspace audit log with the key that made it. Revoking a key takes effect within a minute. Each key can make 120 calls a minute.
