Food Data Central MCP Server
Enables AI agents to search the USDA's FoodData Central database and retrieve detailed nutritional information and ingredient lists. It supports comprehensive food data access through keyword searches and structured queries for specific food items.
README
<h1 align="center">Food Data Central MCP Server</h1>
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:
search_foods: Search for foods using keywords with optional filters for data type, brand, date range, etc.get_food_details: Get comprehensive nutritional and ingredient information for a specific food item by FDC IDget_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
-
Install uv if you don't have it:
pip install uv -
Clone this repository:
git clone https://github.com/FelipeAdachi/mcp-food-data-central.git cd food-data-central-mcp -
Create a virtual environment:
uv venv -
Install dependencies:
uv pip install -e . -
Create a
.envfile based onenv.example:cp env.example .env -
Configure your environment variables in the
.envfile (see Configuration section)
Using Docker (Recommended)
-
Build the Docker image:
docker build -t food-data-central-mcp --build-arg PORT=8050 . -
Create a
.envfile based onenv.exampleand 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
- Visit the USDA FoodData Central API Guide
- Sign up for a free API key
- Add the key to your
.envfile asUSDA_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
serverUrlinstead ofurlin 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": {
"command": "docker",
"args": ["run", "--rm", "-i",
"-e", "TRANSPORT",
"-e", "USDA_API_KEY",
"food-data-central-mcp"],
"env": {
"TRANSPORT": "stdio",
"USDA_API_KEY": "YOUR-API-KEY"
}
}
}
}
Usage Examples
Searching for Foods
# Search for cheese products
search_foods(query="cheddar cheese", page_size=10)
# Search for branded foods from a specific company
search_foods(query="yogurt", data_type=["Branded"], brand_owner="Dannon")
# Search with date filtering
search_foods(query="organic apple", start_date="2023-01-01", end_date="2023-12-31")
Getting Food Details
# Get full details for a specific food item
get_food_details(fdc_id=534358)
# Get abridged details with specific nutrients only
get_food_details(fdc_id=534358, format_type="abridged", nutrients=[203, 204, 205])
Getting Multiple Foods
# Get details for multiple foods at once
get_multiple_foods(fdc_ids=[534358, 373052, 616350])
API Reference
The server provides access to the USDA FoodData Central API endpoints:
- Search Foods (
/v1/foods/search) - Food Details (
/v1/food/{fdcId}) - Multiple Foods (
/v1/foods)
All data returned follows the official USDA FoodData Central API schema and includes comprehensive nutritional information, ingredients, serving sizes, and more.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.