For the complete documentation index, see llms.txt. This page is also available as Markdown.

MCP server

The MCP server — AI agents emit and query analytics natively.

Millimetric ships a first-class Model Context Protocol server at /mcp. Any MCP client (Claude Code, Claude Desktop, MCP Inspector, custom agents) can connect and use the same five operations a developer would.

Endpoints

Millimetric exposes two MCP servers. Pick the one that matches the credential you have:

Endpoint
Auth
Scope
Plan

POST /mcp

sk_live_… or rk_live_…

One project per key.

Pro+

POST /mcp/account

ak_live_…

Every project the account owns. Includes list_projects and compare_projects.

Business

POST https://api.millimetric.ai/mcp
Authorization: Bearer {key}

The transport is JSON-RPC 2.0 over HTTP (the latest MCP HTTP transport — no SSE needed for stateless calls).

For multi-project setups (agencies, multi-product teams), jump to Account MCP below.

Auth

/mcp accepts only server-side keys: rk_live_… (read-only) and sk_live_… (read + ingest).

pk_live_… keys are rejected at /mcp with 403 key_kind_not_allowed. pk_ keys are designed to ship in browser JS for the tracking SDK, which means anyone with view-source on a customer's site can read them — they must never grant access to query a project's events. Generate rk_ / sk_ keys from the dashboard and paste them into your agent's config server-side.

You give the agent
It can call

rk_live_…

query_events, get_stats, top_sources, funnel, all resources

sk_live_…

the read tools above and track_event

pk_live_…

rejectedpk_ is browser-only

Use rk_* by default. Only hand the agent an sk_* key if it needs to emit events on its own behalf.

Tools

track_event — emit an event (requires ingest)

query_events — raw events (requires read)

get_stats — aggregations (requires read)

top_sources — the FB social-vs-paid split (requires read)

Resources

  • events://recent — last 100 events for the authenticated project.

  • schema://events — distinct event names observed in the last 30 days. Useful for agents that want to discover what they can query before guessing.

Connecting from Claude Code

Add this to your MCP config (~/.claude/config.json or via the UI):

After restart, ask Claude:

"Use millimetric.top_sources to show me the Facebook social-vs-paid split for the last 7 days."

Connecting from MCP Inspector

You'll see the tools and resources listed and can call them interactively.

Why MCP?

For AI-native products, telemetry is two-way: the agent does work and the agent answers questions about the work. Both sides talk to the same analytics surface, on the same protocol, with no SDK to bundle.

For non-AI products, MCP is still useful — it's a clean way to give a read-only consumer access to the data without exposing the database, and the same JSON-RPC handler can be wrapped in any UI you care to build.

Response shape

Tool results return as MCP content[]:

The text is JSON-stringified — agents parse it back to data. (MCP doesn't yet have a first-class structured-result type for tools.)

Errors

Standard JSON-RPC error envelope:

Code
Meaning

-32600

invalid_request — body not a valid JSON-RPC envelope.

-32601

method_not_found — unknown method.

-32602

unknown_tool / unknown_resource / unhandled_tool.

-32000

tool_failed (server error) / insufficient_scope.

-32002

plan_limit — feature requires a higher tier (e.g. account-MCP on Pro).

-32004

unknown_project_id / unknown_project_slug — account-MCP only.

-32005

no_projects_visible — account-MCP only.

Account MCP

/mcp/account is the multi-project endpoint. One ak_live_… key authenticates an agent against every project in the account — built for agencies and teams running multiple products on one Millimetric workspace.

It speaks the same JSON-RPC dialect as /mcp, so any MCP client can talk to both with the same code path. The only differences are:

  • Auth: ak_ keys only. pk_/sk_/rk_ are rejected with 403 account_key_required.

  • Plan: Business tier (account_mcp_access). Pro accounts get 402 with error: "plan_limit".

  • Tools: every read tool gains optional project_id / project_slug / project_ids arguments. Omit them and the query spans every project the key can see.

Tools

list_projects

Returns every project the key can read.

query_events (multi-project)

Omit project_slug / project_id / project_ids to scan every project. Rows include a project_id column when the query spans more than one so the agent can attribute them.

get_stats (group by project)

top_sources

Same shape as /mcp, plus the optional project-selection args.

compare_projects

Ranks every project the key can see by a single metric — perfect for "which app had the most traffic this week?".

Returns one row per project, decorated with slug and name.

Resources

  • projects://all — every project the key can read.

  • schema://events — distinct event names from the last 30 days across every accessible project.

Connecting from Claude Code

Then:

"Use millimetric-account.compare_projects to rank my apps by unique visitors over the last 7 days."

Last updated

Was this helpful?