Skip to main content
Glama

faostat-mcp-server: resolve codes

faostat_resolve_codes
Read-onlyIdempotent

Resolve human terms to the opaque integer codes faostat_query_observations needs, within a dimension: areas (countries/regions), items (commodities), or elements (metrics like production, yield, import quantity). Pass query for fuzzy full-text matching ("maize" → item 56), name_contains for a substring filter, or code for an exact-code lookup; omit all three to list the whole dimension. Item and element results are scoped to the requested domain — only codes present in that domain's cube are returned, so a resolved code is always queryable there (areas are shared across domains). Page large listings with offset + limit: when the response reports truncated, pass the returned nextOffset to fetch the next page. Every area match is flagged country or aggregate — aggregates (World, continents, economic groupings — codes ≥ 5000 plus a few curated sub-threshold roll-ups such as China=351, which sums mainland + Taiwan + Hong Kong + Macao) double-count if summed with their member countries, so resolve before querying and exclude aggregates unless you want the regional roll-up.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNoExact code lookup. Takes precedence over `query`/`name_contains` when provided.
limitNoMaximum matches to return (max 200).
queryNoFull-text search term, FTS5-matched against the dimension labels with prefix matching (e.g. "wheat", "import quantity"). Relevance-ranked.
domainYesFAOSTAT domain code (e.g. "QCL"). Item and element resolution is scoped to the codes present in this domain's data; area code lists are shared across all indexed domains.
offsetNoZero-based pagination offset into the match set. When the response reports truncated, pass the returned nextOffset here to fetch the next page. Ignored for exact-code lookups (always single-page).
dimensionYesWhich dimension to resolve: "area" (countries/regions), "item" (commodities), or "element" (metrics).
name_containsNoCase-insensitive substring filter over the label. Used only when `query` is omitted.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorNoPresent when the call failed. Absent on success.
domainNoThe domain code echoed back.
noticeNoGuidance when nothing matched, more pages remain, or the dimension is not yet indexed.
matchesNoMatching codes, relevance-ranked for query mode, else by code.
dimensionNoThe dimension resolved.
truncatedNoTrue when more matches remain beyond the returned page — fetch them with nextOffset.
nextOffsetNoOffset to pass on the next call to fetch the following page. Present only when truncated is true; absent on the last page and for exact-code lookups.
totalMatchesNoTotal matches in this domain before the result cap.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode. Declared by this tool: `unknown_domain`: The domain code is not a selected (indexed) FAOSTAT domain. `index_not_ready`: The dimension tables are not yet populated (mirror has never completed a sync). Other values are possible when a failure originates below the handler."New value: +"Machine-readable failure mode. Declared by this tool: `unknown_domain`: The domain code is not a selected (indexed) FAOSTAT domain. `index_not_ready`: The dimension tables are not yet populated (mirror has never completed a sync). `query_timeout`: The item or element lookup's mirror read — time queued behind other calls' reads plus execution — ran past the 45-second per-call ceiling. Other values are possible when a failure originates below the handler."
    • changedOutput schema / properties / error / properties / data / properties / reason / examples
      Previous value: -[
      -  "unknown_domain",
      -  "index_not_ready"
      -]New value: +[
      +  "unknown_domain",
      +  "index_not_ready",
      +  "query_timeout"
      +]
  2. Changed6 schema fields changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / additionalProperties
      Added value: +false
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedOutput schema / anyOf
      Added value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "domain",
      +      "dimension",
      +      "matches",
      +      "totalMatches",
      +      "truncated"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / error
      Added value: +{
      +  "additionalProperties": {},
      +  "description": "Present when the call failed. Absent on success.",
      +  "properties": {
      +    "code": {
      +      "description": "JSON-RPC error code for this failure.",
      +      "maximum": 9007199254740991,
      +      "minimum": -9007199254740991,
      +      "type": "integer"
      +    },
      +    "data": {
      +      "additionalProperties": {},
      +      "properties": {
      +        "reason": {
      +          "description": "Machine-readable failure mode. Declared by this tool: `unknown_domain`: The domain code is not a selected (indexed) FAOSTAT domain. `index_not_ready`: The dimension tables are not yet populated (mirror has never completed a sync). Other values are possible when a failure originates below the handler.",
      +          "examples": [
      +            "unknown_domain",
      +            "index_not_ready"
      +          ],
      +          "type": "string"
      +        },
      +        "recovery": {
      +          "additionalProperties": {},
      +          "description": "Actionable next step for the caller.",
      +          "properties": {
      +            "hint": {
      +              "type": "string"
      +            }
      +          },
      +          "required": [
      +            "hint"
      +          ],
      +          "type": "object"
      +        },
      +        "retryable": {
      +          "description": "Whether retrying may succeed.",
      +          "type": "boolean"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "message": {
      +      "description": "Human-readable description of what went wrong.",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "code",
      +    "message"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / required
      Removed value: -[
      -  "domain",
      -  "dimension",
      -  "matches",
      -  "totalMatches",
      -  "truncated"
      -]
  3. Changed6 schema fields changed
    • changedInput schema / properties / domain / description
      Previous value: -"FAOSTAT domain code to verify the index is ready (e.g. \"QCL\"). Dimension code lists (areas, items, elements) are shared across all indexed domains."New value: +"FAOSTAT domain code (e.g. \"QCL\"). Item and element resolution is scoped to the codes present in this domain's data; area code lists are shared across all indexed domains."
    • addedInput schema / properties / offset
      Added value: +{
      +  "default": 0,
      +  "description": "Zero-based pagination offset into the match set. When the response reports truncated, pass the returned nextOffset here to fetch the next page. Ignored for exact-code lookups (always single-page).",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedOutput schema / properties / nextOffset
      Added value: +{
      +  "description": "Offset to pass on the next call to fetch the following page. Present only when truncated is true; absent on the last page and for exact-code lookups.",
      +  "maximum": 9007199254740991,
      +  "minimum": -9007199254740991,
      +  "type": "integer"
      +}
    • changedOutput schema / properties / notice / description
      Previous value: -"Guidance when nothing matched or the dimension is not yet indexed."New value: +"Guidance when nothing matched, more pages remain, or the dimension is not yet indexed."
    • changedOutput schema / properties / totalMatches / description
      Previous value: -"Total matches before the result cap."New value: +"Total matches in this domain before the result cap."
    • changedOutput schema / properties / truncated / description
      Previous value: -"True when matches were capped at the limit."New value: +"True when more matches remain beyond the returned page — fetch them with nextOffset."
  4. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already establish readOnly/idempotent/openWorld=false, so the safety profile is covered. The description goes well beyond that with non-obvious traits: item/element results are scoped to the requested domain while areas are shared, aggregates double-count when summed with members (codes >= 5000 plus curated roll-ups like China=351), and truncation is surfaced via a nextOffset field.

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-loads the purpose, then layers mode selection, scoping, and the aggregate caveat in a logical order; every sentence carries information. It runs long as a single dense paragraph, which slightly burdens scanning, but there is little waste.

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?

An output schema exists so return values need not be explained, yet the description still covers the one returned signal an agent must act on (`truncated` + `nextOffset`). Combined with the domain-scoping and aggregate warnings, an agent has everything needed to call this correctly in sequence with faostat_query_observations.

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 all seven parameters are already documented, and the description largely restates that (mode selection, pagination, code precedence). It adds a light illustrative example ('maize' -> 56) but no syntax or format detail the schema lacks, so the 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?

States a specific verb ('resolve human terms to the opaque integer codes') and names exactly which sibling consumes the output (faostat_query_observations). It enumerates the three resolvable dimensions with concrete examples, making it unmistakable against siblings like faostat_list_domains or faostat_commodity_profile.

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 distinguishes the three matching modes (`query` fuzzy, `name_contains` substring, `code` exact) and states what happens when all are omitted ('list the whole dimension'). It also gives the conditional rule for excluding aggregates unless a regional roll-up is wanted.

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.