USDA Nutrition MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
๐ฅ USDA Nutrition MCP Enabled Server
Professional Model Context Protocol (MCP) enabled server for USDA FoodData Central
Transforms 600k+ foods into intelligent nutrition tools for Claude Desktop and other MCP clients
๐ What This Demonstrates
This project showcases professional MCP implementation skills:
โ
Dual Architecture - Both MCP protocol server AND HTTP API
โ
Production Bridge - Smart mcp_bridge.py with hosted/local/custom server support
โ
Three Deployment Options - Hosted service, local development, custom server
โ
Type-Safe Models - Pydantic schemas with proper validation
โ
Docker + Cloud Run - Complete deployment pipeline
Related MCP server: mcp-usda-fdc
๐ Quick Start for Claude Desktop
Option 1: Minimal Installation (Recommended)
Download just the bridge file - no need to clone the entire repository:
# Download the bridge
wget https://raw.githubusercontent.com/zen-apps/mcp-nutrition-tools/main/src/mcp_bridge.py
# Install dependencies
pip install mcp httpxThen add to your Claude Desktop config:
{
"mcpServers": {
"usda-nutrition": {
"command": "python3",
"args": ["/path/to/downloaded/mcp_bridge.py"]
}
}
}Mac Users with Virtual Environment
# Navigate to your project
cd /Users/yourusername/your-project-folder
# Create new venv in the project folder
python3 -m venv venv
# Activate it
source venv/bin/activate
# Install dependencies
pip install mcp httpx
# Test it works
python src/mcp_bridge.py --server-url https://usda-nutrition-mcp-356272800218.us-central1.run.appOption 2: Full Repository (For Development)
{
"mcpServers": {
"usda-nutrition": {
"command": "python3",
"args": ["/path/to/mcp-nutrition-tools/src/mcp_bridge.py"],
"cwd": "/path/to/mcp-nutrition-tools"
}
}
}Option 2: Local Development
{
"mcpServers": {
"usda-nutrition": {
"command": "python3",
"args": [
"/path/to/mcp-nutrition-tools/src/mcp_bridge.py",
"--server-url",
"http://localhost:8080"
],
"cwd": "/path/to/mcp-nutrition-tools"
}
}
}Option 3: Custom Server
{
"mcpServers": {
"usda-nutrition": {
"command": "python3",
"args": [
"/path/to/mcp-nutrition-tools/src/mcp_bridge.py",
"--server-url",
"https://your-server.com"
],
"cwd": "/path/to/mcp-nutrition-tools"
}
}
}See examples/configs/claude_desktop_config_examples.json for detailed configuration examples.
๐ง For Non-Claude Desktop Users
Direct HTTP API
Live API: https://usda-nutrition-mcp-oc46l7ob5a-uc.a.run.app
Documentation: https://usda-nutrition-mcp-oc46l7ob5a-uc.a.run.app/docs
# Search foods
curl -X POST "https://usda-nutrition-mcp-oc46l7ob5a-uc.a.run.app/tools/search_foods" \
-H "Content-Type: application/json" \
-d '{"query": "chicken breast", "page_size": 5}'
# Get nutrition details
curl -X POST "https://usda-nutrition-mcp-oc46l7ob5a-uc.a.run.app/tools/get_food_nutrition" \
-H "Content-Type: application/json" \
-d '{"fdc_id": 171688}'See API_USAGE.md for complete integration examples with Python, JavaScript, LangChain, and OpenAI.
๐ MCP Tools Available
Once configured, Claude Desktop gets these nutrition tools:
search_foods- Search USDA database by textget_food_nutrition- Get detailed nutrition for specific foodcompare_foods- Compare nutrition between multiple foods
Example Claude Interaction
You: "Compare the protein content of chicken breast vs salmon"
Claude: Uses MCP tools automatically:
search_foods("chicken breast")โ Finds FDC ID 171077search_foods("salmon")โ Finds FDC ID 175167compare_foods([171077, 175167])โ Gets comparison dataProvides detailed analysis with recommendations
๐ Architecture Deep Dive
Dual Server Design
Claude Desktop โโ mcp_bridge.py โโ HTTP API โโ USDA FoodData Central
(MCP) โ โ โ
Smart Bridge FastAPI Rate Limited
ClientKey Implementation Details:
src/mcp_server.py- FastMCP protocol serversrc/mcp_http_server.py- FastAPI HTTP serversrc/mcp_bridge.py- Smart bridge with server auto-detectionsrc/usda_client.py- API client with retry logicsrc/models/- Type-safe Pydantic schemas
Smart Bridge Logic
The bridge automatically detects server type and provides appropriate user feedback:
# Hosted service detection
if "usda-nutrition-mcp-oc46l7ob5a-uc.a.run.app" in args.server_url:
print("๐ Using hosted service (1,000 requests/hour shared)")
# Local development
elif "localhost" in args.server_url:
print("๐ Using local server (requires your USDA API key)")๐ฆ Installation & Development
# Clone and setup
git clone https://github.com/zen-apps/mcp-nutrition-tools
cd mcp-nutrition-tools
pip install -r requirements.txt
# Get USDA API key (for local development)
# Visit: https://fdc.nal.usda.gov/api-guide.html
echo "FDC_API_KEY=your_key_here" > .env
# Test MCP server
python -m src.mcp_server
# Test HTTP server
python -m src.mcp_http_server
# Run tests
python -m pytest tests/ -v
# Code quality
ruff check src/
ruff format src/
mypy src/๐ณ Deployment Options
Local Development
# Run HTTP server locally
python -m src.mcp_http_server
# Run with Docker
make upProduction Deployment
# Deploy to Google Cloud Run
export FDC_API_KEY="your_usda_key"
./scripts/deploy-gcp.shThe production deployment includes:
Automatic SSL/HTTPS
Health checks and monitoring
Auto-scaling based on demand
Structured logging
๐ Configuration
Environment Variables
FDC_API_KEY- USDA FoodData Central API key (required for local)ENVIRONMENT- "development" or "production"LOG_LEVEL- Logging level (DEBUG, INFO, etc.)
Rate Limits
Hosted Service: 1,000 requests/hour (shared)
Local Deployment: 1,000 requests/hour (your key)
Enterprise: Contact for higher limits
๐งช Testing Strategy
# Quick connectivity test
python test_quick.py
# Full test suite with mocking
python -m pytest tests/ -v
# Test specific MCP tools
python examples/live_demo.pyThe test suite includes:
USDA API mocking with httpx-mock
Async MCP server testing
Integration test examples
Performance benchmarking
๐ค Contributing
Fork the repository
Create feature branch:
git checkout -b feature/amazing-featureRun tests:
python -m pytest tests/Run linting:
ruff check src/Submit pull request
๐ License
MIT License - see LICENSE file for details.
๐ฏ Ready to use? See examples/configs/claude_desktop_config_examples.json for setup instructions!
๐ Live API: https://usda-nutrition-mcp-oc46l7ob5a-uc.a.run.app/docs
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
USDA FoodData Central nutrient lookup, FDA recall watch, EU FMCG labelling via remote MCP
Nutrition MCP โ wraps Open Food Facts API (free, no auth)
Unofficial Edamam MCP โ wraps three Edamam APIs in one pack: - Nutrition Analysis APIโฆ
Unlock the power of food transparency with our Open Food Facts MCP server. Easily look up any food
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables natural language access to USDA's FoodData Central database with 1M+ foods, supporting search, nutrition facts, food comparison, and daily value calculations.8MIT
- AlicenseNot gradedqualityCmaintenanceProvides tools to search and retrieve USDA Food Data Central information, including food items, nutrients, and food groups, enabling AI agents to query food data through natural language.77 npmMIT
- AlicenseAqualityCmaintenanceMCP server for USDA nutrition data lookup, meal logging, and daily macro tracking.3MIT
- AlicenseAqualityDmaintenanceEnables searching and retrieving nutrition data from the USDA FoodData Central API, with tools for food search, nutrient lookups, and bulk operations.16MIT