Skip to main content
Last updated: February 17, 2026

Supported agents

Claude Code

Anthropic’s CLI coding agent. Works in any terminal or IDE with MCP support.

Gemini CLI

Google’s command-line AI agent with built-in MCP support.

Codex

OpenAI’s coding agent for the terminal, with MCP integration.

Prerequisites

  • A Detrics account with at least one connected platform
  • One of the supported coding agents installed:

Setup

1

Generate an API Key

Go to the Detrics web app and generate an API key. Give it a descriptive name (e.g., “My laptop” or “Work desktop”).The key will only be shown once — copy it before closing the dialog.
Treat your API key like a password. Never share it publicly or commit it to version control. See API Keys for security best practices.
2

Install the MCP Server

Run the command for your coding agent in your terminal. Replace your-api-key with the key you just generated.
claude mcp add detrics -e DETRICS_API_KEY=your-api-key -- npx -y detrics
This registers the Detrics MCP server with your agent. No separate installation step is needed — npx -y detrics handles everything automatically.
3

Verify the Connection

Open your coding agent and try a test prompt:
What platforms do I have connected?
You should see a list of your connected data sources. If you do, you’re all set.

Example prompts

Once connected, try these prompts:
  • “What was my total ad spend across all platforms last month?”
  • “Compare my Google Ads and Meta Ads ROAS for the last 30 days”
  • “Show me my top 5 campaigns by conversions this week”
  • “What’s my Shopify revenue trend over the last 90 days?”
  • “What metrics are available for TikTok Ads?”
Browse Prompt Templates in the Detrics app for 40+ ready-to-use prompts.

Using AI Contexts

AI Contexts let you pre-select which platforms and accounts to query. Instead of specifying account IDs every time, you create a Context once and reference it by name.
Run my weekly performance report
See AI Contexts to learn how to set them up.

Updating your API key

If you need to replace your API key (e.g., after revoking an old one), remove the existing server and re-add it with your new key.
claude mcp remove detrics
claude mcp add detrics -e DETRICS_API_KEY=your-new-key -- npx -y detrics

Troubleshooting

The server is already registered. Remove it first, then re-add it.
claude mcp remove detrics
claude mcp add detrics -e DETRICS_API_KEY=your-api-key -- npx -y detrics
The API key wasn’t passed correctly. Remove the server and re-add it, making sure the -e DETRICS_API_KEY=... flag is included with your full key.
The API key was provided but is not valid. Check at app.detrics.io/mcp/api-keys that the key is still active, then update your agent if needed.
Your agent can reach Detrics, but there are no platforms connected in your workspace. Go to app.detrics.io and connect at least one data source.
For more issues, see Troubleshooting.