Skip to main content
Glama

faostat_get_data

Fetch statistical data from a FAOSTAT domain by specifying domain code and optional filters for area, item, element, and year.

Instructions

Fetch statistical data from a FAOSTAT domain. This is the primary tool for retrieving actual data values.

When you do not have an exact item, element, or area code, call faostat_search_codes first. If it returns requires_confirmation=True, you MUST ask the user to choose from the listed options before calling this tool.

IMPORTANT: For large domains, always filter by area/item/year to avoid very large responses. Check query size first with faostat_get_datasize.

IMPORTANT: Element codes used for filtering differ from the display codes returned in the response. Always use faostat_get_codes(dimension_id='element', domain_code=...) to get the correct filter codes. For example, in QCL:

  • Filter with element='2510' → response shows Element Code '5510' (Production)

  • Filter with element='2312' → response shows Element Code '5312' (Area harvested)

Args: domain_code: Domain code (e.g. 'QCL' for Crops and Livestock Products) lang: Language code (default: 'en') area: Country/area codes, comma-separated (e.g. '2' for Afghanistan). Use faostat_get_codes(dimension_id='area', domain_code=...) to find codes. element: Element FILTER codes, comma-separated (e.g. '2510' for Production, '2312' for Area harvested in QCL). These differ from the display codes in the response. Always look up via faostat_get_codes first. item: Item/commodity codes, comma-separated (e.g. '515' for Apples, '15' for Wheat) year: Year codes, comma-separated (e.g. '2020' or '2018,2019,2020') area_cs: Area code set name (alternative to individual area codes) element_cs: Element code set name item_cs: Item code set name year_cs: Year code set name (e.g. 'FAO_YEAR_RECENT' for recent years) show_codes: Include code columns in response (default: False — names are more useful for interpretation; codes are for filtering) show_unit: Include unit column in response (default: True) show_flags: Include data quality flags (default: False — rarely needed) null_values: Include rows with null values (default: False) limit: Maximum number of rows to return (default: 50). Set to 0 for no limit. Use faostat_get_datasize first if you expect a large result set. response_format: Output format (default: 'objects'). - 'objects': Array of self-describing JSON objects (best LLM comprehension) - 'compact': Columnar {"columns": [...], "rows": [[...]]} (~3x smaller) - 'csv': Plain CSV text with header row (~4x smaller) Use 'compact' or 'csv' when retrieving larger datasets to reduce token usage. fields: Comma-separated column names to include (e.g. 'Area,Year,Value'). Omit to include all columns. Use to reduce response size further.

Examples: # Apple production in Afghanistan 2024 (element 2510 = Production filter code) faostat_get_data('QCL', area='2', item='515', element='2510', year='2024')

# Food security indicators for all African countries
faostat_get_data('FS', area_cs='AFRICA')

# Minimal response — only area, year and value in CSV format
faostat_get_data('QCL', area='231', item='15', element='2510', year='2024',
                 response_format='csv', fields='Area,Year,Value')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domain_codeYes
langNoen
areaNo
elementNo
itemNo
yearNo
area_csNo
element_csNo
item_csNo
year_csNo
show_codesNo
show_unitNo
show_flagsNo
null_valuesNo
limitNo
response_formatNoobjects
fieldsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Given no annotations, the description fully bears the burden. It discloses crucial behavioral nuances like the difference between filter and display codes for elements, response format options with token usage implications, and all parameter defaults. However, it lacks explicit mention of rate limits or authentication, which are not critical for core usage.

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?

The description is long but well-structured with clear sections (purpose, important notes, args, examples). It front-loads critical warnings and efficiently covers all parameters. While not maximally concise, every sentence adds value, and the structure aids comprehension.

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?

For a complex tool with 17 parameters, the description is remarkably complete. It covers all parameters with examples, explains relationships with sibling tools, and provides best practices for large queries and response format optimization. The presence of an output schema reduces the need to explain return values, but the description still gives sufficient context.

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%, so the description must compensate. It provides extensive detail for each of the 17 parameters, including usage context, examples, defaults, and cross-references to other tools (e.g., area codes via faostat_get_codes). This adds significant meaning beyond the bare schema.

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 fetches statistical data from a FAOSTAT domain and is the primary tool for retrieving data values. It distinguishes from sibling tools like faostat_search_codes (for looking up codes) and faostat_get_datasize (for checking query size), ensuring the agent knows when to use this tool.

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?

It provides explicit guidance on when to use faostat_search_codes first if exact codes are unknown, and warns about large domains with instructions to check query size via faostat_get_datasize. It also mandates asking user confirmation when required, and differentiates from alternative tools, covering both when-to-use and when-not-to-use.

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