
Yandex Metrika
io.github.dontsovcmcPublished by GitHub account dontsovcmcv0.2.4Updated Oct 24, 2026
MCP server for Yandex Metrika API — counters, goals, reports, segments, logs
Overview
Local MCP server for the Yandex Metrika API that lets an assistant read analytics reports and manage counters, goals, segments, filters and log requests.
- What you can do
- Read reports: tabular, by-time, drill-down and segment/period comparison statistics for counters and metrics, plus chart annotations and access filters, operations, labels, accounts and delegates, and Logs API requests including evaluation, cancellation and TSV download, and offline conversions, calls, expenses and user parameters uploads, and create, update or delete counters, goals, filters, grants, segments, labels, operations, delegates and log requests.
- When to use it
- Useful when you work with Yandex Metrika and want an assistant to pull traffic and conversion statistics, inspect counters and goals, or set up and manage tracking objects and log exports without leaving the chat.
- Requirements
- Runs locally as a Python package (uvx or pip) on a desktop MCP client. Requires a Yandex Metrika OAuth token with metrika:read and metrika:write scopes, supplied in the YANDEX_METRIKA_TOKEN environment variable or an env file. Optional METRIKA_TIMEOUT and METRIKA_FILE_TIMEOUT variables. Network access to the Yandex Metrika API.
Installation
In SourceWeft
- Open Yandex Metrika in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
mcp-server-yandex-metrika
MCP-сервер, CLI-утилита и библиотека Pydantic-моделей для API Яндекс Метрики.
- MCP-сервер — интеграция с Claude Code, Claude Desktop и другими MCP-клиентами
- CLI-утилита — работа с API из терминала, скрипты и автоматизация
- Pydantic-модели — типизированные модели API для использования в своих Python-программах
Все данные остаются на вашем компьютере — токен никуда не передаётся.
Оглавление
- Возможности
- MCP-сервер
- CLI-утилита
- Pydantic-модели
- Переменные окружения
- Лимиты API
- Разработка
- Лицензия
Возможности
Отчёты (Reporting API)
Счётчики
Цели
Фильтры
Доступ (Grants)
Операции
Сегменты
Метки
Аккаунты и представители
Примечания на графике
Фильтры доступа
Logs API
Импорт данных
MCP-сервер
Установка
Шаг 1. Получить OAuth-токен Яндекс Метрики
- Зарегистрируйте приложение на oauth.yandex.com
- Укажите права:
metrika:read,metrika:write - Получите токен:
https://oauth.yandex.com/authorize?response_type=token&client_id=<ваш_client_id>
Шаг 2. Подключить MCP-сервер
Подключение к Claude Code
Способ 1: через uvx (не требует установки пакета)
Требуется uv — если не установлен:
Способ 2: через pip
Для удаления:
Подключение к Claude Desktop
Добавьте в конфигурационный файл:
Через uvx:
Через pip (после pip install mcp-server-yandex-metrika):
Подключение через --mcp-config
Подключает сервер только на время одной сессии Claude, не сохраняя в настройки. Токен хранится в отдельном .env.mcp файле, а не в конфиге Claude.
Из JSON-строки:
Из файла:
Пример ~/mcp-servers.json:
Пример ~/.env.mcp:
Шаг 3. Проверить
Попросите Claude: «Покажи список моих счётчиков Яндекс Метрики» — он вызовет ym_counters.
Примеры (MCP)
- «Покажи статистику по визитам за последнюю неделю для счётчика 12345678» →
ym_stat_data - «Создай цель "Покупка" типа url с условием contain "/thank-you"» →
ym_goal_create - «Выгрузи логи визитов за январь 2024» →
ym_log_request_create
CLI-утилита
Установка (CLI)
Переменная окружения YANDEX_METRIKA_TOKEN должна быть установлена:
Или через файл:
Формат файла — KEY=VALUE, по одной переменной на строку, #-комментарии.
Использование (CLI)
Без аргументов запускается MCP-сервер, с командой — CLI. Все команды выводят JSON.
Примеры команд
Pydantic-модели
Пакет содержит типизированные Pydantic-модели всех объектов API. Модели можно использовать в своих Python-программах для валидации данных и автодополнения в IDE.
Установка (библиотеки)
Использование в своих программах
Все модели используют extra="allow" для forward compatibility — неизвестные поля API не вызывают ошибок.
Полный список моделей: models.py
Переменные окружения
Загрузка из файла
Вместо передачи переменных через -e можно указать файл:
Формат файла — KEY=VALUE, по одной переменной на строку, #-комментарии.
Работает в обоих режимах: MCP-сервер и CLI:
Лимиты API
- 30 запросов/секунду на IP
- 5000 запросов/день на пользователя
- 3 параллельных запроса на пользователя
- 200 запросов/5 минут для
/stat/v1/data/ - HTTP 420 при превышении лимитов
Разработка
Лицензия
MIT
Source: README.md at commit cd20e21
Tools
0Version history
1- v0.2.4LatestSep 16, 2026
Score
40% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts
Declare a license in the repository or the registry entry.