# Your analytics, inside Claude Code

Source: https://databull.app/mcp/claude-code
Updated: 2026-10-28 · Author: Ahmed Gagan (maker of DataBull)

> Add DataBull to Claude Code once and ask about traffic, sales and buyer journeys from any project. One command sets it up; the read-only key never leaves your machine and your dashboard.

**Short answer:** Run `npx databull@latest mcp`: it creates a read-only DataBull key and adds DataBull to Claude Code for all your projects. By hand, it's `claude mcp add --transport http --scope user databull https://YOUR-DATABULL-URL/mcp --header "Authorization: Bearer dbk_…"`. Then run `/mcp` in Claude Code to check it's connected, and ask.

## The one-command setup

```
npx databull@latest mcp
```

Here's what it does, in order:

1. Updates your DataBull if it's too old for agents.
2. Creates a read-only key named after your computer (or reuses the one it made before, if it still works).
3. Checks the connection by listing the tools.
4. If Claude Code is installed, asks before adding DataBull for **all your projects**, replacing an older `databull` entry if there is one.
5. Prints the config for Cursor, VS Code, Codex and Windsurf too, and a few questions to try.

Add `--client claude` to see only the Claude Code part, or `--yes` to skip the question.

## By hand

This is the exact command the CLI runs. Get a key from your dashboard under **Settings → API keys & AI agents** (that's also the way on [DataBull Hosted](https://databull.app/hosted)):

```
claude mcp add --transport http --scope user databull https://YOUR-DATABULL-URL/mcp \
  --header "Authorization: Bearer dbk_YOUR_KEY"
```

Then open Claude Code and run `/mcp`: **databull** should show as connected.

## Which scope to pick

| Scope | Where it applies | Use it when |
| --- | --- | --- |
| `user` | Every project on your computer, private to you | You want your numbers everywhere. The CLI uses this. |
| `local` (Claude Code's default) | Only the project you ran it in, private to you | You only want analytics in your product's repo. |
| `project` | Saved in `.mcp.json` in the repo, shared with your team | Rarely: the file would hold your key, so keep it out of git. |

## 10 prompts that work

1. "List my sites with today's visitors and revenue."
2. "Which referrer made me the most money this month?"
3. "Compare this week with last week. What changed, and why?"
4. "Show my last 10 sales and where each buyer came from."
5. "Walk me through the journey of my latest customer."
6. "Which landing page converts best for visitors from Google?"
7. "How much did ChatGPT and Perplexity send this month, and did any of it buy?"
8. "Which campaign brought customers who renewed?"
9. "When do my buyers pay? Suggest a time to post tomorrow."
10. "Which pages do buyers read longer than everyone else?"

Name the site by its domain when you have more than one, and add a period ("last 30 days", "since October 1") when it matters. Every tool understands today, 7d, 30d, month to date, last month, 12 months and custom dates.

## Use it while you build

Claude Code already sits in your product's repo, so analytics questions fit into the work: check which pages convert before rewriting the pricing page, or ask after a launch which post sent the buyers. Prefer plain commands? The same numbers are in the terminal: `npx databull@latest sources --by revenue`, with `--json` for scripts.

## If it doesn't connect

- **401 "Missing API key" or "Unknown API key"**: the header is missing or the key belongs to another DataBull. Check that the value is `Bearer dbk_…`, with the space.
- **401 "This API key was revoked"**: create a new key under Settings → API keys, or run `npx databull@latest mcp` again.
- **Can't reach the server**: the URL must be your DataBull address plus `/mcp`, over https.
- **"already exists"**: remove the old entry with `claude mcp remove databull --scope user`, then add it again. The CLI does this for you.

Keys are read-only, stored only as a hash, and hide customer names and emails unless you create one that includes them.

## FAQ

### Do I need a paid Claude plan?

You need Claude Code, which runs on the Claude plans and API accounts that include it. DataBull adds nothing on top: the MCP server is part of your own DataBull.

### Can Claude Code change anything in DataBull?

No. All 14 tools are read-only, and the key can only read analytics.

### Where is the key stored?

In Claude Code's own config on your computer (`~/.claude.json` for the user and local scopes). DataBull keeps only a hash of it.

### How do I remove it?

Run `claude mcp remove databull --scope user`, then revoke the key under Settings → API keys or with `npx databull@latest api-key revoke dbk_…`.
