Yandex Metrika MCP with device flow and Logs API
yandex-metrika-mcp
A Yandex Metrika MCP server for Claude Desktop with a browserless OAuth device flow and the full Logs API cycle
Medium risk
We rate an entry medium when the tool runs code, makes network calls or reads project files. Check what exactly it does before installing.
Why this level
- Reads detailed stats and raw visits through the Logs API
- The OAuth app requests metrika:write and metrika:expenses scopes beyond reading
- Tokens are stored in an unencrypted token.json file on disk
Install
Manual install
git clone https://github.com/perfilev/yandex-metrika-mcp.git
cd yandex-metrika-mcp
npm install
npm run buildBuild the server before logging in and connecting.
This is third-party code. Review the repository files before installing.
What it does
The server gives the model access to Metrika's Reporting, Management, Logs API and real-time reports. The generic get_report tool takes any dimensions, metrics, filters and sort, while presets cover common scenarios: traffic and UTM, audience by geography and device, content, and conversions with funnels. It lists counters, goals and segments, offers real-time bytime and drilldown reports, and the full Logs API cycle from evaluating a request through downloading and clearing the log. Auth runs via npm run login: the script opens a Yandex OAuth device flow with no redirect URI and saves tokens to token.json, refreshing them automatically.
Who it is for. For marketers and analysts who need both a flexible custom report and raw Logs API data in one server.
Good fit when
- You need a custom report with any combination of dimensions and metrics via get_report
- You need raw visits from the Logs API with specific fields like ClientID or goals
- You do not want to configure an OAuth redirect URI: auth runs through a terminal device flow
Not a fit when
- A few ready-made reports without fine-tuning are enough: a server with named tools is simpler
- You have no Node.js environment to build the server before first run
Example request
Build a funnel for goal id=123 in April and show the top 20 landing pages with the worst bounce rateLimitations
Requires a Yandex ID OAuth app with metrika:read, metrika:write, metrika:user_params, metrika:expenses scopes. Tokens are stored in a local token.json file next to the server. No license file.
How to disable. Remove the yandex-metrika block from claude_desktop_config.json and delete the token.json file with saved tokens.
MCP
- Transport
- stdio
- Authentication
- OAuth
| Environment variables | |
|---|---|
| YANDEX_CLIENT_ID required | Client ID of the Yandex ID OAuth app |
| YANDEX_CLIENT_SECRET required, secret | Client secret of the OAuth app |
| TOKEN_PATH required | Path to the token.json file with saved tokens |
Security check
- Reads detailed stats and raw visits through the Logs API
- The OAuth app requests metrika:write and metrika:expenses scopes beyond reading
- Tokens are stored in an unencrypted token.json file on disk
README in short
The README describes capabilities by block: the generic get_report, presets, counters, real-time, Logs API, gives install via clone and build, steps to create an OAuth app and get a token via npm run login, the Claude Desktop config, and Russian-language example prompts.
FAQ
Do I need to configure an OAuth redirect URI?
No, npm run login uses a device flow: it requests a device code from Yandex, shows a confirmation code and saves the tokens itself.
What happens when the token expires?
The server automatically refreshes the access token using the saved refresh token, with no need to log in again.
Related
Official DataLens (Yandex) skills for Claude Code, Codex and OpenCode: SDK, HTML reports and RLS resolution
A Yandex Metrika MCP server generated from the API spec: 108 methods, 10 tools declared by default, transparent filters and response metadata
An open MCP server and agent skill set for SEO: keyword research, competitors, backlinks and site audits powered by DataForSEO
A Claude Code plugin for SEO audits: technical SEO, E-E-A-T, schema, local and AI search via parallel subagents