Food Data Central MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add -e "USDA_API_KEY=${USDA_API_KEY}" food-data-central -- docker build -t food-data-central-mcp --build-arg PORT=8050 .
Required:USDA_API_KEY+ 3 optional
README.md

Access the USDA's FoodData Central database for nutritional information.

Food Data Central MCP Server

A Model Context Protocol (MCP) server for accessing the USDA's FoodData Central database. This server provides AI agents with the ability to search for foods, get detailed nutritional information, and access comprehensive food data from the USDA's database.

Overview

This project demonstrates how to build an MCP server that enables AI agents to access the USDA FoodData Central API. It allows searching for foods, retrieving detailed nutritional information, and accessing comprehensive food data through keyword search and structured queries.

This project is based on Cole Medin's excellent MCP-Mem0 project and jlfwong's Food Data Central MCP Server.

Features

The server provides three essential food data access tools:

  1. search_foods: Search for foods using keywords with optional filters for data type, brand, date range, etc.
  2. get_food_details: Get comprehensive nutritional and ingredient information for a specific food item by FDC ID
  3. get_multiple_foods: Retrieve detailed information for multiple foods at once (up to 20 items)

Prerequisites

  • Python 3.12+
  • USDA API key (free from FoodData Central)
  • Docker if running the MCP server as a container (recommended)

Installation

Using uv

  1. Install uv if you don't have it:

    pip install uv
    
  2. Clone this repository:

    git clone https://github.com/FelipeAdachi/mcp-food-data-central.git
    cd food-data-central-mcp
    
  3. Create a virtual environment:

    uv venv
    
  4. Install dependencies:

    uv pip install -e .
    
  5. Create a .env file based on env.example:

    cp env.example .env
    
  6. Configure your environment variables in the .env file (see Configuration section)

Using Docker (Recommended)

  1. Build the Docker image:

    docker build -t food-data-central-mcp --build-arg PORT=8050 .
    
  2. Create a .env file based on env.example and configure your environment variables

Configuration

The following environment variables can be configured in your .env file:

Variable Description Example
USDA_API_KEY Your USDA FoodData Central API key your_api_key_here
TRANSPORT Transport protocol (sse or stdio) sse
HOST Host to bind to when using SSE transport 0.0.0.0
PORT Port to listen on when using SSE transport 8050

Getting Your API Key

  1. Visit the USDA FoodData Central API Guide
  2. Sign up for a free API key
  3. Add the key to your .env file as USDA_API_KEY

Running the Server

Using uv

SSE Transport
# Set TRANSPORT=sse in .env then:
uv run src/main.py

The MCP server will essentially be run as an API endpoint that you can then connect to with config shown below.

Stdio Transport

With stdio, the MCP client itself can spin up the MCP server, so nothing to run at this point.

Using Docker

SSE Transport
docker run --env-file .env -p 8050:8050 food-data-central-mcp

The MCP server will essentially be run as an API endpoint within the container that you can then connect to with config shown below.

Stdio Transport

With stdio, the MCP client itself can spin up the MCP server container, so nothing to run at this point.

Integration with MCP Clients

SSE Configuration

Once you have the server running with SSE transport, you can connect to it using this configuration:

{
  "mcpServers": {
    "food-data-central": {
      "transport": "sse",
      "url": "http://localhost:8050/sse"
    }
  }
}

Note for Windsurf users: Use serverUrl instead of url in your configuration:

{
  "mcpServers": {
    "food-data-central": {
      "transport": "sse",
      "serverUrl": "http://localhost:8050/sse"
    }
  }
}

Note for n8n users: Use host.docker.internal instead of localhost since n8n has to reach outside of its own container to the host machine:

So the full URL in the MCP node would be: http://host.docker.internal:8050/sse

Make sure to update the port if you are using a value other than the default 8050.

Python with Stdio Configuration

Add this server to your MCP configuration for Claude Desktop, Windsurf, or any other MCP client:

{
  "mcpServers": {
    "food-data-central": {
      "command": "your/path/to/food-data-central-mcp/.venv/Scripts/python.exe",
      "args": ["your/path/to/food-data-central-mcp/src/main.py"],
      "env": {
        "TRANSPORT": "stdio",
        "USDA_API_KEY": "YOUR-API-KEY"
      }
    }
  }
}

Docker with Stdio Configuration

{
  "mcpServers": {
    "food-data-central": {

Tools (3)

search_foodsSearch for foods using keywords with optional filters for data type, brand, date range, etc.
get_food_detailsGet comprehensive nutritional and ingredient information for a specific food item by FDC ID.
get_multiple_foodsRetrieve detailed information for multiple foods at once (up to 20 items).

Environment Variables

USDA_API_KEYrequiredYour USDA FoodData Central API key
TRANSPORTTransport protocol (sse or stdio)
HOSTHost to bind to when using SSE transport
PORTPort to listen on when using SSE transport

Configuration

claude_desktop_config.json
{"mcpServers": {"food-data-central": {"command": "python", "args": ["path/to/src/main.py"], "env": {"TRANSPORT": "stdio", "USDA_API_KEY": "YOUR-API-KEY"}}}}

Try it

Search for 'almonds' and give me the nutritional breakdown for the first result.
What are the ingredients in the food item with FDC ID 123456?
Compare the nutritional content of these three food items: 111, 222, and 333.
Find organic peanut butter brands using the search tool.

Frequently Asked Questions

What are the key features of Food Data Central?

Search for food items using keywords and filters. Retrieve detailed nutritional information for specific foods. Access ingredient lists for food items. Batch retrieval of nutritional data for up to 20 items.

What can I use Food Data Central for?

Building diet tracking applications that require verified USDA nutritional data. Analyzing ingredient lists for specific dietary restrictions or allergens. Comparing nutritional profiles of different food brands for research. Automating the collection of food data for health and wellness AI assistants.

How do I install Food Data Central?

Install Food Data Central by running: uv pip install -e .

What MCP clients work with Food Data Central?

Food Data Central works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Food Data Central docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare