Skip to main content
Glama

faostat_count_data

Read-onlyIdempotent

Count the rows a FAOSTAT query would return before fetching them, using the same filters and null-value settings, to size a dataset or verify filter codes without downloading data.

Instructions

Count the rows of a FAOSTAT query before fetching them, filtered as get_data filters.

One get_data request with no_records=true, which FAOSTAT answers with the query's number of rows: data is that whole number, as is meta.total. It takes get_data's filters and null_values, which decide the rows, and refuses before any request where get_data does. The structure is read first, kept for a day, since a count prints no column to prove a filter's dimension; a filter of several codes is checked against its list before the count, and a count of 0 has each filter's list read: a wrong code, year or dimension raises InvalidRequestError naming the closest, else meta.names names each code. meta.vintage is the domain's last update. A call sends at most twelve requests (structure, code lists, count, release date), each tried up to four times, 48 requests at most, a login where the process holds no token, and a login and the request again where FAOSTAT refuses with 401 or 403.

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": {
      "domain_code": "<domain_code>"
    },
    "name": "faostat_count_data"
  }
}

Input Schema

NameRequiredDescriptionDefault
areaNoOne area code or several, FAO's, as ``list_codes(domain_code, "area")`` lists them, e.g. ``"231"`` (United States of America) or ``["231", "79"]``.
itemNoOne item code or several, as ``list_codes(domain_code, "item")`` lists them, e.g. ``"15"`` (Wheat).
yearNoOne year or several, each one that ``list_codes(domain_code, "year")`` lists, e.g. ``2020`` or ``[2015, 2016, 2017]``.
elementNoOne element code or several, the filter codes that ``list_codes(domain_code, "element")`` lists, e.g. ``"2510"`` (Production Quantity in QCL); ``5510``, the code its rows print, is refused naming ``2510``.
filtersNoAny other dimension's codes by its id, as ``get_data`` takes them, e.g. ``{"month": "7001"}`` for PP; an id that the dataset's structure lacks is refused before the count, and one that ``get_data`` sends itself (``area``, ``page_size``, ``no_records``) before sending.
domain_codeYesThe domain's code, as ``list_domains`` lists it, e.g. ``"QCL"`` (Crops and livestock products) or ``"FS"`` (Suite of Food Security Indicators); one FAOSTAT does not have raises ``NotFoundError``, and an empty text, ``"."`` or ``".."`` is refused before sending.
null_valuesNo``True`` counts the rows of which FAOSTAT holds nothing too, as ``get_data`` with ``null_values=True`` returns them; ``False``, the default, leaves them out.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.3.0

TDQS

A4.3/5.0
Behavior5/5

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

Well beyond the readOnly/openWorld/idempotent annotations, it discloses the underlying mechanism (a get_data call with no_records=true), where the count surfaces (data and meta.total), validation behavior (refusal before any request where get_data refuses, code-list checks, InvalidRequestError naming the closest code), a cached structure kept for a day, and a concrete request/retry budget with login handling on 401/403.

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

Conciseness3/5

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

The purpose is front-loaded, but the prose is dense and clause-chained, with implementation minutiae (twelve requests, four retries, 48 requests at most) mixed into the same block as return semantics. It is informative but harder to scan than necessary.

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 seven-parameter, no-output-schema tool, it covers what comes back (whole number in data and meta.total, meta.vintage as last update), failure modes, and operational limits, leaving nothing an agent needs in order to call it correctly.

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 coverage is 100%, so each of the seven parameters is already documented in the schema. The description only restates that it takes get_data's filters and null_values, adding no format, default, or interaction detail beyond what the schema supplies — the baseline for full coverage.

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?

The first clause gives a specific verb and resource — count the rows of a FAOSTAT query — and immediately scopes it as 'before fetching them, filtered as get_data filters,' which cleanly separates it from the sibling that actually returns data.

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?

It states the situation for use ('before fetching them') and ties the input contract to get_data's filters, so an agent knows when this is the right call. It stops short of explicit when-not guidance, e.g. that a small known query can go straight to get_data or get_series.

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