Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
domain_codeYes
dimension_idYes
queryYes
langNoen

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

No annotations exist, so the description fully bears the burden. It details the three possible outcomes (single match, multiple matches, no matches) with explicit flags (requires_confirmation), includes agent instructions for handling each case, and provides message examples that clarify system behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While lengthy, every section serves a purpose: the opening states use case, followed by behavioral details, parameter descriptions, return shapes, and examples. The structure is logical and front-loaded, making it easy for an agent to parse.

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?

With 4 parameters (3 required), no enums, and a text-described output schema, the description covers all necessary context: when to use, how to interpret results, and agent actions for each case. No gaps remain for the agent to guess behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description adds comprehensive details for each parameter: domain_code is explained as a domain code (e.g., 'QCL'), dimension_id lists valid options, query is described as a case-insensitive substring with examples, and lang has a default explained. This far exceeds the baseline.

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?

The description clearly states it searches codes in a dimension by name, specifies its role as a precursor to faostat_get_data for partial or uncertain code names, and distinguishes it from sibling tools like faostat_get_codes by noting it should be used when browsing all codes is not needed.

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 when to use ('before faostat_get_data when you have a partial or uncertain code name'), provides clear instructions for multiple matches ('STOP and ask the user'), and suggests an alternative (faostat_get_codes) for no matches.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/berba-q/faostat-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server