Skip to main content
Glama

Run a GAQL query

run_gaql_report
Read-only

Run an arbitrary read-only Google Ads Query Language (GAQL) SELECT against an account and return the raw rows. The power tool for anything the structured tools don't cover. Only SELECT is allowed.

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": {
      "gaql": "<gaql>"
    },
    "name": "run_gaql_report"
  }
}

Input Schema

NameRequiredDescriptionDefault
gaqlYesA GAQL SELECT statement, e.g. "SELECT campaign.name, metrics.clicks FROM campaign WHERE segments.date DURING LAST_7_DAYS". Enum-typed fields only accept their exact string name in WHERE (e.g. `campaign.status = 'ENABLED'`), never the field's underlying numeric/ordinal value (e.g. NOT `= '2'` or `= 2`) and never LIKE/wildcards. Use IN (...) with the exact enum name(s), e.g. WHERE campaign.status IN ('ENABLED','PAUSED'), or omit the filter and inspect the returned enum values in a first pass. Any metrics/segments field requires a `segments.date` filter that bounds a finite range - bound `segments.date` with either `segments.date DURING LAST_30_DAYS` (or another named range: TODAY, YESTERDAY, LAST_7_DAYS, THIS_MONTH, LAST_MONTH, ...) or `segments.date BETWEEN 'YYYY-MM-DD' AND 'YYYY-MM-DD'`. A single-sided comparison (`segments.date >= '...'`) does not count as a finite range. Otherwise Google errors with "Expects filters on the following field to limit a finite date range: 'segments.date'". For keyword-level metrics (impressions, clicks, cost, conversions, ...), query `FROM keyword_view`, not `FROM ad_group_criterion` - ad_group_criterion only exposes the criterion's own config (status, keyword.text, keyword.match_type, quality_info, ...) and has no metrics. On keyword_view, name the keyword with the `ad_group_criterion.keyword.text` / `ad_group_criterion.keyword.match_type` fields, not `segments.keyword.info.text` / `segments.keyword.info.match_type` - that segment labels a different resource's rows by the keyword involved (e.g. search_term_view), and keyword_view rows are already one per keyword. Otherwise Google errors with "metric/segment is incompatible with the resource in the FROM clause". `change_event` and `change_status` don't support `segments.date` at all - use their own date/time field instead: `change_event.change_date_time` on change_event, `change_status.last_change_date_time` on change_status. Conversion-related segments (segments.conversion_action_name, segments.conversion_action_category, segments.conversion_lag_bucket, ...) only combine with conversion-specific metrics (metrics.conversions, metrics.all_conversions, metrics.conversions_value, ...) - ordinary metrics like clicks, impressions, and cost_micros aren't computed per conversion action, and Google names the ones actually blocking the query as "unsupported metrics" above. Drop those metrics from this query, or run them separately without the conversion segment. GAQL requires that any field used in WHERE or ORDER BY also appear in the SELECT list - add the named field there too. `DURING` only accepts a fixed set of named ranges: TODAY, YESTERDAY, LAST_7_DAYS, LAST_14_DAYS, LAST_30_DAYS, LAST_BUSINESS_WEEK, THIS_WEEK_SUN_TODAY, THIS_WEEK_MON_TODAY, LAST_WEEK_SUN_SAT, LAST_WEEK_MON_SUN, THIS_MONTH, LAST_MONTH - there's no LAST_90_DAYS or other custom-length range. For anything else, use `segments.date BETWEEN 'YYYY-MM-DD' AND 'YYYY-MM-DD'` with explicit dates instead. `change_event` and `change_status` cap how far back `segments.date`/the relevant date field can start - 30 days for change_event, 90 for change_status - Google simply doesn't retain older history. Narrow the `BETWEEN`/`DURING` range to stay within that limit. `change_event` and `change_status` queries must end with an explicit `LIMIT n` where n <= 10000, e.g. `LIMIT 1000` - Google rejects them outright with no LIMIT clause at all. `change_event` has no `resource_type` field - that name belongs to `change_status`. On `change_event` the equivalent is `change_event.change_resource_type` (an enum, e.g. AD, CAMPAIGN, AD_GROUP, ...). GAQL's WHERE clause doesn't support parentheses or boolean grouping - conditions can only be ANDed together as a flat list, and there's no OR at all. Remove the parentheses; if you need an OR over the same field's values, use `IN (...)` instead, and if you need an OR across different fields, run separate queries and merge the results.
customerIdNoClient account id (digits). Must not be a manager (MCC) account: Google rejects metrics on managers, so pick a child account from the account list.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / customerId / description
      Added value: +"Client account id (digits). Must not be a manager (MCC) account: Google rejects metrics on managers, so pick a child account from the account list."
  2. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, and the description reinforces this with "Only SELECT is allowed" and states the output is raw rows rather than a normalized report. It does not mention error surfacing or row/result limits, which for an open-ended query tool would be the remaining useful behavioral detail.

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

Conciseness5/5

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

Three short sentences, front-loaded with the action and scope, then the differentiation, then the hard constraint. No redundant restatement of the schema's lengthy GAQL rules.

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?

The description sets scope and output form while the schema carries the heavy syntax rules and the annotations carry the safety profile, which is appropriate for a two-parameter pass-through query tool. It lacks any note on failure behavior (Google errors are surfaced verbatim per the schema) or expected result size, which would complete the picture.

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

Parameters3/5

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

Schema description coverage is 100% and the gaql parameter is documented exhaustively in the schema (enum handling, date-range rules, resource compatibility, LIMIT requirements). The tool description adds no parameter meaning beyond "SELECT against an account", so the baseline 3 applies.

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 an arbitrary read-only Google Ads Query Language (GAQL) SELECT against an account") plus the return shape ("raw rows"), and explicitly positions it against the structured report siblings ("The power tool for anything the structured tools don't cover"). An agent can distinguish it from run_report/run_funnel_report without opening a schema.

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 selection rule: use this when the structured tools don't cover the question, and only for SELECT statements. It does not name a specific sibling to fall back to for common cases (e.g. "prefer run_report for standard metric pulls"), so it stops short of explicit when-not guidance.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources