home / mcp / food data central mcp server
Provides access to the USDA FoodData Central API for searching foods and retrieving nutrition data via MCP.
Configuration
View docs{
"mcpServers": {
"felipeadachi-mcp-food-data-central": {
"url": "http://localhost:8050/sse",
"headers": {
"TRANSPORT": "sse",
"USDA_API_KEY": "YOUR_API_KEY"
}
}
}
}You can access the USDA FoodData Central database through this MCP server to search foods, fetch detailed nutrition data, and retrieve information for multiple items. This makes it easy for AI agents to query up-to-date food data and nutrition details via standardized MCP client configurations.
Connect your MCP client to the Food Data Central MCP Server using either a remote HTTP endpoint or a local stdio configuration. Once connected, you can search for foods by keyword, request full nutritional details for a single item, or fetch details for multiple items in one call. Use the three core tools to access data: search_foods, get_food_details, and get_multiple_foods.
- To search foods, provide a query string and optional filters such as data type, brand, or date range. - To get details for a specific food, supply the FDC ID. - To retrieve details for several foods at once, pass a list of FDC IDs up to twenty items.
Prerequisites - Python 3.12 or newer - A USDA FoodData Central API key - Docker is recommended if you plan to run the server in a container - Optional: a virtual environment tool like venv or conda for isolation
Install using Python with uv (recommended for development and experimentation)
pip install uvClone the project, set up a virtual environment, and install dependencies
git clone https://github.com/FelipeAdachi/mcp-food-data-central.git
cd food-data-central-mcp
# Create a virtual environment
uv venv
# Install package in editable mode
uv pip install -e .Create the environment configuration file and provide your API key
cp env.example .env
```
Edit .env to set USDA_API_KEY and other configuration values as neededAlternatively, you can run via Docker (recommended for isolation and ease of use)
docker build -t food-data-central-mcp --build-arg PORT=8050 .
```
Then run with your environment variables configured in a .env file and expose the portYou configure how the MCP server starts by setting environment variables in a .env file. The key variables you’ll typically set are USDA_API_KEY for the API access, TRANSPORT to select between sse or stdio, HOST and PORT for SSE, and any other needed variables.
Run the server with SSE transport after configuring your environment
uv run src/main.pyRun the server with stdio transport by configuring the client to launch the server as a subprocess, then start the server with the provided Python entry point and environment variables
# Example client-driven stdio setup usage is provided in the integration examplesIntegration notes and examples assume you will connect to the server via an MCP client that supports the SSE (server-sent events) transport or the stdio transport, depending on your setup. The server exposes endpoints for searching foods, fetching detailed food information, and retrieving multiple foods in a single request.
Environment variables and MCP configuration details are described in the available configuration guides. Ensure your API key remains secure and is not exposed in client configurations. If you plan to deploy in a container, expose the correct port and ensure network access to the container if you are using the SSE transport.
Search for foods using keywords with optional filters for data type, brand, date range, and other criteria.
Fetch comprehensive nutritional and ingredient information for a specific food item by its FDC ID.
Retrieve detailed information for multiple foods in a single request (up to 20 items).