# FAOSTAT MCP

Connects AI coding agents to UN agricultural statistics for 245 countries. It lets you retrieve crop, trade, food security, and emissions metrics via chat.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 18
- Author: berba-q
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/berba-q/faostat-mcp
- Updated: 2026-10-02
- HTML: https://affpapa.org/en/nevibecode/mcp/faostat-mcp

## What it does

This server bridges the UN food and agriculture database with coding assistants using 23 purpose-built MCP endpoints. The model handles category selection, filters time series from 1961 onward, and resolves ambiguity via `faostat_search_codes`. A built-in throttle limits traffic to 2 requests per second.

Requests flow through a tiered cache: 20 minutes in memory, 24 hours in SQLite, and optional Redis persistence. Anonymous access is not supported. You need credentials from the FAOSTAT Developer Portal to query the API. You can store your login in the OS keychain with `faostat_setup` or pass it as runtime environment variables.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `FAOSTAT_API_TOKEN`, `FAOSTAT_USERNAME`, `FAOSTAT_PASSWORD` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add faostat-mcp -e FAOSTAT_API_TOKEN=<FAOSTAT_API_TOKEN> -e FAOSTAT_USERNAME=<FAOSTAT_USERNAME> -e FAOSTAT_PASSWORD=<FAOSTAT_PASSWORD> -- uvx faostat-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from faostat-mcp <command>

### Codex

**Platform CLI**
```bash
codex mcp add faostat-mcp --env FAOSTAT_API_TOKEN=<FAOSTAT_API_TOKEN> --env FAOSTAT_USERNAME=<FAOSTAT_USERNAME> --env FAOSTAT_PASSWORD=<FAOSTAT_PASSWORD> -- uvx faostat-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from faostat-mcp <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "faostat-mcp": {
            "command": "uvx",
            "args": [
                "faostat-mcp"
            ],
            "env": {
                "FAOSTAT_API_TOKEN": "<FAOSTAT_API_TOKEN>",
                "FAOSTAT_USERNAME": "<FAOSTAT_USERNAME>",
                "FAOSTAT_PASSWORD": "<FAOSTAT_PASSWORD>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from faostat-mcp <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "faostat-mcp": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "faostat-mcp"
            ],
            "env": {
                "FAOSTAT_API_TOKEN": "<FAOSTAT_API_TOKEN>",
                "FAOSTAT_USERNAME": "<FAOSTAT_USERNAME>",
                "FAOSTAT_PASSWORD": "<FAOSTAT_PASSWORD>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from faostat-mcp <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e FAOSTAT_API_TOKEN=<FAOSTAT_API_TOKEN> -e FAOSTAT_USERNAME=<FAOSTAT_USERNAME> -e FAOSTAT_PASSWORD=<FAOSTAT_PASSWORD> faostat-mcp uvx faostat-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from faostat-mcp <command>

## When to use it
- query global crop yields and harvested acreage across historical dates
- inspect country-level agricultural trade and price metrics
- track greenhouse gas emissions originating from food systems
- evaluate national indicators on undernourishment and food access

## Example prompts
- Compare wheat production volumes between France and Germany from 2015 to 2022 using FAOSTAT.
- Show the agricultural greenhouse gas emission numbers for Brazil over the last five years.
- Run faostat_setup with my credentials to store my login securely.

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89408
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89433
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27669
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49845

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
