yandex-direct-mcp
# yandex-direct-mcp
Read-only MCP server for Yandex Direct. AI assistants and coding agents can read campaigns, conversion goals, ad creatives, and performance reports without changing live ad settings.
[Русская версия (README.ru.md)](README.ru.md)
## Available tools
| Tool | Description |
|---|---|
| `get_campaigns` | List campaigns with ID, name, status, state, and type (optional `campaign_ids` filter). |
| `get_goals` | List conversion goals for the account via the v4 Live API (`GetRetargetingGoals`). |
| `get_ads` | Load ad creatives (titles, texts, destination URLs, statuses) and resolve `AdImageHash` to image URLs. |
| `get_campaign_report` | Load daily campaign statistics (`Impressions`, `Clicks`, `Cost`, `Conversions`) with `goal_ids` support. |
| `get_ad_report` | Load daily ad statistics (`AD_PERFORMANCE_REPORT`). |
| `get_search_queries_report` | Load weekly search query statistics (`SEARCH_QUERY_PERFORMANCE_REPORT`) for search term and negative keyword analysis. |
| `get_placements_report` | Load daily ad network placement statistics filtered by `minimum_clicks`. |
Report tools wait for async `201`/`202` responses using the `retryIn` header and return parsed JSON rows.
## Getting credentials
1. Register an app in [Yandex OAuth](https://oauth.yandex.com/) with the `direct:api` permission and set the Redirect URI to `https://oauth.yandex.com/verification_code`.
2. Enable API access in your Yandex Direct account settings (see [Yandex Direct API token docs](https://yandex.com/dev/direct/doc/start/token.html)).
3. Open this URL in your browser (replace `<CLIENT_ID>` with your app ID), approve access, and copy `access_token` from the redirect URL:
```text
https://oauth.yandex.com/authorize?response_type=token&client_id=<CLIENT_ID>
```
4. Set `YANDEX_DIRECT_TOKEN` to that token and `YANDEX_CLIENT_LOGIN` to the Yandex Direct account login (without `@yandex.ru`).
## Environment variables
- `YANDEX_DIRECT_TOKEN` (required): Yandex Direct OAuth token.
- `YANDEX_CLIENT_LOGIN` (required): Yandex Direct client login.
- `YANDEX_DIRECT_API_URL` (optional): base URL for API v5, defaults to `https://api.direct.yandex.com`. Set this when pointing to a local mock server (for example `http://localhost:8091`).
- `YANDEX_DIRECT_GOALS_URL` (optional): URL for API v4 Live goals, defaults to `https://api.direct.yandex.ru/live/v4/json/`.
## Installation in coding agents
Requires [uv](https://docs.astral.sh/uv/getting-started/installation/) (`uvx`).
Run it directly from GitHub with `uvx`, or from a local clone using `--directory /path/to/yandex-direct-mcp`.
### Standard JSON config (Cursor, Claude Desktop, Windsurf, Antigravity, VS Code, Gemini CLI)
Add this block to your agent's `mcpServers` JSON config:
```json
{
"mcpServers": {
"yandex-direct": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/s3rezhkaa/yandex-direct-mcp",
"yandex-direct-mcp"
],
"env": {
"YANDEX_DIRECT_TOKEN": "your-oauth-token",
"YANDEX_CLIENT_LOGIN": "your-client-login"
}
}
}
}
```
For a local clone, use `"command": "uv"` and `"args": ["run", "--directory", "/path/to/yandex-direct-mcp", "yandex-direct-mcp"]`.
### Claude Code CLI
```bash
claude mcp add yandex-direct \
-e YANDEX_DIRECT_TOKEN=your-oauth-token \
-e YANDEX_CLIENT_LOGIN=your-client-login \
-- uvx --from git+https://github.com/s3rezhkaa/yandex-direct-mcp yandex-direct-mcp
```
### Codex CLI (`~/.codex/config.toml`)
```toml
[mcp_servers.yandex_direct]
command = "uvx"
args = ["--from", "git+https://github.com/s3rezhkaa/yandex-direct-mcp", "yandex-direct-mcp"]
[mcp_servers.yandex_direct.env]
YANDEX_DIRECT_TOKEN = "your-oauth-token"
YANDEX_CLIENT_LOGIN = "your-client-login"
```
## Optional audit skill
A short audit skill is included in [skills/yandex-direct-audit/SKILL.md](skills/yandex-direct-audit/SKILL.md).
Copy or symlink `skills/yandex-direct-audit` into your agent's skills directory (for example `~/.claude/skills/`, `~/.codex/skills/`, or `.agents/skills/` in a workspace) to run a step-by-step account audit.
## Local development
```bash
uv sync
uv run ruff check .
uv run pytest -v
```
TDQS
Scored across 7 tools
Each tool targets a distinct resource or report type (goals, campaigns, ads, search queries, placements, campaign stats, ad stats). The only friction is at-a-glance confusion between metadata getters (get_campaigns, get_ads) and their stat counterparts (get_campaign_report, get_ad_report), but the descriptions clearly separate them.
Every tool follows a clean get_<resource> snake_case pattern, with the report tools consistently suffixed with _report. No mixed conventions or vague verbs.
Seven tools is well within the ideal range and each one covers a distinct reporting axis. Nothing feels redundant or padded for the analytics purpose.
The reporting surface is decent (campaign, ad, placement, search query, goals), but it is entirely read-only: no ad group or keyword tools, and no way to create campaigns/ads, manage bids, or apply negative keywords even though the search-query report suggests that workflow. Agents can analyze but cannot act.