Skip to main content
Glama

Fetch bounded rows for a dataflow

fetch
Read-onlyIdempotent

Return bounded rows for a dataflow — the completion path for hosted clients.

Use this when the client cannot execute a client-download plan locally (no shell/filesystem — e.g. a hosted store app or connector) but still needs actual values. fetch server-side downloads the exact GET/fan-out plan build_url would produce, concatenates it, runs one bounded literal-equality query, and releases the artifact — the raw dataset never enters model context. Clients that CAN execute locally should keep using ask/build_url and run the plan themselves; fetch is the affinity-free hosted shortcut, not the power path.

POST-only selections have no hosted download path: fetch raises fetch_shape_unsupported and the caller must execute the build_url plan client-side. A rejected/over-length selection raises the same reason build_url would report; narrow the selection and retry.

fetch does not page, deliberately. It holds no dataset between calls: every call rebuilds the plan, re-downloads every part from the provider, and releases the artifact. An offset over that would be unsound as well as wasteful — there is no snapshot behind the cursor, so rows shifting upstream between calls would silently skip or duplicate observations, and N pages would mean N full downloads of the same dataflow from an agency that may rate-limit. When a result is truncated, narrow it (select, where, time_range) or switch to stage_url + query_dataset, which pages with offset over ONE immutable staged artifact and downloads once.

Rows are ordered by series key, then period, before limit applies. A series with a period that cannot be placed unambiguously keeps the provider's order.

no_records_for_selection is TERMINAL, not a fault: the request was well-formed and the source holds no observations for it. Widen the selection or state that no data exists — do not retry the same selection. Only upstream_origin_error (an origin fault), upstream_rate_limited and download_concurrency_exceeded (the server, or your own calls still running, are busy) are worth retrying. When the last is followed by slots_pending, retry once your running calls finish; a stage_url among them that succeeds keeps its place, so the retry can meet dataset_limit_reached instead. dataset_limit_reached is not: fetch needs one of the caller's places for staged datasets while it runs, and datasets left staged by stage_url, in this conversation or any other, hold them all. The error gives slots_used, slots_max and next_expiry; call release_dataset on a dataset you have finished with, or wait until next_expiry. subscription_key_required and upstream_auth_required mean the provider demands a key Aard does not send (Stats NZ): download the build_url request with your own key instead.

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": {
      "agency_id": "<agency_id>",
      "dataflow_id": "<dataflow_id>"
    },
    "name": "fetch"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoOptional max rows to return (a safe default applies when omitted)
whereNoOptional {column: value | [values]} literal-equality row filters
selectNoOptional list of columns to return (defaults to all columns)
agency_idYesSDMX agency code, e.g. "ABS", "ESTAT", "OECD"
max_bytesNoOptional smaller byte budget for this response; it can only lower the server ceiling, never raise it
precisionNoURL breadth — "point", "series" (default), or "cube"series
selectionsNoOptional {dimension_id: [code or name, ...]} to anchor the query
time_rangeNoOptional time filter (e.g. "2020-2024", "since 2015", "2024")
dataflow_idYesSDMX dataflow identifier, e.g. "ERP_Q"
availabilityNo"confirmed" (default) or "best_effort"confirmed
response_formatNoHow the rows are sent. "auto" (default) means no preference and lets the server decide; "text" sends them as CSV only — in the text content, and in structuredContent as a "csv" string in place of typed rows. "structured" sends typed rows only, "both" the CSV and the typed rows. If you got a summary but no rows, call again with response_format="text".auto

Output Schema

NameRequiredDescriptionDefault
csvNo
rowsNo
columnsNo
agency_idYes
truncatedYes
dataflow_idYes
limit_sourceYes
matched_rowsYes
applied_limitYes
returned_rowsYes
period_calendarYes
max_bytes_ceilingNo
min_bytes_requiredNo
source_request_countYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedOutput schema / properties / period_calendar
      Added value: +{
      +  "enum": [
      +    "gregorian",
      +    "buddhist"
      +  ],
      +  "type": "string"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "agency_id",
      -  "dataflow_id",
      -  "source_request_count",
      -  "matched_rows",
      -  "returned_rows",
      -  "truncated",
      -  "applied_limit",
      -  "limit_source"
      -]New value: +[
      +  "agency_id",
      +  "dataflow_id",
      +  "source_request_count",
      +  "period_calendar",
      +  "matched_rows",
      +  "returned_rows",
      +  "truncated",
      +  "applied_limit",
      +  "limit_source"
      +]
  2. Changed2 schema fields changed
    • changedInput schema / properties / response_format / description
      Previous value: -"Which channel carries the rows. \"auto\" (default) means\nno preference and lets the server decide; \"text\" sends them as CSV\nin the text channel only, \"structured\" as typed rows only, \"both\"\nin both. If you got a summary but no rows, call again with\nresponse_format=\"text\"."New value: +"How the rows are sent. \"auto\" (default) means no\npreference and lets the server decide; \"text\" sends them as CSV\nonly — in the text content, and in structuredContent as a \"csv\"\nstring in place of typed rows. \"structured\" sends typed rows only,\n\"both\" the CSV and the typed rows. If you got a summary but no\nrows, call again with response_format=\"text\"."
    • addedOutput schema / properties / csv
      Added value: +{
      +  "type": "string"
      +}
  3. Changed11 schema fields changed
    • addedInput schema / properties / agency_id / description
      Added value: +"SDMX agency code, e.g. \"ABS\", \"ESTAT\", \"OECD\""
    • addedInput schema / properties / availability / description
      Added value: +"\"confirmed\" (default) or \"best_effort\""
    • addedInput schema / properties / dataflow_id / description
      Added value: +"SDMX dataflow identifier, e.g. \"ERP_Q\""
    • addedInput schema / properties / limit / description
      Added value: +"Optional max rows to return (a safe default applies when omitted)"
    • addedInput schema / properties / max_bytes / description
      Added value: +"Optional smaller byte budget for this response; it can only\nlower the server ceiling, never raise it"
    • addedInput schema / properties / precision / description
      Added value: +"URL breadth — \"point\", \"series\" (default), or \"cube\""
    • addedInput schema / properties / response_format / description
      Added value: +"Which channel carries the rows. \"auto\" (default) means\nno preference and lets the server decide; \"text\" sends them as CSV\nin the text channel only, \"structured\" as typed rows only, \"both\"\nin both. If you got a summary but no rows, call again with\nresponse_format=\"text\"."
    • addedInput schema / properties / select / description
      Added value: +"Optional list of columns to return (defaults to all columns)"
    • addedInput schema / properties / selections / description
      Added value: +"Optional {dimension_id: [code or name, ...]} to anchor the query"
    • addedInput schema / properties / time_range / description
      Added value: +"Optional time filter (e.g. \"2020-2024\", \"since 2015\", \"2024\")"
    • addedInput schema / properties / where / description
      Added value: +"Optional {column: value | [values]} literal-equality row filters"
  4. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations declare readOnlyHint/openWorldHint/idempotentHint, but the description goes far beyond them: it discloses that the server downloads and then releases the artifact so raw data never enters context, that there is deliberately no paging and why (no snapshot, N full downloads, rate limits), and that fetch consumes a staged-dataset slot while running. It also gives a full, actionable error taxonomy distinguishing terminal (no_records_for_selection, dataset_limit_reached) from retryable (upstream_origin_error, upstream_rate_limited, download_concurrency_exceeded).

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?

Well front-loaded: purpose, then when-to-use, then the no-paging rationale, then error handling. Every sentence is substantive, but the error-code section is long and dense enough that it reads more like embedded documentation than a tool blurb, which slightly dilutes scannability.

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?

With an output schema present the description need not explain return values, and it doesn't waste space doing so. Given 11 parameters and a failure-prone download path, it covers everything an agent needs: hosting constraint, unsupported shapes, truncation strategy, slot exhaustion, and which errors to retry versus abandon.

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, but the description adds genuine meaning: rows are ordered by series key then period before limit applies, where clauses are literal-equality only, and truncated results should be narrowed via select/where/time_range. It also supplies a practical response_format workaround ("If you got a summary but no rows, call again with response_format=\"text\"") that the schema description does not spell out as a failure mode.

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 ("Return bounded rows for a dataflow") and immediately qualifies it as "the completion path for hosted clients." It distinguishes itself from the power path (ask/build_url) and from the paging path (stage_url + query_dataset) in the first paragraph.

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?

Explicit use-when condition: the client cannot execute a client-download plan locally but still needs values. It names the alternative for capable clients ("keep using ask/build_url and run the plan themselves") and names the alternative for paging (stage_url + query_dataset). It also states an explicit unsupported case (POST-only selections raise fetch_shape_unsupported).

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