Yandex Metrika MCP — Claude Code MCP server: analytics and reports
An MCP server that hands your coding agent the Yandex Metrika API: traffic, sources, geography, search phrases and custom reports. Useful when you want site stats without leaving the chat.
claude mcp add yandex-metrika-mcp -e YANDEX_METRIKA_TOKEN=<YANDEX_METRIKA_TOKEN> -- npx -y @stufently/yandex-metrika-mcpWhat Yandex Metrika MCP does
Twelve tools ship with the server. Five cover counter management: listing sites, counter details, goals, creating a counter and deleting one. Six handle reporting — visits summary, traffic sources, geography, devices, popular pages and search phrases. The twelfth, get-report, takes arbitrary Metrika metrics and dimensions.
You need an OAuth token in YANDEX_METRIKA_TOKEN. Reading works with metrika:read, while create-counter and delete-counter return 403 without metrika:write — and that rejection shows up when you call the tool, not during setup. To get a token interactively, run node packages/yandex-metrika-mcp/src/index.mjs auth; it opens a browser and prints the token. Read-only access is possible by setting YANDEX_METRIKA_SCOPE="metrika:read".
Deleting a counter cannot be undone, so delete-counter insists on confirm: true. Leave it out and the tool returns an error without touching the API. Only the literal true passes — "true", 1 and "yes" are turned down. Install the scoped package @stufently/yandex-metrika-mcp: the unscoped name belongs to a different publisher. Reporting defaults to the last 30 days.
What it helps with
- ask the agent how many visits a site got this month
- break down traffic sources and spot channels that dropped
- check which cities visitors come from
- pull top search phrases without opening the web dashboard
- build a custom report from Metrika metrics and dimensions
Example prompts for the agent
- Show me the traffic summary for counter 12345 over the last 30 days
- Which sources brought the most visits last week?
- Run
get-reportfor counter 12345 with metricym:s:visitsand dimensionym:s:trafficSource
How to install Yandex Metrika MCP
Platform CLI
claude mcp add yandex-metrika-mcp -e YANDEX_METRIKA_TOKEN=<YANDEX_METRIKA_TOKEN> -- npx -y @stufently/yandex-metrika-mcpReplace <…> with your own values
Platform CLI
codex mcp add yandex-metrika-mcp --env YANDEX_METRIKA_TOKEN=<YANDEX_METRIKA_TOKEN> -- npx -y @stufently/yandex-metrika-mcpReplace <…> with your own values
Config file
{
"mcpServers": {
"yandex-metrika-mcp": {
"command": "npx",
"args": [
"-y",
"@stufently/yandex-metrika-mcp"
],
"env": {
"YANDEX_METRIKA_TOKEN": "<YANDEX_METRIKA_TOKEN>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"yandex-metrika-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@stufently/yandex-metrika-mcp"
],
"env": {
"YANDEX_METRIKA_TOKEN": "<YANDEX_METRIKA_TOKEN>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e YANDEX_METRIKA_TOKEN=<YANDEX_METRIKA_TOKEN> yandex-metrika-mcp npx -y @stufently/yandex-metrika-mcpReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Yandex Metrika MCP
How do I install Yandex Metrika MCP in Claude Code?
Run claude mcp add yandex-metrika-mcp -e YANDEX_METRIKA_TOKEN=<YANDEX_METRIKA_TOKEN> -- npx -y @stufently/yandex-metrika-mcp with your own token.
What does Yandex Metrika MCP do?
It exposes 12 tools over the Yandex Metrika API: counters and goals, counter creation and deletion, reports on traffic, sources, geography, devices, popular pages and search phrases, plus custom reports through get-report.
Why does delete-counter refuse to run?
It needs an explicit confirm: true argument and the metrika:write scope. Without confirmation the tool returns an error and sends nothing to the API, since deleting a counter is irreversible.