Skip to main content
Glama

data_query

Read-only

Query data from Google Ads, Facebook Ads, Google Analytics, LinkedIn Ads, TikTok Ads, Microsoft Ads, Shopify, HubSpot, and 200+ other platforms. Use data_source_discovery, accounts_discovery and field_discovery first. Returns rows when completed; else pass schedule_id to get_async_query_results. Team- and data-source-level context arrives with data_source_discovery/accounts_discovery, and a narrowed accounts_discovery (≤3 accounts) inlines an account's own context — apply what you already have. Only when you are querying a specific account whose context you have not seen, read it first with get_business_context (ds_id + account_id) for reporting guidelines — e.g. which campaigns to exclude, how to segment data, preferred metrics.

If the user specifies reporting preferences during the conversation (e.g. "exclude brand campaigns", "always break out Advantage+ separately", "for this client we only look at last-click attribution"), ask whether to save these as context for future sessions using manage_business_context with action 'save'.

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": {
      "ds_id": "<ds_id>"
    },
    "name": "data_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
ds_idYesData source ID from data_source_discovery (e.g. 'FA', 'AW', 'GAWA')
freshNoSkip stored results and run the query again. Use only to confirm a change right after a write, e.g. a budget or status update; it is slower and uses more quota. Only for campaign management data sources (e.g. Facebook Ads, Google Ads). Not available with API keys or for every client; the result notes say when it was not applied.
fieldsNoField IDs from field_discovery, comma-separated. List dimensions before metrics (e.g. 'date,clicks,cost'); if unsure whether a field is a dimension or metric, check field_discovery. All fields must share a common report_type if the source uses report types.
filtersNoFilter expression: field_name operator value, combined with AND/OR. Operators: ==, !=, >, >=, <, <=, =@ (contains), !@ (not contains), =~ (regex), !~ (not regex), [] (in list). Example: "country == US AND clicks > 100"
compressNoAlways recommended. Returns completed rows as a compact text table whose columns are the requested field IDs.
end_dateNoYYYY-MM-DD. Required when date_range_type=custom.
max_rowsNoMax rows to return (default 1000). Higher values may be capped by your license.
settingsNoData source settings from data_source_discovery as a JSON object. Include report_type and all setting_ids here. report_type is a preference when the source picks the report from the fields; some sources treat it as a strict choice and refuse one that does not fit. TikTok Smart+: use platform_details.is_smart_plus in campaign_and_resource_get.
timezoneNoIANA timezone (e.g. 'America/New_York'). Default: UTC.
start_dateNoYYYY-MM-DD. Required when date_range_type=custom.
ds_accountsNoAccount IDs from accounts_discovery, or free-text identifier when is_free_text_account_required=true. Required when has_account_list=true; ALL_ACCOUNTS queries every account of the connected logins: use only when the user asks for all accounts, as it can be slow or rate-limited on sources with many accounts.
compare_showNoperc_change (default), abs_change, or value
compare_typeNoprev_range, prev_year, prev_year_weekday, or custom (with compare_start/end_date)
date_range_typeNoA date range is required for nearly all data sources (is_date_range_required=true in data_source_discovery config). Use a relative range: last_7_days, last_30_days, last_90_days, last_month, this_month, yesterday, etc. (append '_inc' to include the current period), or 'custom' with start_date/end_date. Pass as a root-level parameter, NOT inside settings.
compare_end_dateNoYYYY-MM-DD (when compare_type=custom)
compare_start_dateNoYYYY-MM-DD (when compare_type=custom)

Output Schema

NameRequiredDescriptionDefault
dataNo
errorNo
notesNo
successYes
business_contextNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations cover the safety profile (readOnly, non-destructive), and the description layers on behavior those annotations cannot express: the synchronous-then-async return pattern and how to retrieve scheduled results, plus the fact that 'fresh' is slower and burns more quota and that ALL_ACCOUNTS can be slow or rate-limited. These are the operational traits an agent needs before calling.

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-loaded with purpose, then prerequisites, then the async fallback, which is good structure. The context paragraph is somewhat repetitive (context inlining is restated from two angles) and could be tighter without losing information.

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

Completeness5/5

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

For a 16-parameter, open-world query tool this covers the gaps that matter: required upstream discovery calls, async handling, and when account-level context must be fetched versus reused. With an output schema present, the absence of return-format detail is appropriate rather than a gap.

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%, so every parameter is already documented, and the description adds almost no parameter-level meaning beyond a restatement of the context-lookup convention (ds_id + account_id for get_business_context). Baseline 3 applies when the schema carries the parameter burden.

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?

Opens with a specific verb+resource ("Query data from Google Ads, Facebook Ads, ... and 200+ other platforms") that immediately scopes the tool and distinguishes it from discovery/management siblings. The named platform examples make concrete what 'data' means.

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

Usage Guidelines5/5

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

Explicitly sequences the workflow (data_source_discovery, accounts_discovery, field_discovery first), states the alternative path for pending results (pass schedule_id to get_async_query_results), and gives a conditional rule for get_business_context: only when the account context hasn't already been inlined. It even triggers a follow-up action (manage_business_context with action 'save') when the user states preferences.

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