# Connect over MCP (/docs/agents/mcp)

Datahop's [MCP](https://modelcontextprotocol.io) server is at `https://app.datahop.dev/mcp`. It uses the streamable HTTP transport and a project [API key](/docs/agents/api-keys).

<CopyPrompt preset="connect" primary>
  Give this to your agent. It connects over MCP (or the [CLI](/docs/agents/cli)), learns your data and reports what's interesting, without changing anything until you say so.
</CopyPrompt>

## 1. Create an API key [#1-create-an-api-key]

**Settings → API keys & MCP → Create key.** Give it a name you'll recognise in the activity log, such as `claude-growth-agent`, and choose **Read & write** or **Read only**. Copy the key (`dh_sk_…`): it's shown only once. The panel then shows the commands below with your key filled in.

## 2. Add the server [#2-add-the-server]

<Tabs items={['Claude Code', 'JSON config', 'curl']}>
  <Tab value="Claude Code">
    ```bash
    claude mcp add --transport http datahop https://app.datahop.dev/mcp \
      --header "Authorization: Bearer dh_sk_…"
    ```
  </Tab>
  <Tab value="JSON config">
    For clients that read an `mcpServers` file, such as Claude Desktop, Cursor and agent SDKs:

    ```json title="mcp.json"
    {
      "mcpServers": {
        "datahop": {
          "type": "http",
          "url": "https://app.datahop.dev/mcp",
          "headers": { "Authorization": "Bearer dh_sk_…" }
        }
      }
    }
    ```
  </Tab>
  <Tab value="curl">
    To check that a key works:

    ```bash
    curl -s https://app.datahop.dev/mcp \
      -H "Authorization: Bearer $DATAHOP_KEY" \
      -H 'content-type: application/json' \
      -H 'accept: application/json, text/event-stream' \
      -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }'
    ```
  </Tab>
</Tabs>

## 3. Ask something [#3-ask-something]

*"What's our signup → upgrade conversion this month, and where do people drop off?"*

The agent starts with `project_overview` and reads your real event names before it queries. It never guesses them. Descriptions you add under [Data](/docs/product-analytics#describe-your-events) make this step much more reliable.

## Good to know [#good-to-know]

- **One project per key.** The key decides the project, so tools never ask for one.
- **Your agent only sees what it can use.** A read-only key doesn't see tools that change things. A product that's switched off removes its tools. Changes apply on the agent's next call.
- **Reads and writes are labelled**, so your client can approve reads automatically and ask before writes.
- **Errors explain the fix**, such as *"Math "p99" needs mathProperty. Hint: set mathProperty to a numeric event property"*, so the agent can correct itself.
- **Very large results are cut short** with a note to narrow the question.
- **A revoked key stops working immediately.**

## Tips [#tips]

- **Start read-only** while you see how an agent behaves.
- **Give each agent its own key**, so the activity log shows who did what.
- **Ask for dashboards by name.** Reading a dashboard returns every card's summary in one call.
