usda-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@usda-mcp-servercompare calcium in milk and cheese"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Public Hosted Server: https://usda.caseyjhand.com/mcp
Overview
USDA FoodData Central — the US government's authoritative food composition database, spanning roughly 400,000 foods across SR Legacy, Foundation, Survey (FNDDS), and Branded sources. Search foods by keyword or UPC, pull full nutrient profiles with portion scaling, and compare foods side by side from any MCP client. Runs as a stdio process, a local Streamable HTTP server, or the public hosted endpoint above.
Tools
Tool | Description |
| Search foods by keyword, ingredient, or UPC/GTIN across SR Legacy, Foundation, Survey (FNDDS), and Branded data sources |
| Full nutrient profile for one food by FDC ID, with optional per-portion scaling |
| Batch nutrient fetch for 2–20 FDC IDs in a single request |
| Side-by-side nutrient comparison for 2–5 foods, formatted as a markdown table |
| Static FDC nutrient reference table (~150 nutrients) with IDs, names, units, and categories |
Resources
Resource | Description |
| Full nutrient profile for a specific food by FDC ID |
| Complete FDC nutrient reference list |
All resource data is also reachable via tools. Use usda_search_foods to discover FDC IDs before reading food resources.
Related MCP server: nutrition-mcp-server
Capability reference
usda_search_foods tool
Query by keyword, ingredient name, or UPC/GTIN code; optional
dataType[]filter across SR Legacy, Foundation, Survey (FNDDS), and Branded, defaulting to["SR Legacy"](or["Branded"]oncebrandOwneris set)brandOwnerandfoodCategoryfilters narrow results;pageSize(max 50, default 10) andpageNumberpaginateReturns FDC IDs plus a preview of key nutrients (energy, protein, fat, carbs) — not a complete profile
Typed errors:
query_empty(blank query),no_results(nothing matched in the requested data sources)
usda_get_food tool
Full nutrient profile for one
fdcId; optionalnutrients[]filter to specific IDsOptional
quantity+unit(g/oz/lb/kg/serving) scales every value from the FDC per-100g basis;unit="serving"uses the food's first defined portion weightReturns
allPortions[]alongside the scaled resultTyped errors:
not_found(bad FDC ID),quantity_without_unit,no_portion_data(servingrequested but the food has no portion data)
usda_get_foods tool
Batch fetch for 2–20 FDC IDs in one call; values are per-100g only (no portion scaling)
nutrients[]filter strongly recommended — full profiles for 20 foods are largePer-ID partial failure — IDs that return no data land in
failed[]instead of aborting the batch
usda_compare_foods tool
Side-by-side comparison for 2–5 FDC IDs, pivoted one row per nutrient and one column per food
Defaults to 12 commonly compared nutrients (energy, protein, fat, saturated fat, carbs, fiber, total sugars, sodium, potassium, calcium, iron, vitamin C) unless
nutrients[]is givenAll values scaled to a common
quantity+unitbasis (default 100g)Proceeds with the valid foods when some IDs return no data; only throws
too_few_foodswhen fewer than 2 resolveRows where every food is null for that nutrient are filtered out
usda_list_nutrients tool
Static reference table of ~150 tracked FDC nutrients — no API call
Optional
categoryfilter:macronutrients,vitamins,minerals,lipids,amino_acids,otherReturns each nutrient's ID, name, SR reference number, unit, and category — resolve a name to the ID used by
nutrients[]elsewhere
usda://food/{fdcId} resource
Same data as
usda_get_foodwithout portion scaling — full nutrient profile per 100g asapplication/jsonfdcIdmust be a bare positive integer (no sign, leading zero, decimal, or exponent); anything else throwsinvalid_idnot_foundwhen the ID doesn't exist in FDC
usda://nutrients resource
Complete FDC nutrient reference — same content as
usda_list_nutrientswith no category filterServed as
application/jsonwith a 1-hour public cache hint, since the table is bundled at build time and identical for every caller
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
FoodData Central-specific:
Type-safe client for the USDA FoodData Central REST API (
api.nal.usda.gov/fdc/v1)Normalization layer that handles inconsistent API response shapes across search, single-food, and batch endpoints
Batch API endpoint (
/foods) with per-food partial failure reportingHTML response detection (rate-limit proxy returns 200 HTML) with service-unavailable error surfacing
Static nutrient reference dictionary — ~150 nutrients with FDC IDs, SR numbers, units, and categories; no API call required
Agent-friendly output:
Provenance preserved — FDC data source (
dataType) on every food result so callers know whether they're reading curated research data or label-derived branded valuesPartial failure reporting — batch tools (
usda_get_foods,usda_compare_foods) return successes alongside structuredfailed[]/missingData[]entries rather than failing the whole requestCross-reference hints — FDC IDs and tool names in descriptions so agents know exactly which call to make next (search → get → compare workflow)
Getting started
Public Hosted Instance
A public instance is available at https://usda.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
{
"mcpServers": {
"usda-mcp-server": {
"type": "streamable-http",
"url": "https://usda.caseyjhand.com/mcp"
}
}
}Self-Hosted / Local
Add the following to your MCP client configuration file. See data.gov API key signup to generate a free API key.
{
"mcpServers": {
"usda-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/usda-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"USDA_FDC_API_KEY": "your-api-key"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"usda-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/usda-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"USDA_FDC_API_KEY": "your-api-key"
}
}
}
}Or with Docker:
{
"mcpServers": {
"usda-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"-e", "USDA_FDC_API_KEY=your-api-key",
"ghcr.io/cyanheads/usda-mcp-server:latest"
]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 USDA_FDC_API_KEY=your-api-key bun run start:http
# Server listens at http://localhost:3010/mcpPrerequisites
Bun v1.4.0 or higher (or Node.js v24+).
A free USDA FDC API key — register at api.data.gov/signup. Required for food search, lookup, and comparison calls;
usda_list_nutrientsand the static nutrient reference work without it.
Installation
Clone the repository:
git clone https://github.com/cyanheads/usda-mcp-server.gitNavigate into the directory:
cd usda-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env and set USDA_FDC_API_KEYConfiguration
Variable | Description | Default |
| Required for FoodData Central-backed tools (search, get, batch, compare) — not for startup or | — |
| Transport: |
|
| Port for HTTP server. |
|
| Auth mode: |
|
| Log level (RFC 5424). |
|
| Directory for log files (Node.js only). |
|
| Storage backend. |
|
| Enable OpenTelemetry instrumentation (spans, metrics, completion logs). |
|
See .env.example for the full list of optional overrides.
Running the server
Local development
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t usda-mcp-server .
docker run --rm -e USDA_FDC_API_KEY=your-key -p 3010:3010 usda-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/usda-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Directory | Purpose |
|
|
| Server-specific environment variable parsing and validation with Zod ( |
| Tool definitions ( |
| Resource definitions ( |
|
|
| Unit tests mirroring |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storageRegister new tools and resources via the barrels in
src/mcp-server/*/definitions/index.tsWrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
USDA FoodData Central nutrient lookup, FDA recall watch, EU FMCG labelling via remote MCP
USDA FoodData Central nutrition data: search foods, compare macros, and analyze meals.
Unlock the power of food transparency with our Open Food Facts MCP server. Easily look up any food
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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.3MIT
- 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.1 npmMIT
- FlicenseNot gradedqualityCmaintenanceProvides access to USDA FoodData Central database, enabling food search, nutrition details, and comparison for dietary analysis via MCP.5-