faostat_search_codes
Search FAOSTAT dimension codes by name to find exact matches or resolve ambiguous names. Prevents wrong-code errors by requiring user confirmation when multiple matches exist.
Instructions
Search codes in a dimension by name — use this BEFORE faostat_get_data when you have a partial or uncertain code name (e.g. 'production', 'wheat', 'Nigeria').
This tool prevents wrong-code errors by making ambiguity explicit:
Exactly 1 match → safe to proceed (requires_confirmation=False)
Multiple matches → STOP and ask the user to choose (requires_confirmation=True)
No matches → broaden your search term
AGENT INSTRUCTION: When the response contains "requires_confirmation": true, you MUST present ALL entries in the "matches" list to the user and ask them to select one before calling faostat_get_data, faostat_get_rankings, or any other data tool. Do NOT guess or automatically pick the first match.
Args: domain_code: Domain code to search within (e.g. 'QCL', 'TM', 'FS'). dimension_id: Dimension to search ('element', 'item', 'area', 'year'). query: Partial or full name to search for (case-insensitive substring). Examples: 'production', 'wheat', 'gross production index'. lang: Language code (default: 'en').
Returns a JSON object with one of these shapes:
Single match — safe to proceed: {"match": {"code": "2510", "label": "Production"}, "requires_confirmation": false, "message": "Unique match found. Use code '2510' as the element filter."}
Multiple matches — MUST ask user before proceeding: {"matches": [{"code": "2510", "label": "Production"}, {"code": "2512", "label": "Gross Production Index Number"}], "requires_confirmation": true, "message": "Multiple matches for 'production' in element/QCL. Ask the user."}
No matches: {"matches": [], "requires_confirmation": false, "message": "No codes match '...'. Use faostat_get_codes to browse all codes."}
Examples: faostat_search_codes('QCL', 'element', 'production') → Multiple matches (Production, Gross Production Index) — ask user.
faostat_search_codes('QCL', 'area', 'nigeria')
→ Single match for Nigeria — safe to proceed with code '231'.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain_code | Yes | ||
| dimension_id | Yes | ||
| query | Yes | ||
| lang | No | en |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |