faostat-mcp-server: resolve codes
faostat_resolve_codesResolve labels to the numeric codes or exact alphanumeric item identities faostat_query_observations needs: areas (countries/regions), items (commodities), and elements (metrics). Use query for full-text matching, name_contains for substring matching, code or code_text for exact identity, or omit them to list. Item and element matches occur in the selected domain; areas use shared vocabulary. For elements, optionally pass item_codes or item_codes_text to discover metrics and distinct units observed for those items; this does not establish area/year/source coverage. Empty item selectors match nothing. Page with offset and limit using nextOffset when truncated. Areas carry country/aggregate classification. Verified domain-specific item groups carry aggregate; null means unclassified, not safe-to-sum. Item groups can overlap their members even with matching units. Area aggregates include codes ≥ 5000 and curated roll-ups such as China=351; exclude overlapping regional and country rows when summing.
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": "<domain>",
"dimension": "<dimension>"
},
"name": "faostat_resolve_codes"
}
}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). | |
| code_text | No | Exact alphanumeric item code. Only for dimension item; mutually exclusive with code. Numeric identities use code. | |
| dimension | Yes | Which dimension to resolve: "area" (countries/regions), "item" (commodities), or "element" (metrics). | |
| item_codes | No | For element resolution only: restrict elements and units to these items. Empty matches nothing; omit for domain-wide elements. Mutually exclusive with item_codes_text. | |
| name_contains | No | Case-insensitive substring filter over the label. Used only when `query` is omitted. | |
| item_codes_text | No | For element resolution only: restrict elements and units to these exact text items. Empty matches nothing; mutually exclusive with item_codes. |
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. |