MCP server to provide models context around the USDA's Foundation Foods database
This MCP server can operate in two distinct modes:
- Use case: Local development and Claude Desktop integration
- Command:
./foundation-foods-mcp-server --stdio
- Transport: stdio pipes
- Authentication: None required
- Perfect for: Claude Desktop, local development, testing
- Use case: Remote MCP server accessible over the internet
- Command:
./foundation-foods-mcp-server
(default mode) - Transport: HTTP with JSON-RPC 2.0
- Authentication: Bearer token required (except
/health
endpoint) - Perfect for: Shared deployments, cloud hosting, team access, mcp as a service
Check out the related project noot-app/openfoodfacts-mcp-server for a near identical MCP server with a demo video showcasing its capabilities and how to use it with Claude Desktop.
This MCP server provides access to the USDA Foundation Foods database through three specialized tools, each designed for different use cases and levels of detail.
Basic food search with complete data
- Purpose: Search for foods and get comprehensive food information
- Returns: Complete food details including all available nutrients
- Best for: Detailed nutritional analysis, research, when you need all available data
- Example: Get complete nutritional profile for "milk" including every measured nutrient
Customizable nutrient filtering
- Purpose: Search for foods with customizable nutrient selection
- Returns: Essential nutrient data (name, amount, unit) for specified nutrients only
- Customization: Accepts
nutrients_to_include
parameter to filter which nutrients to return - Best for: Targeted nutritional queries, meal planning, when you want specific nutrients
- Example: Get only protein, calcium, and vitamin D data for "milk"
Fixed high-value nutrients (no customization)
- Purpose: Search with a fixed, optimized set of essential nutrients
- Returns: Default nutrient set
- Optimization: Pre-selected nutrients based on comprehensive data analysis
- Best for: Consistent results, general nutrition tracking, when you want the "best" nutrients without customization
- Example: Get the top nutrients for "milk" - always the same essential nutrients
This setup uses STDIO mode for local Claude Desktop integration.
script/build --simple
Add this to your Claude Desktop MCP settings (~/Library/Application Support/Claude/claude_desktop_config.json
on macOS):
{
"mcpServers": {
"foundationfoods": {
"command": "/path/to/foundation-foods-mcp-server",
"args": ["--stdio"],
"env": {
"FOUNDATIONFOODS_MCP_TOKEN": "your-secret-token",
"DATA_DIR": "/full/path/to/foundation-foods-mcp-server/data",
"ENV": "development"
}
}
}
}
Restart Claude Desktop. The mcp server will automatically start and be ready for food product queries.
This setup uses HTTP mode for remote deployment with authentication.
For production deployment (HTTP mode), configure these environment variables:
# Required: Authentication
FOUNDATIONFOODS_MCP_TOKEN=your-production-secret-token
# Optional: Server configuration
PORT=8080
ENV=production
For remote deployment, run without the --stdio
flag (HTTP mode is the default):
./foundation-foods-mcp-server
This will start an HTTP server on the configured port (default 8080) with:
/health
endpoint (no authentication required)/mcp
endpoint (Bearer token authentication required)
Mode | Command | Use Case | Authentication | Transport |
---|---|---|---|---|
STDIO | ./foundation-foods-mcp-server --stdio |
Claude Desktop, local development | None | stdio pipes |
HTTP | ./foundation-foods-mcp-server |
Remote deployment, shared access | Bearer token | HTTP/JSON-RPC |
Variable | Required | Default | Description |
---|---|---|---|
FOUNDATIONFOODS_MCP_TOKEN |
Yes (HTTP mode) | - | Bearer token for authentication |
PORT |
No | 8080 |
HTTP server port (HTTP mode only) |
ENV |
No | production |
Environment (development/production) |
LOG_LEVEL |
No | INFO |
The log level |
Endpoint | Authentication | Description |
---|---|---|
/health |
None | Health check endpoint |
/mcp |
Bearer token | MCP JSON-RPC 2.0 endpoint |
A cool tip for developing locally, you can actually do this and it will return a result from the MCP server:
echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "search_foundation_foods_and_return_nutrients_simplified", "arguments": {"name": "milk", "limit": 2}}, "id": 1}' | go run ./cmd/foundation-foods-mcp-server --stdio