# faostat-mcp-server [Health: Active]

**Category:** 🌳 Environment & Nature  
**Repository:** https://github.com/cyanheads/faostat-mcp-server  
**GitHub Stars:** 3  
**npm Downloads (last month):** 1816  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/faostat-mcp-server

## Description
UN FAOSTAT global food & agriculture statistics over a local SQLite mirror, via MCP.

## Tools
Capabilities this server exposes over MCP:

- **faostat_list_domains** — Discover FAOSTAT statistical domains with codes, descriptions, last-update date, upstream row count, and local index status. The entry point — every query keys on a domain code.
- **faostat_resolve_codes** — Resolve human terms to the codes a query needs (areas, items, elements), flagging each area as a country or an aggregate region and carrying its M49 code.
- **faostat_query_observations** — Query a domain's cube by area(s), item(s), element(s), and year range. Returns pages of up to `limit` rows by an `offset` of at most 100,000; with DataCanvas on, a first page whose match exceeds `limit` also stages the whole match to a canvas table.
- **faostat_commodity_profile** — Workflow: assemble top producers, the production trend, and trade flows for one commodity from the production and trade domains in a single call. The elements follow what the item carries: Production, or Stocks for live-animal items. `trade_item_code` ranks trade on another TCL item for crops trade…
- **faostat_dataframe_query** — Run a read-only SQL `SELECT` against the canvas tables staged by the analytical tools.
- **faostat_dataframe_describe** — List the canvas tables staged this session, each with provenance, row count, and column schema.
- **faostat_dataframe_drop** — Drop one staged canvas table before its 2-hour TTL. Opt-in — callable only with `FAOSTAT_DATAFRAME_DROP_ENABLED=true`.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "faostat-mcp-server": {
    "command": "npx",
    "args": ["-y","@cyanheads/faostat-mcp-server"],
    "env": {
      "FAOSTAT_DATAFRAME_DROP_ENABLED": ""
    }
  }
}
```

**Requires environment variables:** `FAOSTAT_DATAFRAME_DROP_ENABLED` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What faostat-mcp-server does

faostat-mcp-server exposes UN FAOSTAT statistics through MCP, using a local SQLite mirror rather than querying the upstream service for every request. The catalog covers domains such as production, trade, food balances, food security, land use, fertilizer, and emissions, with data spanning more than 245 countries and territories from 1961 onward.

The workflow starts with domain discovery. Agents can then resolve natural-language names into the area, item, and element codes required by a query. Observation results include area M49 identifiers, source details where applicable, quality flags, units, and period information. Aggregate areas are excluded by default unless selected explicitly.

## How it works

The server supports both STDIO and Streamable HTTP transport. A typical request first calls `faostat_list_domains` to identify a domain and check whether its local index is ready. `faostat_resolve_codes` narrows human terms to valid codes within that domain, after which `faostat_query_observations` retrieves filtered rows by area, item, element, source, and inclusive year range.

Queries return pages, with a maximum offset of 100,000. Results exceeding the requested page size can be staged in DataCanvas when that feature is enabled. The staged table can be inspected with `faostat_dataframe_describe` and queried using read-only SQL through `faostat_dataframe_query`. Staged tables expire after two hours.

`faostat_commodity_profile` provides a higher-level workflow for one commodity. It combines top producers, an annual production trend, and trade flows from the relevant production and trade domains. For live-animal items, the production-side element is Stocks; crops traded mainly as processed products can use a separate TCL trade item for trade rankings.

## Setup and configuration

The package can be launched through `npx` using the `@cyanheads/faostat-mcp-server` package. Its published client configuration uses `npx -y @cyanheads/faostat-mcp-server`. Installation links are available for Claude Desktop, Cursor, and VS Code. A hosted MCP endpoint is also available at `https://faostat.caseyjhand.com/mcp`.

The optional `FAOSTAT_DATAFRAME_DROP_ENABLED=true` setting enables `faostat_dataframe_drop`, allowing a staged canvas table to be removed before its two-hour expiry. Without that opt-in setting, the drop operation is unavailable.

## Tools and capabilities

- Discover FAOSTAT domains, update dates, row counts, and local index status.
- Resolve areas, items, and elements by text, code, or M49 code.
- Query observations with year, source, area, item, and element filters.
- Preserve qualifiers, quality flags, units, periods, and source-specific rows.
- Generate commodity production and trade profiles.
- Inspect staged canvas schemas and provenance.
- Run read-only SQL `SELECT` statements against staged canvas tables.

## Limitations and notes

Domain and item/element lookups depend on the relevant local index being ready. Observation pages contain at most 1,000 rows per call, and the query offset cannot exceed 100,000; narrower filters or year partitions are needed for deeper result sets. DataCanvas staging is capped at 50,000 rows. Source-specific observations should be compared separately rather than summed when multiple sources are returned. M49 identifiers follow FAO conventions and are not necessarily ISO numeric country codes.

_Full upstream README: https://allmcps.com/mcp/faostat-mcp-server/readme_

