To get a right answer from query_data, have your assistant ask a narrow question, check the truncated flag before it adds anything up, and remember that the rows are each network's stored pull, before any pipeline's transform rules. The tool returns raw daily rows, not totals, and never more than 500 of them in one call. Its arguments and output schema are on the generated query_data page.
Why the row cap skews totals
Each result carries rows, total (the number of rows in this answer) and truncated. Every row is one day for one ad, ad group or campaign, as the network reported it. The tool does no grouping or summing, so the assistant does the arithmetic over whatever rows it received.
A week of daily rows for a few dozen ads already runs to hundreds of rows. Without a limit, the tool returns at most 100. When more rows match than the limit, truncated is true and the rest are left out. Rows are sorted by date first, so the rows that drop off are the latest days in the range. A total from a truncated answer is too low, and the shortfall sits at the end of the period, the part people usually ask about.
Tell the assistant how to ask
Steer the call from your prompt:
- One date range. A reversed range is refused with
start must not be after end. - One network or one source. A source is a single connected account, such as one ad account or analytics property; its id comes from list_sources.
- Only the columns it will use. Ask for
fieldssuch as["date", "cost", "currency"], not every column. A network-specific value isextra.<key>, and a row without that key returnsnullfor it. Any name that is not a standard column or anextra.name,extraitself included, is refused withunknown field: {…}. - The maximum limit when the question covers many days or ads.
Set these rules once at the start of the conversation:
When you use query_data: request only the fields you need, always include
currency with cost, set limit to the maximum, and if truncated is true,
split the date range and query again before you report any total.
If an answer is still truncated, have the assistant split the range by week or by day, or query one source at a time, and add the parts. Each call counts toward the rate limit that REST and MCP share: 120 requests a minute per credential. Past that, the server answers 429 with a Retry-After header.
Read the numbers correctly
- Currencies. Keep
currencynext tocostandconversion_value. Accounts that bill in different currencies cannot be summed into one figure, so have the assistant report one total per currency. - Ratios.
ctr,cpc,cpmandcpaeach hold one row's value. Averaging them across rows gives a wrong blended rate. Have the assistant sum cost, clicks, impressions and conversions first and divide afterward. - Days. The tool's description says dates are in the ad account's time zone, but some networks date their rows in UTC days. Two sources can split the same calendar day at different hours.
- Transforms. A pipeline's renames, filters and derived columns reach its destination only. A total from
query_datacan differ from your warehouse or sheet for that reason alone. - Recent days. Each sync replaces the stored rows for the days it re-pulls, so yesterday's figures can change after the next run. See the trailing sync window.
When to use the REST endpoint instead
query_data suits questions an assistant can answer from a few hundred rows. For a full export into a notebook or BI tool, use the REST endpoint, which reads the same stored rows and takes a larger limit. Reading stored rows with the API shows how to page through it by date.