
Security News
Ruby's Bundler 4.0.18 Extends Cooldown to bundle lock and bundle cache
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.
@cyanheads/usda-mcp-server
Advanced tools
Search foods, compare nutrients, and look up the full USDA FoodData Central database via MCP. STDIO or Streamable HTTP.
Search foods, compare nutrients, and look up the full USDA FoodData Central database via MCP. STDIO or Streamable HTTP.
Five tools covering the USDA FoodData Central workflow — from discovery to detailed nutrient analysis:
| Tool | Description |
|---|---|
usda_search_foods | Search foods by keyword across SR Legacy, Foundation, Survey FNDDS, and Branded data sources, with nutrient preview and pagination |
usda_get_food | Full nutrient profile for one food by FDC ID, with optional per-portion scaling (g, oz, lb, kg, or serving) |
usda_get_foods | Batch nutrient fetch for 2–20 FDC IDs in a single request; failed IDs reported in failed[] instead of aborting |
usda_compare_foods | Side-by-side nutrient comparison for 2–5 foods, formatted as a markdown table scaled to a common gram basis |
usda_list_nutrients | Static FDC nutrient reference table (~150 nutrients) with IDs, names, units, and categories — no API call required |
usda_search_foodsSearch USDA FoodData Central foods by keyword, UPC/GTIN code, or ingredient.
"Branded" in dataType for packaged products or UPC lookup"General Mills")"Poultry Products", "Vegetables and Vegetable Products")pageSize (up to 50) and pageNumberusda_get_food for the full profileusda_get_foodFull nutrient profile for one food by FDC ID.
nutrients[]) with amounts per 100gquantity + unit to scale values (e.g. quantity=200, unit="g" → per-200g values)unit="serving" scales to the food's first defined portion weightallPortions[]) alongside the serving infonutrients[] to specific IDs strongly reduces context size for common queries (use usda_list_nutrients to look up IDs)usda_get_foodsBatch nutrient fetch for 2–20 FDC IDs.
nutrients[] filter strongly recommended — full profiles for 20 foods are largefailed[] carries IDs that returned no data, so one missing food doesn't abort the batchusda_get_food calls when you already have FDC IDsusda_compare_foodsSide-by-side nutrient comparison for 2–5 foods.
nutrients[] for specific comparisons (e.g. just iron and vitamin C)quantity + unit)usda_list_nutrientsFDC nutrient reference table — all ~150 tracked nutrients.
category filter: macronutrients, vitamins, minerals, lipids, amino_acids, other"vitamin C") to FDC IDs (1162) for use in nutrients[] params| Type | Name | Description |
|---|---|---|
| Resource | usda://food/{fdcId} | Full nutrient profile for a specific food by FDC ID — same data as usda_get_food without portion scaling |
| Resource | usda://nutrients | Complete FDC nutrient reference list — all ~150 tracked nutrients with IDs, names, units, and categories |
All resource data is also reachable via tools. Use usda_search_foods to discover FDC IDs before reading food resources.
Built on @cyanheads/mcp-ts-core:
none, jwt, oauthin-memory, filesystem, Supabase, Cloudflare KV/R2/D1USDA FDC-specific:
api.nal.usda.gov/fdc/v1)/foods) with per-food partial failure reportingAgent-friendly output:
dataType) on every food result so callers know whether they're reading curated research data or label-derived branded valuesusda_get_foods, usda_compare_foods) return successes alongside structured failed[] / missingData[] entries rather than failing the whole requestAdd 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/mcp
git clone https://github.com/cyanheads/usda-mcp-server.git
cd usda-mcp-server
bun install
cp .env.example .env
# edit .env and set USDA_FDC_API_KEY
| Variable | Description | Default |
|---|---|---|
USDA_FDC_API_KEY | Required. USDA FoodData Central API key from api.data.gov. | — |
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | Port for HTTP server. | 3010 |
MCP_AUTH_MODE | Auth mode: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (RFC 5424). | info |
LOGS_DIR | Directory for log files (Node.js only). | <project-root>/logs |
STORAGE_PROVIDER_TYPE | Storage backend. | in-memory |
OTEL_ENABLED | Enable OpenTelemetry instrumentation (spans, metrics, completion logs). | false |
See .env.example for the full list of optional overrides.
Build and run:
# One-time build
bun run rebuild
# Run the built server
bun run start:stdio
# or
bun run start:http
Run 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 build -t usda-mcp-server .
docker run --rm -e USDA_FDC_API_KEY=your-key -p 3010:3010 usda-mcp-server
The 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.
| Directory | Purpose |
|---|---|
src/index.ts | createApp() entry point — registers tools, resources, and inits FdcService. |
src/config | Server-specific environment variable parsing and validation with Zod (USDA_FDC_API_KEY). |
src/mcp-server/tools | Tool definitions (*.tool.ts) — search, get, batch, compare, list-nutrients. |
src/mcp-server/resources | Resource definitions (*.resource.ts) — food profile and nutrient reference. |
src/services/fdc | FdcService — USDA FDC API client, normalization, and static nutrient reference data. |
tests/ | Unit tests mirroring src/ — 50 tests across all tools and resources. |
See CLAUDE.md for development guidelines and architectural rules. The short version:
try/catch in tool logicctx.log for request-scoped logging, ctx.state for tenant-scoped storagesrc/mcp-server/*/definitions/index.tsIssues and pull requests are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
Apache-2.0 — see LICENSE for details.
FAQs
Search foods, compare nutrients, and look up the full USDA FoodData Central database via MCP. STDIO or Streamable HTTP.
We found that @cyanheads/usda-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.