faostat-mcp-server: resolve codes
faostat_resolve_codesResolve 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
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Exact code lookup. Takes precedence over `query`/`name_contains` when provided. | |
| limit | No | Maximum matches to return (max 200). | |
| query | No | Full-text search term, FTS5-matched against the dimension labels with prefix matching (e.g. "wheat", "import quantity"). Relevance-ranked. | |
| domain | Yes | 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. | |
| offset | No | 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). | |
| dimension | Yes | Which dimension to resolve: "area" (countries/regions), "item" (commodities), or "element" (metrics). | |
| name_contains | No | Case-insensitive substring filter over the label. Used only when `query` is omitted. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present when the call failed. Absent on success. | |
| domain | No | The domain code echoed back. | |
| notice | No | Guidance when nothing matched, more pages remain, or the dimension is not yet indexed. | |
| matches | No | Matching codes, relevance-ranked for query mode, else by code. | |
| dimension | No | The dimension resolved. | |
| truncated | No | True when more matches remain beyond the returned page — fetch them with nextOffset. | |
| nextOffset | No | 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. | |
| totalMatches | No | Total matches in this domain before the result cap. |