Skip to main content
Glama

faostat_get_data

Read-onlyIdempotent

Retrieve rows from one FAOSTAT dataset filtered by area, item, element, year, or other dimension codes; use narrow filters or pagination to handle large result sets.

Instructions

Get one FAOSTAT dataset's rows, filtered by any of its dimensions.

Each row has the dataset's columns. Filter by area, item, element and year, and by any other dimension's id in filters (list_dimensions names them); with no filter it refuses before any request. Without page_size all matching rows come at once: keep filters narrow, or page. Name a country for TM, EA and FT, whose whole years time out (HTTP 504). Codes are FAO's whatever area_cs and item_cs print. A filter of several codes is checked against its list first, an empty answer after: a wrong code, year, dimension or system raises InvalidRequestError naming the closest; else meta.names names each code. meta.vintage is the domain's last update, else None with a note. A call sends at most twelve requests (structure, code lists, data, 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_get_data"
  }
}

Input Schema

NameRequiredDescriptionDefault
areaNoOne area code or several, FAO's whatever ``area_cs`` says, as ``list_codes(domain_code, "area")`` lists them, e.g. ``"231"`` (United States of America) or ``["231", "79"]``.
itemNoOne item code or several, FAO's whatever ``item_cs`` says, as ``list_codes(domain_code, "item")`` lists them, e.g. ``"15"`` (Wheat) or ``["15", "27"]``.
langNoLanguage of the labels and the headers: ``"en"`` (the default), ``"fr"`` or ``"es"``. The rows are read by their columns' descriptions, so a row has the same fields in each.en
yearNoOne year or several, each one that ``list_codes(domain_code, "year")`` lists, e.g. ``2020`` or ``[2015, 2016, 2017]``; a year the dataset lacks is refused, and ``get_series`` takes a range instead. FS has no ``year``, which is refused there: its periods are ``year3``, in ``filters`` or through ``get_series``.
area_csNoThe coding system in which the rows print the area codes, one that the dataset's dimension ``area`` names (``"M49"``, ``"FAO"``, ``"ISO2"`` or ``"ISO3"`` in QCL), or in a dataset without it its countries' dimensions (``reporterarea`` and ``partnerarea`` in TM, ``recipientarea`` in FA and EA, ``"CRS"`` too in EA), checked against its structure before the data; another, or one in a dataset with none of them, is refused. ``None`` prints FAO's codes under ``area_code``; given, the rows print them under a header naming the system, kept in ``columns``, and ``area_code`` is ``None``: ``area="231"`` with ``area_cs="M49"`` prints ``840`` under ``Area Code (M49)``. The filter takes FAO's codes whatever the system, so ``area="840"`` is refused in QCL, whose area list lacks it.
elementNoOne element code or several, the filter codes that ``list_codes(domain_code, "element")`` lists, e.g. ``"2510"`` (Production Quantity in QCL), which answers rows whose ``element_code`` is ``"5510"`` (Production); ``5510`` as a filter matches nothing and is refused naming ``2510``.
filtersNoAny other dimension's codes by its id, as ``list_dimensions`` names it, one code or several, as ``list_codes`` lists them, e.g. ``{"month": "7001"}`` (January) for PP, ``{"survey": "024_2024"}`` for MDDW or ``{"reporterarea": "231", "partnerarea": "110"}`` for TM; each sent under its id and checked as the four filters are, an id that the dataset's structure lacks refused. An id that ``get_data`` sends itself (``area``, ``lang``, ``page_size``) is refused before sending.
item_csNoThe coding system in which the rows print the item codes, one that the dataset's dimension ``item`` names, ``"CPC"`` or ``"FAO"`` in QCL, ``"FBS"`` or ``"FAO"`` in FBS, checked likewise. ``None`` prints FAO's codes under ``item_code``; given, the rows print them under a header naming the system, kept in ``columns``, and ``item_code`` is ``None``: ``item="15"`` with ``item_cs="CPC"`` prints ``0111`` under ``Item Code (CPC)``.
page_sizeNoRows per page, e.g. ``100``; with ``page_number``, one page of the answer. ``None`` returns every row, and ``count_data`` counts them first. One below 1 is refused before sending, since FAOSTAT answers ``0`` with every row.
domain_codeYesThe domain's code, as ``list_domains`` lists it, e.g. ``"QCL"`` (Crops and livestock products), ``"TCL"`` (trade in crops and livestock products), ``"FBS"`` (Food Balances, 2010-), ``"PP"`` (Producer Prices) or ``"RL"`` (Land Use); one FAOSTAT does not have raises ``NotFoundError``, and an empty text, ``"."`` or ``".."`` is refused before sending.
null_valuesNo``True`` adds the rows of which FAOSTAT holds nothing, without a unit, a value or flags; ``False``, the default, leaves them out. A row whose value is missing comes either way, flagged ``O``, its ``value`` ``None``.
page_numberNoThe page to return, from 1, e.g. ``2`` (rows 101 to 200 with ``page_size=100``); without ``page_size`` it is refused before sending, since FAOSTAT answers it alone with every row.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.3.0

TDQS

A4.2/5.0
Behavior4/5

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

Goes far beyond the readOnly/idempotent/openWorld annotations: it discloses the request budget (twelve per call, four retries each, 48 maximum), the token/login flow and re-auth on 401/403, the 504 timeout behavior on specific domains, the refusal order for invalid codes, and what meta.names and meta.vintage return. This is unusually rich behavioral context for a read-only tool, though the run-on packing slightly blurs it.

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 and every sentence carries information, but the prose is telegraphic and badly over-compressed: clauses like "A filter of several codes is checked against its list first, an empty answer after" and nested parentheticals about TM/EA/FT make it hard to parse on first read. Information density is high, but structure and readability suffer.

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?

With 12 parameters and no output schema, the description still covers return shape (columns, area_code/item_code becoming None when a coding system is named, meta.names and meta.vintage) and failure modes (InvalidRequestError naming the closest code, 504s, 401/403 re-auth). It is close to complete for a complex data-fetch tool; only row/structure internals are left implicit.

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 the schema already defines every parameter thoroughly (area_cs, item_cs, filters, page_size, page_number). The description adds a little operational meaning — that multi-code filters are validated against the code list first, and how page_size interacts with page_number — but largely restates what the schema carries. Baseline 3 is appropriate.

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 and resource — "Get one FAOSTAT dataset's rows, filtered by any of its dimensions" — and continuously distinguishes itself from siblings: get_series is named as the range alternative, count_data as the counter, list_dimensions and list_codes as the source of dimension and code ids. An agent can tell exactly which tool fetches dataset rows.

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 states the when-not: with no filter the call is refused before any request, so filters must be narrow or paged. It names concrete conditions for alternatives (get_series takes a range instead of a year list; count_data counts rows first; FS has no year, use year3) and warns that whole years time out for TM, EA and FT requiring a country name.

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