Skip to main content
Glama
yandex-direct-mcp

yandex-direct-mcp

by gmen1057

yandex-direct-mcp

Open-source MCP-сервер для Яндекс Директ — ~80 инструментов, чтобы ИИ (Claude, Cursor, Claude Code, Grok, Windsurf…) мог смотреть и (по явному разрешению) менять рекламный кабинет: поиск, РСЯ, ключи, минуса, бюджеты, автотаргетинг, поисковые запросы, max-conv, видео-расширения.

Сделано в проде Arckep (AI-студия).
Статья с установкой: https://arckep.ru/blog/how-to/yandex-direct-mcp-open-source

🤖 Агенту: прочитай AGENTS.md и разверни MCP сам.


Зачем

Кабинет Директа — ручной и медленный. MCP даёт агенту безопасный контур:

  • Read — кампании, группы, ключи, объявления, минуса, exclude-площадки, device/demo, стратегия, funds

  • Stats — cost/clicks/CTR, breakdown по Placement/Device/…, поисковые запросы (SQ)

  • Write (только allow_write=true) — бюджет, suspend/resume, минуса, exclude, гео, ставки, AT, max-conv, тексты объявлений, launch pack

  • Escape — direct_rpc на любой service.method API v5/v501

Один OAuth-токен = весь кабинет. Несколько брендов размечаются в projects.json, чтобы случайно не потрогать чужой продукт.


Related MCP server: yandex-marketing-mcp

Быстрый старт

git clone https://github.com/gmen1057/yandex-direct-mcp.git
cd yandex-direct-mcp
npm install
cp .env.example .env
# YANDEX_DIRECT_TOKEN=...
npm run smoke

Claude Desktop

claude_desktop_config.json:

{
  "mcpServers": {
    "yandex-direct": {
      "command": "node",
      "args": ["/полный/путь/yandex-direct-mcp/index.mjs"],
      "env": {
        "YANDEX_DIRECT_TOKEN": "ваш_токен"
      }
    }
  }
}

Остальные клиенты — в AGENTS.md и examples/.


Токен Директа

  1. Зарегистрируйте приложение: https://oauth.yandex.ru/

  2. Права: Яндекс Директ API

  3. Получите токен: документация

  4. Положите в .env как YANDEX_DIRECT_TOKEN=... (права 600)

  5. Для агентского доступа: YANDEX_DIRECT_CLIENT_LOGIN=login_клиента

API: https://api.direct.yandex.com/json/v501 + Reports v5.


projects.json

{
  "projects": {
    "shop": {
      "label": "Интернет-магазин",
      "name_prefixes": ["[shop]"],
      "campaign_ids": [123456789]
    }
  }
}
  • Write требует project=shop (или другой ваш ключ) — не all.

  • Префиксы в Name кампании ([shop] …) помогают авторазметке.


Безопасность write

Правило

Смысл

allow_write=true

без флага — только dry-run план

project=<ключ>

нельзя all на мутациях

dry_run

явно посмотреть payload

логи

logs/*.jsonl при write

Не включайте write «чтобы проверить». Сначала direct_ping / direct_list_campaigns / direct_report.


Что умеет (кратко)

Класс

Примеры tools

Read

direct_ping, list_campaigns, get_campaign, list_keywords, list_ads, get_negatives, list_bidmodifiers

Отчёты

direct_report, report_breakdown, report_search_queries, report_raw

Бюджет / state

set_daily_budget, set_search_weekly_budget, set_network_weekly_budget, suspend/resume/archive/unarchive

Качество

set_excluded_sites, set_negatives, set_group_negatives, set_region_excludes, device/demo bidmods

Ключи / AT

add/delete/set_keyword_*, get/set_autotargeting, get_keyword_bids

Стратегия

set_max_conv, set_strategy, set_priority_goals, get_strategy

Креатив

add_ads, update_ad_text, update_ad_href, upload_adimage, sitelinks/callouts, video

Launch

direct_launch_pack — кампания → группы → ключи → ads → moderate → pin

Escape

direct_rpc

Полный список — при старте MCP (~80 tools).


Gotchas (РФ / Директ)

  • Деньги API в микросах: 1 ₽ = 1 000 000; tools принимают рубли.

  • DailyBudget + WeeklySpendLimit в одном campaigns.update → ошибка 4004 — два шага.

  • Soft Conversions в отчётах ≠ оплаты в CRM.

  • ЕПК / UNIFIED: ≤3 ads в группе; ACCEPTED OFF часто пул, не бан.

  • В заголовках: не ₽, длинное тире —, слово VPN — модерация.

  • Ad Id — int64, не терять точность.

  • AT: AutotargetingCategories — plain array; ставки AT через keywordbids.set.


Требования

  • Node.js ≥ 18

  • Сеть до api.direct.yandex.com

  • Units API (дневной лимит кабинета)


Лицензия

MIT — см. LICENSE.

Не аффилирован с Яндексом. «Яндекс» и «Директ» — товарные знаки правообладателей.


Связанное

Available Tools

80 tools
direct_account_balanceB

READ: clients.get financial flags + sample campaign Funds/SharedAccountFunds (cabinet balance snapshot).

Inputs: no named parameters.

direct_account_summaryA

Short cabinet summary: counts by project/state + optional last-N-days cost. READ-ONLY.

Inputs: days.

direct_add_adgroupsA

WRITE: adgroups.add. groups=[{name, region_ids?}]. Default region_ids=[225]. allow_write=true + project scope.

Inputs: groups (required), campaign_id (required), dry_run, project, +1 more.

direct_add_adsA

WRITE: ads.add TextAd. ads=[{adgroup_id, title, title2?, text, href, display_url_path?, image_hash?, sitelink_set_id?, mobile?}]. Max 3 ads/group on UNIFIED. Title ≤56, Title2 ≤30, Text ≤81. No ₽·— VPN in copy. allow_write=true.

Inputs: ads (required), dry_run, project, moderate, +1 more.

direct_add_audience_targetsC

WRITE: audiencetargets.add — [{adgroup_id, retargeting_list_id, context_bid_rub?}]. allow_write=true.

Inputs: targets (required), dry_run, project, allow_write.

direct_add_calloutsC

WRITE: adextensions callouts (≤25 chars each). Attach via UI/EPK may be limited. allow_write=true.

Inputs: callouts (required), dry_run, allow_write.

direct_add_feedB

WRITE: feeds.add — name + url (HTTP feed) or file_path (upload). business_type RETAIL|… source URL|FILE. allow_write=true.

Inputs: name (required), url, dry_run, file_path, +3 more.

direct_add_keywordsA

WRITE: add keywords to ad group. keywords=[{keyword, bid_rub?}]. bid optional (micros). allow_write=true. Does not auto-enable AT.

Inputs: keywords (required), adgroup_id (required), dry_run, project, +1 more.

direct_ads_set_stateA

WRITE: ads suspend | resume | moderate. Pass ad_ids (int64 as number or string ok). project scope via parent campaigns. allow_write=true.

Inputs: action (required), ad_ids (required), dry_run, project, +1 more.

direct_archive_campaignsA

WRITE: archive campaigns (remove from active UI). Prefer suspend for reversible stop. allow_write=true.

Inputs: campaign_ids (required), dry_run, project, allow_write.

direct_attach_calloutsA

WRITE: ads.update TextAd CalloutSetting AdExtensionIds. Pass ad_ids + extension_ids (from add_callouts/list). allow_write=true. May re-moderate.

Inputs: ad_ids (required), extension_ids (required), dry_run, project, +2 more.

direct_attach_video_extensionC

WRITE: creatives.add VideoExtensionCreative(video_id) then ads.update TextAd.VideoExtension.CreativeId. Optional moderate. allow_write=true.

Inputs: ad_ids (required), video_id (required), dry_run, project, +3 more.

direct_audience_targets_stateB

WRITE: audiencetargets suspend|resume|delete by ids. allow_write=true.

Inputs: ids (required), action (required), dry_run, project, +1 more.

direct_check_changesA

READ: changes.checkCampaigns — which campaigns changed since Timestamp (ISO or API format).

Inputs: timestamp (required), project, campaign_ids.

direct_client_infoA

READ: clients.get — login, currency, VAT, shared account flags, restrictions snapshot.

Inputs: no named parameters.

direct_create_campaignA

WRITE: campaigns.add from zero. channel=search (HP, Network OFF) | rsya (Network max-clicks, Search OFF). Optional daily_rub, weekly_rub, bid_ceiling_rub, negatives, counter_id, utm TrackingParams, timezone. After add use add_adgroups/keywords/ads or direct_launch_pack. allow_write=true.

Inputs: name (required), channel (required), dry_run, project, +10 more.

direct_delete_bidmodifiersB

WRITE: bidmodifiers.delete by ids. allow_write=true.

Inputs: ids (required), dry_run, project, allow_write.

direct_delete_feedsB

WRITE: feeds.delete by ids. allow_write=true.

Inputs: ids (required), dry_run, allow_write.

direct_delete_keywordsA

WRITE: keywords.delete by ids. Irreversible. allow_write=true + project scope.

Inputs: keyword_ids (required), dry_run, project, allow_write.

direct_get_adA

READ: full ad detail (titles, text, href, image, state). ad_id may be int64 string.

Inputs: ad_id (required).

direct_get_autotargetingB

READ: ---autotargeting keyword rows + AutotargetingCategories + Bid. project/campaign_ids.

Inputs: project, campaign_ids.

direct_get_campaignA

Get one campaign by Yandex Id (detail + strategy + excluded sites + negatives sample). READ-ONLY.

Inputs: campaign_id (required).

direct_get_excluded_sitesB

List ExcludedSites for campaign(s). READ-ONLY.

Inputs: project, campaign_id, campaign_ids.

direct_get_group_negativesA

READ: ad group NegativeKeywords (separate from campaign-level).

Inputs: limit, project, adgroup_ids, campaign_ids.

direct_get_keyword_bidsA

READ: keywordbids.get — SearchBid/ContextBid/AuctionBids for keywords. Pass keyword_ids and/or campaign_ids/project.

Inputs: limit, project, keyword_ids, campaign_ids.

direct_get_negativesA

List campaign-level negative keywords. READ-ONLY. Group-level negatives are separate.

Inputs: project, campaign_id.

direct_get_strategyA

READ: full BiddingStrategy + PriorityGoals + counters for one campaign (Text/Unified).

Inputs: campaign_id (required).

direct_get_time_targetingC

READ: campaign TimeTargeting schedule.

Inputs: campaign_id (required).

direct_launch_packA

WRITE FULL LAUNCH from zero in one call: create campaign → excluded sites → adgroups → keywords (phrase+"[exact]") → optional images → ads → moderate → optional age0-17 ban → optional resume → pin projects.json. channel=search|rsya. groups: [{name, phrases[], ads:[{title,title2?,text,content}], image_path?}]. content used in utm_content. Max 3 ads/group. allow_write=true. Prefer dry_run first.

Inputs: name (required), groups (required), channel (required), project (required), +18 more.

direct_list_adextensionsB

READ: adextensions.get — callouts library (ids + text).

Inputs: ids, limit.

direct_list_adgroupsA

List ad groups for campaign_ids or project. Includes RegionIds. READ-ONLY.

Inputs: limit, project, campaign_ids.

direct_list_adsB

List ads for campaign_ids / adgroup_ids / project. READ-ONLY. UNIFIED: ACCEPTED OFF may be pool, not ban.

Inputs: limit, project, adgroup_ids, campaign_ids.

direct_list_advideosA

READ: advideos.get by ids (API requires Ids). Use after upload_advideo.

Inputs: ids (required).

direct_list_audience_targetsB

READ: audiencetargets.get for campaign/adgroup (retarget conditions on groups).

Inputs: limit, project, adgroup_ids, campaign_ids.

direct_list_bidmodifiersA

List campaign-level bid modifiers (mobile/tablet/desktop/demographics). READ-ONLY.

Inputs: campaign_id (required).

direct_list_campaign_fundsC

READ: campaign funds / shared account spend fields (where available on get).

Inputs: project, campaign_ids.

direct_list_campaignsA

List campaigns with project (from projects.json), state, daily/weekly budget ₽, negatives count, excluded sites count. READ-ONLY.

Inputs: project, include_archived.

direct_list_dictionariesA

READ: dictionaries.get — supply DictionaryNames e.g. SupplySidePlatforms, AudienceCriteriaTypes, Currencies, MetroStations, TimeZones, Interests.

Inputs: names (required).

direct_list_feedsA

READ: feeds.get — API requires ids. Pass feed ids from create/add or UI.

Inputs: ids (required).

direct_list_keywordsB

List keywords for campaign_ids / adgroup_ids / project. READ-ONLY.

Inputs: limit, states, project, adgroup_ids, +1 more.

direct_list_retargeting_listsC

READ: retargetinglists.get — Metrika audience lists in cabinet.

Inputs: ids, limit.

direct_pingA

READ: health check — token present, units remaining, campaign count by project.

Inputs: no named parameters.

direct_product_attributionB

OPTIONAL READ: your product DB via custom SQL (not soft Metrika Conversions). Enable PRODUCT_ATTRIBUTION_ENABLED=true and set PRODUCT_ATTRIBUTION_SQL or use built-in only if you customized it. Default: disabled with setup hints.

Inputs: days.

direct_project_mapA

Show campaign→project mapping rules (projects.json) + live non-archived list. READ-ONLY.

Inputs: include_archived.

direct_register_project_campaignA

WRITE local: pin campaign_id into projects.json under project key. No Direct API. allow_write=true (or dry_run).

Inputs: project (required), campaign_id (required), dry_run, allow_write.

direct_reportA

Campaign performance (cost, clicks, impressions, CTR, CPC) for date range. Conversions=soft Metrika. READ-ONLY. May poll ~1 min.

Inputs: date_to, project, date_from, campaign_ids, +1 more.

direct_report_breakdownB

READ: performance report with breakdown dimension (Placement|AdGroupId|Criterion|Device|AdId|Date|…). Soft Conversions. For RSYA junk use Placement. Polls offline report.

Inputs: breakdown (required), limit, date_to, project, +2 more.

direct_report_rawA

READ: raw Reports API — pass full report spec (SelectionCriteria, FieldNames, ReportType…). Advanced; prefer direct_report / direct_report_breakdown.

Inputs: spec (required).

direct_report_search_queriesA

READ: SEARCH_QUERY_PERFORMANCE_REPORT — real user queries (not just Criterion keys). Cost/clicks/CTR/CPC + soft Conversions. Offline report may poll ~1 min. Top by cost.

Inputs: limit, date_to, project, date_from, +2 more.

direct_resume_campaignsA

WRITE: resume suspended campaigns. Requires allow_write=true + project/campaign_ids. Do NOT auto-resume killed Chat/Skazki without owner intent.

Inputs: dry_run, project, allow_write, campaign_ids.

direct_rpcA

Escape hatch: call any Direct API service.method with params JSON. Prefer typed tools. Methods add/update/delete/suspend/resume/set/moderate require allow_write=true. service e.g. campaigns, keywords, ads, adgroups, bidmodifiers, keywordbids, clients, dictionaries.

Inputs: method (required), service (required), params, allow_write.

direct_search_geo_regionsA

Search Yandex Direct GeoRegions dictionary by name substring. READ-ONLY. Use Federation subject IDs for RegionIds excludes (negative).

Inputs: query (required), type, limit.

direct_set_autotargetingA

WRITE: keywords.update AutotargetingCategories for AT rows. categories=[{category,value YES|NO}] e.g. EXACT,ALTERNATIVE,COMPETITOR,BROADER,ACCESSORY. Prefer plain array (API gotcha). Optional bid_rub via keywordbids. allow_write=true.

Inputs: categories (required), keyword_ids (required), bid_rub, dry_run, +2 more.

direct_set_bidmodifiersB

WRITE: bidmodifiers.set — [{id, bid_modifier}] where bid_modifier 0–1300 (0=exclude). allow_write=true.

Inputs: items (required), dry_run, project, allow_write.

direct_set_daily_budgetA

WRITE: campaign DailyBudget ₽ (Amount micros). Mode STANDARD|DISTRIBUTED. Do NOT send in same update as WeeklySpendLimit (API 4004). allow_write=true.

Inputs: daily_rub (required), campaign_id (required), mode, dry_run, +2 more.

direct_set_demographics_bid_modifierA

WRITE: campaign demographics bid mod (age and/or gender). BidModifier 0=exclude. Age e.g. AGE_0_17, AGE_18_24, AGE_55. allow_write=true.

Inputs: campaign_id (required), bid_modifier (required), age, gender, +3 more.

direct_set_device_bid_modifiersA

WRITE: campaign device bid mods. ONE field per API call (Mobile/Tablet/Desktop). BidModifier 0=off, 100=default, 50=−50%, 130=+30%. allow_write=true. Desktop may 6000-conflict if Mobile=0.

Inputs: campaign_id (required), mobile, tablet, desktop, +3 more.

direct_set_excluded_sitesA

WRITE: set campaign ExcludedSites (RSYA junk packages/DSP). mode=merge (default) or replace. allow_write=true required. Never auto-exclude dsp.yandex.ru unless sites list includes it.

Inputs: sites (required), mode, dry_run, project, +2 more.

direct_set_group_negativesC

WRITE: adgroups.update NegativeKeywords. mode=merge|replace. allow_write=true + project.

Inputs: phrases (required), mode, dry_run, project, +3 more.

direct_set_keyword_bidsA

WRITE: set keyword search bids (₽) via keywordbids.set. keyword_ids required. allow_write=true.

Inputs: bids (required), dry_run, project, allow_write.

direct_set_keyword_statesA

WRITE: suspend or resume keywords by id. allow_write=true + project scope.

Inputs: action (required), keyword_ids (required), dry_run, project, +1 more.

direct_set_max_convB

WRITE: Search WB_MAXIMUM_CONVERSION_RATE + GoalId + WeeklySpendLimit ₽, Network SERVING_OFF (default). Unified/Text auto. allow_write=true. Prefer payment goals over form alone.

Inputs: goal_id (required), weekly_rub (required), campaign_id (required), dry_run, +3 more.

direct_set_negativesB

WRITE: campaign NegativeKeywords. mode=merge|replace. Phrases as Direct expects (morphology; avoid bare +). allow_write=true.

Inputs: phrases (required), mode, dry_run, project, +3 more.

direct_set_network_weekly_budgetA

WRITE: Network WB_MAXIMUM_CLICKS WeeklySpendLimit (+ optional BidCeiling) for RSYA-style campaigns. Search left as-is. ₽ → micros. allow_write=true. Does not touch DailyBudget in same call.

Inputs: weekly_rub (required), campaign_id (required), dry_run, project, +2 more.

direct_set_priority_goalsB

WRITE: PriorityGoals SET (no REMOVE in API). goals=[{goal_id, value_rub}]. Weights in ₽. allow_write=true. Prefer payment-heavy; avoid max-conv on form alone.

Inputs: goals (required), campaign_id (required), dry_run, project, +1 more.

direct_set_region_excludesA

WRITE: add negative RegionIds on all ad groups of campaigns (exclude subjects under Russia 225). Pass positive region ids (e.g. 11010 Дагестан) — tool stores negatives. Preserves existing positives (225 etc). allow_write=true.

Inputs: region_ids (required), dry_run, project, allow_write, +1 more.

direct_set_retargeting_bid_modifierA

WRITE: bidmodifiers.add RetargetingAdjustment on campaign (RetargetingConditionId + BidModifier 0–1300). allow_write=true. Used e.g. exclude visitors list.

Inputs: campaign_id (required), bid_modifier (required), retargeting_condition_id (required), dry_run, +2 more.

direct_set_search_weekly_budgetA

WRITE: Search HIGHEST_POSITION + WeeklySpendLimit ₽, Network SERVING_OFF (JTBD-style). Does not change DailyBudget. allow_write=true. Aborts if live strategy is unexpected unless force=true.

Inputs: weekly_rub (required), campaign_id (required), force, dry_run, +2 more.

direct_set_strategyB

WRITE: set Search strategy preset: highest_position | max_conv | max_clicks_network | serving_off_search. weekly_rub/goal_id/bid_ceiling as needed. allow_write=true.

Inputs: mode (required), campaign_id (required), dry_run, goal_id, +4 more.

direct_set_time_targetingA

WRITE: campaigns.update TimeTargeting. schedule_items=7 strings "day,h0,h1..h23" pct 0–100, day 1=Mon…7=Sun. Or weekend_pct for quick 100wd/weekend pattern. allow_write=true.

Inputs: campaign_id (required), dry_run, project, allow_write, +3 more.

direct_suspend_campaignsA

WRITE: suspend campaigns (State→SUSPENDED). Requires allow_write=true + project or campaign_ids. Stops spend.

Inputs: dry_run, project, allow_write, campaign_ids.

direct_unarchive_campaignsA

WRITE: campaigns.unarchive. allow_write=true + project scope. Prefer resume if only SUSPENDED.

Inputs: campaign_ids (required), dry_run, project, allow_write.

direct_update_adgroup_regionsA

WRITE: set absolute RegionIds on specific ad groups (positives + negatives). Example [225,-11010]. allow_write=true.

Inputs: updates (required), dry_run, project, allow_write.

direct_update_ad_hrefA

WRITE: update TextAd Href (landing/UTM) for ads. ad_hrefs=[{ad_id, href}]. allow_write=true. May need moderate after.

Inputs: ad_hrefs (required), dry_run, project, allow_write, +1 more.

direct_update_ad_textC

WRITE: ads.update TextAd Title/Title2/Text/Href/DisplayUrlPath/AdImageHash/SitelinkSetId. No ₽·— VPN. optional moderate_after. allow_write=true.

Inputs: ads (required), dry_run, project, allow_write, +1 more.

direct_update_keywordsA

WRITE: keywords.update user_param / strategy priority. items=[{keyword_id, user_param1?, user_param2?, strategy_priority?}]. For AT use set_autotargeting. allow_write=true.

Inputs: items (required), dry_run, project, allow_write.

direct_upload_adimageA

WRITE: adimages.add from local file path (server FS) or raw base64. Returns AdImageHash for TextAd.AdImageHash. allow_write=true.

Inputs: name (required), dry_run, file_path, allow_write, +1 more.

direct_upload_advideoA

WRITE: advideos.add from file_path or base64. Returns video Id; poll status with list_advideos. allow_write=true.

Inputs: name (required), dry_run, file_path, allow_write, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 80 tools

    Disambiguation3/5

    Most tools have distinct targets, but the many budget/strategy write tools (set_max_conv, set_strategy, set_daily_budget, set_network_weekly_budget, set_search_weekly_budget) overlap in purpose and could confuse an agent. Some list/get tools are also similar, though descriptions help.

    Naming Consistency4/5

    The vast majority follow direct_verb_noun (e.g., list_campaigns, set_keyword_bids, delete_keywords). A few anomalies like direct_ping, direct_rpc, direct_account_summary, and direct_client_info deviate from the verb-first pattern, but the overall convention is clear and predictable.

    Tool Count1/5

    With 80 tools, the server is far beyond the typical well-scoped range. Even for a complex API, this number is excessive and will likely overwhelm agents, making tool selection harder rather than easier.

    Completeness5/5

    The tool set covers the full lifecycle of Yandex Direct campaigns: creation, management, bidding, budgets, extensions, reporting, and even a raw RPC escape hatch. There are no obvious dead ends; nearly every operation an agent could need is present.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      MCP server for Yandex.Direct API v5 enabling management of campaigns, ad groups, ads, keywords, statistics, and account info via 12 tools.
      20
      93 npm
      4
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      MCP server for managing Yandex Direct advertising, Yandex Metrica analytics, Wordstat keyword research, and Yandex Webmaster SEO tools, with self-configuring OAuth; provides 153 tools for complete ad and search workflows from AI assistants.
      100
      14 npm
      3
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A hardened MCP server for managing Yandex.Direct advertising campaigns with read-only defaults, write and finance capabilities optional, using OAuth authentication.
      26
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for Yandex Direct, Metrika, Wordstat, and Webmaster APIs, providing 132 tools to manage advertising campaigns, analytics, keyword research, and reporting through any MCP-compatible client.
      60
      MIT