yandex-metrica-mcp

yandex-metrica-mcp

MCP server for Yandex Metrica — query your web analytics in plain language from Claude, Cursor, and other AI agents. Secretless one-command login (PKCE), read-only, TypeScript.

Category
Visit Server

README

yandex-metrica-mcp

CI npm License: MIT

Ask your Yandex Metrica analytics in plain language — from Claude, Cursor, or any MCP client.

A Model Context Protocol (MCP) server for Yandex Metrica. It lets an AI agent query your web-analytics data — traffic, sources, landing pages, conversions, geography, devices and trends — through a small set of flexible, read-only tools.

Read-only by design, no secrets stored in the package: interactive login uses a built-in public OAuth client with PKCE, and the server talks only to Yandex.

Status: early development (v0.1, work in progress). General-purpose: SEO is one of many use cases, not the focus.

Demo

Point an AI agent at your counter and ask about your traffic — the server queries Yandex Metrica and hands back real, read-only data, no dashboards. Here the run_report tool answers a “traffic sources, last 7 days” question against a live counter:

yandex-metrica-mcp querying live Yandex Metrica traffic sources, read-only

Quickstart

1. Add the server to your MCP client (e.g. Claude Desktop) — no token required up front; you log in interactively in step 2:

{
    "mcpServers": {
        "yandex-metrica": {
            "command": "npx",
            "args": ["-y", "yandex-metrica-mcp"],
            "env": { "YANDEX_METRIKA_COUNTER_ID": "12345678" }
        }
    }
}

2. Log in once — one command, no app registration, no secret stored:

npx yandex-metrica-mcp auth

Approve the Yandex consent page and paste the code back. The login uses authorization-code + PKCE, so no client secret ever touches your machine; the token is cached (mode 0600) and valid for ~1 year.

3. Ask your agent about traffic, sources, conversions, geography, devices, or trends — see Examples for prompts.

Prefer a static token (CI / non-interactive) or your own OAuth app? See Authentication.

Or install as a Claude Code plugin

The repo doubles as a plugin marketplace, so you can install the server through Claude Code's plugin system instead of the config above:

/plugin marketplace add BoxLab-Ltd/yandex-metrica-mcp
/plugin install yandex-metrica-mcp@boxlab

Then run npx yandex-metrica-mcp auth once to log in.

Why

There is no official Yandex Metrica MCP server, and existing community ones are mostly thin, unmaintained, or dump raw data straight into the model's context. This server aims to be the well-engineered, well-maintained, open option: flexible report tools, strict token/context discipline, read-only by default.

Features (v0.1)

  • run_report — flexible wrapper over the Reporting API (/stat/v1/data).
  • run_comparison — compare two periods with absolute and percentage deltas.
  • run_drilldown — drill down through a dimension tree.
  • run_timeseries — metrics split into a time series (/bytime) for trends.
  • get_metadata — discover available counters, goals, and common dimensions/metrics so the model queries with real field names.
  • Built-in context control: field selection on by default, low default row limits, and sampling/quota surfaced back to the model.

Planned for later: Logs API (raw row-level export → local SQL), Streamable HTTP transport, write tools (behind an explicit flag).

Requirements

  • Node.js >= 18
  • Yandex Metrica credentials with the metrika:read scope (see Authentication). Whoever the credentials belong to must have access to the counters you query.

Authentication

Recommended: interactive login. No app registration needed — the server ships a built-in public OAuth client. Run once:

yandex-metrica-mcp auth     # or, in dev: bun run auth

It opens a Yandex consent page; after you approve, Yandex shows a code that you paste back into the terminal. The token is cached at ~/.config/yandex-metrica-mcp/token.json (mode 0600) and is valid for ~1 year; re-run auth when it expires. The login uses authorization-code + PKCE, so no client secret is stored anywhere. A cached login takes precedence over YANDEX_METRIKA_TOKEN.

Alternative: static token. Get a token for an app with the metrika:read scope at https://oauth.yandex.ru and pass it as YANDEX_METRIKA_TOKEN — handy for CI or non-interactive use.

Own OAuth app (optional). To use your own app instead of the built-in one, set YANDEX_OAUTH_CLIENT_ID; add YANDEX_OAUTH_CLIENT_SECRET to also enable automatic token refresh.

Configuration

The Quickstart covers the happy path. For all options — static token, your own OAuth app, default counter, request tuning, language — see .env.example. The published package runs on Node (so npx/MCP clients work out of the box); local development uses Bun.

Examples

Once connected, an agent can answer questions like:

  • “How many visits and users did counter 12345678 get last week, split by traffic source?” → run_report with metrics: ["ym:s:visits","ym:s:users"], dimensions: ["ym:s:lastsignTrafficSource"].
  • “Compare this week's organic conversions to last week's.” → run_comparison (server returns A, B, and the deltas).
  • “Which operating systems do my visitors use? Let me drill into Windows versions.” → run_drilldown, then again with parentId.
  • “What counters and goals can I query?” → get_metadata.

Development

This project is Bun-first:

bun install
bun run dev        # run from source with hot reload
bun run typecheck  # tsc --noEmit
bun run lint       # eslint
bun test           # bun's test runner
bun run build      # emit dist/ with tsc (Node-compatible)

License

MIT © boxlab

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured