Short answer
Run claude mcp add --transport http --scope user ownlytics https://ownlytics.xyz/api/mcp --header "Authorization: Bearer dbk_YOUR_KEY": it creates a read-only ownlytics key and adds ownlytics to Claude Code for all your projects. By hand, it's claude mcp add --transport http --scope user ownlytics https://YOUR-OWNLYTICS-URL/mcp --header "Authorization: Bearer dbk_…". Then run /mcp in Claude Code to check it's connected, and ask.
The one-command setup
claude mcp add --transport http --scope user ownlytics https://ownlytics.xyz/api/mcp --header "Authorization: Bearer dbk_YOUR_KEY"
Here's what it does, in order:
- Updates your ownlytics if it's too old for agents.
- Creates a read-only key named after your computer (or reuses the one it made before, if it still works).
- Checks the connection by listing the tools.
- If
Claude Code is installed, asks before adding ownlytics for all your projects, replacing an older
ownlyticsentry if there is one. - 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 API runs. Get a key from your dashboard under Settings → API keys & AI agents (that's also the way on ownlytics Hosted):
claude mcp add --transport http --scope user ownlytics https://YOUR-OWNLYTICS-URL/mcp \
--header "Authorization: Bearer dbk_YOUR_KEY"
Then open Claude Code and run
/mcp: ownlytics 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 API uses this. |
local ( | 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
- "List my sites with today's visitors and revenue."
- "Which referrer made me the most money this month?"
- "Compare this week with last week. What changed, and why?"
- "Show my last 10 sales and where each buyer came from."
- "Walk me through the journey of my latest customer."
- "Which landing page converts best for visitors from Google?"
- "How much did
ChatGPT and
Perplexity send this month, and did any of it buy?"
- "Which campaign brought customers who renewed?"
- "When do my buyers pay? Suggest a time to post tomorrow."
- "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 ownlytics@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 ownlytics. 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
claude mcp add --transport http --scope user ownlytics https://ownlytics.xyz/api/mcp --header "Authorization: Bearer dbk_YOUR_KEY"again. - Can't reach the server: the URL must be your ownlytics address plus
/mcp, over https. - "already exists": remove the old entry with
claude mcp remove ownlytics --scope user, then add it again. The API 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.