Skip to main content
Glama
YouTube Studio MCP

YouTube Studio MCP

by nelsonrogers

Custom analytics query

query_analytics
Read-onlyIdempotent

Run custom YouTube Analytics API v2 reports for your channel with selected metrics, dimensions, filters, date ranges, sorting, and row limits when preset reports do not fit.

Instructions

Run any YouTube Analytics API v2 report for the channel (ids=channel==MINE) — the escape hatch when no other tool fits. See https://developers.google.com/youtube/analytics/channel_reports for valid combinations. Notes: the 'video' dimension needs sort and max_results <= 200; 'insightTrafficSourceDetail' needs a filter on insightTrafficSourceType, sort and max_results <= 25; demographics (ageGroup/gender) only support viewerPercentage; the 'month' dimension aligns dates to whole months automatically. YouTube's error message is returned if a combination is invalid.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "metrics": "<metrics>"
    },
    "name": "query_analytics"
  }
}

Input Schema

NameRequiredDescriptionDefault
sortNoComma-separated sort, '-' for descending, e.g. '-views'.
periodNoNamed date range, Studio-style. Rolling ranges end at the latest complete day of data (analytics lag ~2-3 days; dates are US Pacific). Ignored when start_date is set.last_28_days
filtersNoAnalytics filter string, e.g. 'video==ID1,ID2;country==US' (';' = AND).
metricsYesMetric API names, e.g. ['views', 'likes'].
save_toNoOptional file to also save the rows to (.csv or .json). A bare filename goes in the output directory; absolute paths are allowed.
currencyNoCurrency for revenue metrics (ISO 4217).
end_dateNoCustom range end, YYYY-MM-DD (inclusive). Defaults to the latest complete day.
dimensionsNoDimension API names, e.g. ['day'], ['video'], ['country', 'creatorContentType'].
start_dateNoCustom range start, YYYY-MM-DD. Overrides `period`.
max_resultsNoRow limit.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations cover safety (readOnly, idempotent, non-destructive) but say nothing about validity rules; the description supplies the substantive behavior: the 'video' dimension requires sort and max_results <= 200, insightTrafficSourceDetail requires an insightTrafficSourceType filter with max_results <= 25, demographics only return viewerPercentage, and 'month' auto-aligns dates. It also discloses failure behavior – YouTube's own error message is surfaced for invalid combinations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads purpose and the escape-hatch role in the first clause, then moves to a docs pointer and a compact 'Notes' block of constraints. It is dense but every line carries operational information; the multi-line notes format is slightly harder to scan than a single tight statement.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter open-ended query tool with a 100% covered schema, an output schema, and safety annotations, the description covers the parts structured fields cannot: combination validity rules and error surfacing. An agent could still want guidance on metric/dimension pairing beyond the linked docs, which keeps it just under full completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3; the description earns above that by documenting cross-parameter constraints the schema cannot express (sort and row caps conditional on dimension choice, required filters per dimension, metric restrictions per dimension). It does not elaborate on save_to or currency, but the schema already handles those.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Run any YouTube Analytics API v2 report for the channel'), names the API scope (ids=channel==MINE), and positions itself explicitly as 'the escape hatch when no other tool fits', which distinguishes it from the 17 measured siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear when-to-use rule (only when no other tool fits) and points to the upstream report docs for valid metric/dimension combinations. It stops short of naming which siblings to prefer for common jobs, so the routing guidance is clear but not complete.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.