MCP server
The MCP server lets your coding agent answer questions about your analytics. It uses the same Query API as the dashboard, so your agent gets the same numbers you see. This page shows how to connect a client, how it authenticates, and which tools it can use.
Endpoint
- The server is at
https://app.nanolytics.dev/mcpand uses Streamable HTTP. - It's stateless: each request is handled on its own.
- Every response includes a
query_idand anas_of. Your agent should cite them alongside the numbers it gives you.
Authentication
A client can connect in one of two ways.
The OAuth server's metadata is at https://app.nanolytics.dev/.well-known/oauth-protected-resource/mcp. Clients that support MCP's OAuth find it automatically.
You can get a secret key from the connect flow, from Settings → API keys, or with the create_key tool. Keep it out of your repository: it can read and write the site's data until you revoke it.
Claude Code
To connect with OAuth:
claude mcp add --transport http nanolytics https://app.nanolytics.dev/mcpTo connect with a site's secret key, read it from .env.local so the key never appears in the command:
claude mcp add --transport http --scope local nanolytics https://app.nanolytics.dev/mcp --header "Authorization: Bearer $(grep '^NANOLYTICS_KEY=' .env.local | cut -d= -f2-)"--scope local keeps the server configured for this project on your machine only, so it isn't committed to the repository. The tools are available from your next session.
Other clients
For clients that take an mcpServers entry and read the key from the environment, use this config and set NANOLYTICS_KEY to the site's secret key:
{
"mcpServers": {
"nanolytics": {
"type": "http",
"url": "https://app.nanolytics.dev/mcp",
"headers": { "Authorization": "Bearer ${NANOLYTICS_KEY}" }
}
}
}If your client supports MCP's OAuth, all it needs is the URL: https://app.nanolytics.dev/mcp.
Typical workflow
- Call
list_sitesto get the sites you can read, with each one's ID, domain and timezone. - Call
get_schemafor a site to see its first day of data, its dimensions, metrics and goals, and its event names with their property keys. Your agent should read this before writing a query. - Ask with
query. For ordered steps usefunnel, for where people went from a step usepaths, for one error group useerror, and for recorded sessions usereplaysandreplay.
To install on a new site, call create_site, add its snippet to your pages, then check it with install_status. To track more (page speed, errors, session replay, outbound links), use update_site. After the first line of code, neither needs any further code change.
Tools
Example questions
Goals apply to all the data you've already collected. Settings you change with update_site reach visitors within five minutes.
Same numbers as the dashboard
The dashboard and the Query API use the same engine, so a number from MCP matches the dashboard for the same range and filters.