FoodDB - USDA Food Database MCP Server
An MCP server for querying USDA Food Data Central information. It provides tools to search for foods and get detailed nutritional information.
Note: This project was 100% created with Claude AI. No human has directly edited any code files. All development was done through AI-assisted programming.
Data Source
To use this project, you'll need to download the USDA Food Data Central dataset:
- Visit USDA FDC Download Datasets
- Download the "Full Download" package
- Extract the CSV files to the
./datadirectory in this project
Features
- Import USDA Food Data Central CSV files into a SQLite database
- Model Context Protocol (MCP) server for integration with Claude for Desktop and other MCP clients
- Smart keyword-based search for food items
- Semantic vector search using OpenAI embeddings
- Comprehensive nutritional data including calories, macros, and serving sizes
Installation
# Install in development mode
uv pip install -e .
Usage
Initialize the Database
Before using the server, you need to import the USDA data:
# Import data from the default location (./data) with embeddings generation
uv run food init-db
# Custom data and database paths
uv run food init-db --data-dir /path/to/data --db-path custom.sqlite
# Skip embeddings generation
uv run food init-db --no-embeddings
Generate Embeddings
If you need to generate or update embeddings for vector search:
# Generate ALL embeddings for foods that don't have them yet
uv run food generate-embeddings
# Process foods in larger batches (default is 1000)
uv run food generate-embeddings --batch-size 5000
For vector search to work, you need to set the OPENAI_API_KEY environment variable:
export OPENAI_API_KEY=your-api-key
Search for Foods
You can search for foods using the CLI:
# Search for foods matching a query
uv run food search "ice cream" --limit 5
Get Food Information
Get detailed information about a specific food by its ID:
# Display detailed nutrition information for a food
uv run food info 167575
Run the MCP Server
Run the server with the stdio transport (for use with Claude Desktop):
uv run food run-server
Or with the HTTP transport for other clients:
uv run food run-server --transport http --port 8000
Integrating with Claude for Desktop
To use this server with Claude for Desktop, add it to your Claude Desktop configuration at ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"fooddb": {
"command": "uv",
"args": [
"--directory",
"/path/to/fooddb",
"run",
"food",
"run-server"
],
"env": {
"OPENAI_API_KEY": "your-openai-api-key-here"
}
}
}
}
Important:
- Replace
/path/to/fooddbwith the absolute path to your fooddb installation - Replace
your-openai-api-key-herewith your actual OpenAI API key - The
envsection is required for vector search functionality - Without a valid OpenAI API key, only basic text matching searches will work
MCP Tools
The server provides the following MCP tools:
food_search
Search for foods using semantic vector search via embeddings. This can find foods that match the concept even if they don't contain the exact keywords.
food_search(query: str, limit: int = 10, model: str = "text-embedding-3-small") -> List[Dict]
food_info
Get detailed information about a specific food by ID, including nutritional content, portions, and brand information.
food_info(food_id: int) -> str
Development
Running Tests
uv run pytest
Linting
uv run ruff check .
Data Structure
The USDA Food Data Central dataset includes:
- Food: Basic food information (name, category, etc.)
- Nutrient: Definitions of nutrients (calories, protein, etc.)
- FoodNutrient: Mapping of foods to their nutrient values
- FoodPortion: Serving size information for foods
- FoodEmbeddings: Vector embeddings for semantic search
Vector Search
The system uses OpenAI's text-embedding-3-small model to generate vector embeddings for food descriptions. These embeddings are stored in the SQLite database using the sqlite-vec extension, which enables efficient similarity searches.
For vector search functionality:
- Make sure the sqlite-vec extension is installed and available
- Set the OPENAI_API_KEY environment variable
- Generate embeddings during database initialization or with the generate-embeddings command
- Use the semantic_food_search MCP tool for natural language food searches
Recommend MCP Servers 💡
PostHog
Official PostHog MCP Server 🦔
vibe-check-mcp-server
The definitive Vibe Coder's sanity check MCP server: Prevent cascading errors in AI workflows by implementing strategic pattern interrupts. Uses tool call "Vibe Check" with LearnLM 2.0 Flash, fine-tuned for pedagogy and metacognition to enhance complex workflow strategy, and prevents tunnel vision errors.
@ertiqah/linkedin-mcp-runner
This MCP server enables GPT-based assistants like Claude and ChatGPT to access a user's public LinkedIn data, allowing them to analyze past posts, understand writing tone, and assist with content creation, rewriting, and brainstorming.

deepwiki
Official DeepWiki MCP server providing wiki-related tools via SSE and Streamable protocols.
bart6114/my-bear-mcp-server
An MCP server for reading Bear app notes in read-only mode for AI assistants like Claude.
@timlukahorstmann/mcp-weather
A Model Context Protocol (MCP) server that provides hourly and daily weather forecasts using the AccuWeather API.