Yandex Metrica MCP

v0.2.3
io.github.stufently/yandex-metrica-mcp Checked 1 day ago Published 1 month ago

Yandex Metrica for AI agents: counters, goals, Reporting API and Logs API export over stdio.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

yandex_metrica_list_counters

List Yandex Metrica counters the configured token can access, with each counter id, name, and site. Use when the user needs a counter id before any other query. Do not use this to read one counter's settings; call yandex_metrica_get_counter once the id is known.

ParameterTypeDescription
pageintegerPage number (1-based)
per_pageintegerItems per page (max 1000)
searchstringSearch by counter name or site URL
sortstringSort order
statusstringFilter by counter status
typestringFilter by counter type

yandex_metrica_get_counter

Get one Yandex Metrica counter by id, including its settings, status, owner, timezone, and site. Use when the user already has a counter id and wants that counter's configuration. Do not use this to discover unknown ids; call yandex_metrica_list_counters instead.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID

yandex_metrica_list_goals

List conversion goals configured on one Yandex Metrica counter, including each goal id and type. Use when the user asks which goals exist on a counter before building a report. Do not use this for conversion counts or rates; call yandex_metrica_get_report with the goal metrics.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID

yandex_metrica_get_report

Run a Yandex Metrica Reporting API query and return aggregated statistics such as visits, users, bounce rate, and traffic sources. Use when the user wants a summary, a breakdown, or a comparison of two periods via date1_b and date2_b. Do not use this for row-level visits or pageviews; call yandex_metrica_evaluate_logs_request and the other Logs API tools. Metrics use the ym:s: prefix for visits and ym:pv: for hits.

ParameterTypeDescription
counter_ids *arrayOne or more counter IDs to query
metrics *arrayMetrics to include, e.g. ['ym:s:visits', 'ym:s:pageviews', 'ym:s:bounceRate']. Max 20.
accuracystringSampling accuracy (default: medium)
attributionstringAttribution model for traffic source metrics. 'lastsign' = last significant source; 'automatic' = auto-attribution.
currencystringCurrency code (ISO 4217), e.g. 'RUB'
date1stringStart date (YYYY-MM-DD or 'today', 'yesterday', '7daysAgo'). Default: 7daysAgo
date1_bstringComparison segment B start date. When provided with date2_b, uses the comparison endpoint (/stat/v1/data/comparison). date1/date2 become segment A. Each row returns two sets of metrics.
date2stringEnd date (YYYY-MM-DD or relative). Default: today
date2_bstringComparison segment B end date. Must be provided together with date1_b.
dimensionsarrayDimensions for grouping, e.g. ['ym:s:date', 'ym:s:regionCityName']
filtersstringFilter expression, e.g. "ym:s:trafficSourceName=='Organic Search'"
filters_astringSegmentation filter for segment A only (comparison mode)
filters_bstringSegmentation filter for segment B only (comparison mode)
include_undefinedbooleanInclude rows with undefined dimension values
langstringLanguage for dimension value names (default: ru)
limitintegerRows to return (default 100)
offsetintegerRow offset for pagination (1-based)
presetstringPreset report name (e.g. 'sources_summary'). Overrides metrics/dimensions.
sortarraySort fields. Prefix with '-' for descending, e.g. ['-ym:s:visits', 'ym:s:date']

yandex_metrica_evaluate_logs_request

Check whether a Yandex Metrica Logs API export can be created for the given dates, source, and fields, without creating a request. Use when the user wants to know if a raw export is possible and how many days fit the quota. Do not use this to start the export; call yandex_metrica_create_logs_request after the check succeeds.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID
date1 *stringStart date YYYY-MM-DD
date2 *stringEnd date YYYY-MM-DD (cannot be current day)
fields *arrayFields to export. For visits: ['ym:s:visitID','ym:s:date','ym:s:clientID',...]. For hits: ['ym:pv:watchID','ym:pv:date','ym:pv:URL',...]
source *string'hits' for pageview-level data, 'visits' for session-level data

yandex_metrica_create_logs_request

Create an asynchronous Yandex Metrica Logs API export of raw visits or hits for one counter and date range. Use when the user wants row-level data and yandex_metrica_evaluate_logs_request has shown the export is possible. Do not use this only to test feasibility, and do not use it for aggregated totals; call yandex_metrica_get_report for those. Poll yandex_metrica_get_logs_request until the status is processed. date2 cannot be today. Fields use the ym:s: prefix for visits and ym:pv: for hits.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID
date1 *stringStart date YYYY-MM-DD
date2 *stringEnd date YYYY-MM-DD (cannot be current day)
fields *arrayFields to export. See Yandex Metrica Logs API documentation for full field lists.
source *string'hits' for pageview-level data, 'visits' for session-level data
attributionstringAttribution model for traffic source fields. Default: lastsign.

yandex_metrica_list_logs_requests

List every Logs API export request on a Yandex Metrica counter, in any status from created through cleaned. Use when the user wants to see existing exports or find a request id. Do not use this to poll a single request; call yandex_metrica_get_logs_request with that request id.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID

yandex_metrica_get_logs_request

Get the status and prepared parts of one Yandex Metrica Logs API export request. Use when the user is waiting for a created export to reach processed before downloading it. Do not use this to fetch the TSV rows; call yandex_metrica_download_logs_part once the status is processed. Do not use it to list every request; call yandex_metrica_list_logs_requests.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID
request_id *integerLogs API request ID

yandex_metrica_download_logs_part

Download one processed part of a Yandex Metrica Logs API export as TSV text. Use when the user wants the rows of a request whose status is already processed. Do not use this to check whether the export is ready; call yandex_metrica_get_logs_request first. Preview mode returns about the first 50KB; full mode is only for small parts under 10MB. Part numbers come from the parts list returned by yandex_metrica_get_logs_request and start at 0.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID
part_number *integerPart number (0-based)
request_id *integerLogs API request ID
modestringOutput mode. 'preview' returns first ~50KB with metadata (safe default). 'full' returns entire content — may be very large for big exports.

yandex_metrica_cancel_logs_request

Cancel a Yandex Metrica Logs API export that is still pending, in status created or awaiting_retry. Use when the user wants to stop an export that has not been processed yet. Do not use this on a processed request; call yandex_metrica_clean_logs_request to delete the prepared files.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID
request_id *integerLogs API request ID

yandex_metrica_clean_logs_request

Delete the prepared files of a processed Yandex Metrica Logs API export and free the export quota. Use when the user has finished downloading and the request status is processed. Do not use this to stop a request that is still pending; call yandex_metrica_cancel_logs_request instead.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID
request_id *integerLogs API request ID

yandex_metrica_create_counter

Create a new Yandex Metrica counter for a site and return its id and tracking code. Use when the user asks to add a website or start tracking a new property. Do not use this to find a counter that already exists; call yandex_metrica_list_counters or yandex_metrica_get_counter.

ParameterTypeDescription
name *stringCounter name
site *stringSite domain (e.g. "example.com")
gdpr_agreement_acceptedbooleanGDPR agreement accepted (required for EU sites)
mirrorsarrayMirror domains
time_zone_namestringTimezone (e.g. "Europe/Moscow")

yandex_metrica_delete_counter

Delete one Yandex Metrica counter; it stops collecting data and its statistics are no longer available through the API. Use when the user explicitly asks to remove a counter and has confirmed the deletion. Do not use this to inspect a counter; call yandex_metrica_get_counter instead.

ParameterTypeDescription
counter_id *integerYandex Metrica counter (tag) ID