Skip to content
MCP server
RegistryRemote

usda-mcp-server MCP Server

Search foods, compare nutrients, and look up the full USDA FoodData Central database.

usda-mcp-server scores 71 (Good), licensed Apache-2.0 and written in TypeScript. It can be reached as a remote MCP endpoint. It declares 7 tools. Filed under Databases. GitHub shows 1 stars. Package registries report about 776 downloads a week. Install configs are generated for 10 clients. Being listed in the registry is not the same as being vendor-official.

by cyanheadsApache-2.0TypeScript1 stars
Trust score
71Good
Trust score 71 of 100, Good

Good trust

71 of 100 from six public signals. Nobody can buy a point.

  • Listed in the official MCP registry.
  • OSI-style license: apache-2.0.
How we score trust
Scorecard

License, quality and maintenance

How grades work
Trust breakdown

Where the 71 comes from

22 + 20 + 5 + 10 + 4 + 10 = 71. Each factor is capped, so no single signal can carry a listing.

Registry22 / 30

Active in the official MCP registry, plus a known vendor namespace.

Registry: 22 of 30 points.
Maintenance20 / 20

How recently the repository saw a commit or release.

Maintenance: 20 of 20 points.
Popularity5 / 20

GitHub stars and weekly downloads, on a log scale.

Popularity: 5 of 20 points.
License10 / 10

A clear, OSI-style open-source license.

License: 10 of 10 points.
Security4 / 10

Not archived, a secure install path, a pinned version.

Security: 4 of 10 points.
Docs10 / 10

A real summary, a README with depth, listed tools.

Docs: 10 of 10 points.

Install

Pick your client, copy the config, paste it in.

Remote auth: No sign-in detected. Our check reached the endpoint without being asked for credentials. Some servers only check keys after connecting, so follow the provider's setup notes. Security tips

Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.

~/Library/Application Support/Claude/claude_desktop_config.json
{  "mcpServers": {    "cyanheads-usda-mcp-server": {      "command": "npx",      "args": [        "-y",        "@cyanheads/usda-mcp-server@0.2.3"      ],      "env": {        "USDA_FDC_API_KEY": "",        "USDA_CLAMP_LIMITS": "true",        "MCP_LOG_LEVEL": "info"      }    }  }}

Environment variables

NameRequiredNotes
USDA_FDC_API_KEYRequiredUSDA FoodData Central API key from data.gov. Required for all food data requests.
USDA_CLAMP_LIMITSOptionalWhen true, an over-limit request is served up to its cap with a notice: usda_get_foods fetches the first 20 distinct FDC IDs and usda_compare_foods compares the first 5, returning the rest as deferredIds, and usda_search_foods serves a pageSize above 200 at 200. false rejects more than 20 usda_get_foods entries, more than 5 usda_compare_foods entries, or a pageSize above 200.
MCP_LOG_LEVELOptionalSets the minimum log level for output (e.g., 'debug', 'info', 'warn').
MCP_TRANSPORT_TYPEOptionalSelects the HTTP transport.
USDA_FDC_API_KEYRequiredUSDA FoodData Central API key from data.gov. Required for all food data requests.
USDA_CLAMP_LIMITSOptionalWhen true, an over-limit request is served up to its cap with a notice: usda_get_foods fetches the first 20 distinct FDC IDs and usda_compare_foods compares the first 5, returning the rest as deferredIds, and usda_search_foods serves a pageSize above 200 at 200. false rejects more than 20 usda_get_foods entries, more than 5 usda_compare_foods entries, or a pageSize above 200.
MCP_HTTP_HOSTOptionalThe hostname for the HTTP server.
MCP_HTTP_PORTOptionalThe port to run the HTTP server on.
MCP_HTTP_ENDPOINT_PATHOptionalThe endpoint path for the MCP server.
MCP_AUTH_MODEOptionalAuthentication mode to use: 'none', 'jwt', or 'oauth'.
MCP_LOG_LEVELOptionalSets the minimum log level for output (e.g., 'debug', 'info', 'warn').

Tools7Tool docs quality grade D

All capabilities

About

Version License Docker MCP SDK npm TypeScript Bun

Install in Claude Desktop Install in Cursor Install in VS Code

Framework

Public Hosted Server: https://usda.caseyjhand.com/mcp


Overview

Nutrition data for roughly 400,000 foods from USDA FoodData Central, the US government's authoritative food composition database. Search by keyword or UPC, pull full nutrient profiles scaled to any portion, and compare foods side by side.

Tools

ToolDescription
usda_search_foodsSearch foods by keyword, ingredient, or UPC/GTIN across SR Legacy, Foundation, Survey (FNDDS), and Branded data sources
usda_get_foodFull nutrient profile for one food by FDC ID, with optional per-portion scaling
usda_get_foodsBatch nutrient fetch for 2–500 FDC IDs, 20 distinct IDs per call
usda_compare_foodsSide-by-side nutrient comparison of up to 5 foods from 2–500 FDC IDs, formatted as a markdown table
usda_list_nutrientsStatic FDC nutrient reference table (269 nutrients) with IDs, names, units, and categories

Resources

ResourceDescription
usda://food/{fdcId}Full nutrient profile for a specific food by FDC ID
usda://nutrientsComplete FDC nutrient reference list
skill://usda-guide/SKILL.mdFood selection, serving-weight, and missing-nutrient guidance for agents

Food profiles and the nutrient reference are also reachable via tools. Use usda_search_foods to discover FDC IDs before reading food resources.

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. Without dataType the search covers ["SR Legacy"], ["Branded"] once brandOwner is set, or ["Branded", "Survey (FNDDS)"] when the query is 8–14 digits alone (a UPC/GTIN barcode or an FNDDS food code); a barcode matches the Branded gtinUpc. A 12-, 13-, or 14-digit code with a valid GTIN check digit also matches the other forms FDC stores that GTIN in (leading zeros added or dropped down to 12 digits, and the 12-digit form without its check digit) in the same call, and each row keeps its stored gtinUpc; any other code matches only as FDC stores it. A barcode query that finds nothing hints at a product-name search with dataType: ["Branded"]
  • A food matching any one query word counts; requireAllWords: true requires every word. "quoted phrases", OR, and the other Lucene operators keep their meaning
  • brandOwner and foodCategory filters match as one phrase, ignoring case and punctuation; a value containing * or ? is sent as wildcard terms, each word matched on its own (Poult*); a whole word followed by * can match nothing (Poultry* does), so shorten it. pageSize (default 10) and pageNumber paginate; a pageSize above FDC's maximum of 200 is served at 200 with a notice, and pages then count at 200. USDA_CLAMP_LIMITS=false rejects it instead
  • Returns FDC IDs plus available preview nutrients: protein (1003), fat (1004), carbohydrate (1005), fiber (1079, and 2033 for AOAC 2011.25 total dietary fiber, a separate measure some Foundation foods report beside or instead of 1079), and energy (1008, 1062, 2047, 2048). Original values, units, order, and distinct fiber and energy measures are preserved; missing entries are omitted. Use usda_get_food for other nutrients or the full profile
  • Each food carries basisUnit — what the nutrient amounts are per 100 of: g, ml for a Branded label in ml or MLT, or absent when the label unit (IU, MG, or none) fixes neither, in which case the amounts are per 100 label units and the basis is unverified. Branded foods also return gtinUpc
  • FDC serves only the first 100,000 results of a search. A page past that window fails with result_window_exceeded (naming the last reachable page); a page past the last page returns empty foods[], the requested page, totals, and a notice with a valid pageNumber when the query has matches
  • Typed errors: query_empty (blank query), query_syntax (FDC rejected the query syntax), no_results (nothing matched in the requested data sources), result_window_exceeded (pageSize × pageNumber, at the pageSize served, beyond the first 100,000 results), retry_deadline_exceeded (FDC did not answer within the call's 45 s budget; retry once)

usda_get_food tool

  • Full nutrient profile for one fdcId; optional nutrients[] filter to specific IDs, with requested IDs the food does not report listed in missingNutrients
  • Values are per 100 of basisUnit: g for every non-Branded food and for Branded labels in g / GRM / GM, ml for Branded labels in ml or MLT, absent when the label unit fixes neither (basis unverified, per 100 label units). Branded foods also return gtinUpc, servingSize, servingSizeUnit, and householdServingFullText
  • Optional unit (g / oz / lb / kg / serving) with an optional quantity scales every value from that per-100 basis; quantity defaults to 100 for mass units and 1 for serving. Serving uses the valid portion FDC displays first (lowest sequenceNumber), or a positive finite Branded label size in g / GRM / GM (case-insensitive) when no portion exists, multiplied by quantity. On an ml or label-unit basis a mass unit is applied to that basis unconverted, and a notice says so
  • Optional provenance: true (default false) adds what FDC sends about how each nutrient value was obtained: derivation (code, description, optional source), dataPoints (samples behind the value), and min, max, median. A key FDC does not send is absent, never 0 or null, and no derivation is inferred; min, max, and median are in the unit and basis of amount and scale with it under quantity and unit, while dataPoints never scales. SR Legacy sends dataPoints on every row, a derivation on some rows, and min/max on some foods; Foundation sends a derivation on every valued row, dataPoints on analytical rows, and min/max/median on most rows; Branded sends only a derivation (source Manufacturer's analytical; partial documentation); Survey (FNDDS) sends none. Derivation code Z is an assumed zero, not a measurement. Each nutrient line in the text output gains a suffix with the same data. The response is two to three times as large
  • servingInfo identifies the resolved portion or label serving and its gram weight; allPortions[] contains actual portion definitions only, in FDC's display order (ascending sequenceNumber, ties as FDC lists them, unnumbered portions last), so servingInfo is the first entry whenever a food has portions. Each portion carries amount (how many of the described unit the gram weight covers) when FDC sends one
  • Typed errors: not_found (bad FDC ID), quantity_without_unit, no_portion_data (no valid portion or supported Branded gram label), retry_deadline_exceeded (FDC did not answer within the call's 45 s budget; retry once). Volume, IU, milligram labels, missing units, and invalid sizes require an explicit mass-unit request; no density is inferred

usda_get_foods tool

  • Batch fetch in one call; accepts 2–500 fdcIds entries, drops repeats, fetches the first 20 distinct IDs, and returns the rest in deferredIds with a notice naming the follow-up call (a single deferred ID goes to usda_get_food) and the nutrients and provenance to carry into it. foods[] and failed[] cover only the fetched IDs. USDA_CLAMP_LIMITS=false rejects more than 20 entries instead
  • The batch is one /foods request. If FDC sends no response headers within 15 s, or leaves the body unfinished 15 s after them (slow Foundation records, most often), each ID is refetched on its own inside the call's 45 s budget, at most 10 in flight across the server. IDs FDC does not return in time, or keeps failing on, join deferredIds ahead of those past the first 20, and the notice names them; usda_get_food can fetch one at a time
  • Values are per 100 of each food's basisUnit (no portion scaling); each entry also carries servingSizeUnit for Branded foods
  • nutrients[] filter strongly recommended — full profiles for 20 foods are large. Requested IDs a food does not report are listed in its missingNutrients
  • Optional provenance: true (default false) adds the same per-nutrient derivation, dataPoints, min, max, and median as usda_get_food, each present only where FDC sends it and in the unit and basis of amount. Code Z is an assumed zero, and Survey (FNDDS) foods carry none of these fields. The response is two to three times as large
  • Per-ID partial failure — IDs that return no data land in failed[] instead of aborting the batch; when every ID is unknown, foods[] is empty and failed[] holds them all
  • Typed error: retry_deadline_exceeded when FDC answered none of the fetched IDs within the call's 45 s budget (retry once, or request fewer foods)

usda_compare_foods tool

  • Side-by-side comparison, pivoted one row per nutrient and one column per food; accepts 2–500 fdcIds entries, drops repeats (and repeats in nutrients[]), compares the first 5 distinct IDs, and returns the rest in deferredIds without requesting them from FDC, with a notice naming the follow-up call (usda_compare_foods with the IDs in deferredIds and the same nutrients, quantity, and unit; a single leftover ID is paired with one already compared). USDA_CLAMP_LIMITS=false rejects more than 5 entries instead
  • Defaults to 12 commonly compared nutrients (energy, protein, fat, saturated fat, carbs, fiber, total sugars, sodium, potassium, calcium, iron, vitamin C) unless nutrients[] is given. Under the defaults, a food missing energy (1008) is filled from 2048, then 2047, and one missing total sugars (2000) from 1063; each fill is listed in substitutions[] (fdcId, requested, used) rather than missingData[]. An explicit nutrients[] is compared as given, without fills
  • All values scaled to a common quantity + unit basis (default 100 g; quantity is an amount in unit, so unit: "oz" alone compares per 100 oz). A food whose basisUnit is ml, or absent, is compared on that basis without conversion and a notice names it
  • Proceeds with the valid foods when some IDs return no data; throws too_few_foods when fdcIds holds fewer than 2 distinct IDs (before any FDC request) or fewer than 2 of the compared IDs resolve. IDs past the first 5 never count toward the two-food minimum
  • IDs among the first 5 that FDC does not return before the call's 45 s deadline, or keeps failing on, are left out and listed in deferredIds ahead of those past the first 5, with a notice; when that leaves fewer than 2 foods, the call fails with retry_deadline_exceeded (retry once, or fetch the IDs with usda_get_food), or with too_few_foods when even answers for the deferred IDs could not make 2 foods
  • Rows where every food is null for that nutrient are filtered out

usda_list_nutrients tool

  • Static reference table of 269 tracked FDC nutrients — no API call
  • Optional category filter: macronutrients, vitamins, minerals, lipids, amino_acids, other
  • Optional query: part of a nutrient name, matched case-insensitively (lutein, 18:1), or a whole FDC nutrient ID (1062) or SR number (268); it combines with category, and a blank query is ignored. No match returns nutrients: [] with a notice saying what to try and the query echoed as effectiveQuery
  • Returns 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_food without portion scaling, with portions in the same display order — full nutrient profile per 100 of basisUnit (per 100 g, or per 100 ml for a Branded food labeled in ml; absent basisUnit means a label unit that fixes neither) as application/json
  • fdcId must be a bare positive integer (no sign, leading zero, decimal, or exponent); anything else throws invalid_id
  • not_found when the ID doesn't exist in FDC; retry_deadline_exceeded when FDC does not answer within the call's 45 s budget

usda://nutrients resource

  • Complete FDC nutrient reference — same content as usda_list_nutrients with no filter
  • Served as application/json with a 1-hour public cache hint, since the table is bundled at build time and identical for every caller

skill://usda-guide/SKILL.md resource

Guidance for matching food records, choosing a serving weight, and reporting incomplete nutrient coverage. The same usda-guide ships with plugin installs, npm, Docker, and the desktop bundle.

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 reporting; a batch that times out is refetched one ID per request, and IDs FDC does not return in time are deferred rather than failing the call
  • HTML response detection (rate-limit proxy returns 200 HTML) with service-unavailable error surfacing
  • Static nutrient reference dictionary — 269 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 values, and, with provenance: true on usda_get_food and usda_get_foods, each nutrient's derivation, sample count, and spread as FDC sends them
  • Partial failure reporting — batch tools (usda_get_foods, usda_compare_foods) return successes alongside structured failed[] / missingData[] / deferredIds[] entries rather than failing the whole request
  • Cross-reference hints — FDC IDs and tool names in descriptions so agents know exactly which call to make next (search → get → compare workflow)

Getting started

Connect to the hosted instance, no install:

claude mcp add --transport http usda-mcp-server https://usda.caseyjhand.com/mcp

Or run it locally:

claude mcp add usda-mcp-server -e USDA_FDC_API_KEY=your-key -- npx -y @cyanheads/usda-mcp-server

For other clients, add this to the MCP config file:

{
  "mcpServers": {
    "usda-mcp-server": {
      "command": "npx",
      "args": ["-y", "@cyanheads/usda-mcp-server"],
      "env": { "USDA_FDC_API_KEY": "your-api-key" }
    }
  }
}

Get a free key at api.data.gov/signup. Food search, lookup, and comparison require it; the static nutrient reference works without it. For Docker or a source build, see Running the server.

Configuration

VariableDescriptionDefault
USDA_FDC_API_KEYRequired for FoodData Central-backed tools (search, get, batch, compare) — not for startup or usda_list_nutrients. Get a free key at api.data.gov.—
USDA_CLAMP_LIMITStrue: an over-limit request is served up to its cap with a notice. usda_get_foods fetches the first 20 distinct IDs and usda_compare_foods compares the first 5, returning the rest as deferredIds; usda_search_foods serves a pageSize above 200 at 200. false: more than 20 usda_get_foods entries, more than 5 usda_compare_foods entries, or a pageSize above 200 is rejected. An empty value reads as unset (true); a value that is not a boolean string fails startup.true
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTPort for HTTP server.3010
MCP_AUTH_MODEAuth mode: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (RFC 5424).info
LOGS_DIRDirectory for log files (Node.js only).<project-root>/logs
STORAGE_PROVIDER_TYPEStorage backend.in-memory
OTEL_ENABLEDEnable OpenTelemetry instrumentation (spans, metrics, completion logs).false

See .env.example for the full list of optional overrides.

Running the server

Requires Bun v1.4.4 or higher (or Node.js v24+).

Local development

git clone https://github.com/cyanheads/usda-mcp-server.git
cd usda-mcp-server && bun install
cp .env.example .env   # set USDA_FDC_API_KEY
  • 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

docker run --rm -e USDA_FDC_API_KEY=your-key -p 3010:3010 ghcr.io/cyanheads/usda-mcp-server:latest

The image defaults to HTTP transport, stateless session mode, and logs to /var/log/usda-mcp-server. For stdio, use docker run -i --rm -e MCP_TRANSPORT_TYPE=stdio -e USDA_FDC_API_KEY=your-key ghcr.io/cyanheads/usda-mcp-server:latest. To build locally, run docker build -t usda-mcp-server .; OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.

Project structure

DirectoryPurpose
src/index.tscreateApp() entry point — registers tools, resources, and inits FdcService.
src/configServer-specific environment variable parsing and validation with Zod (USDA_FDC_API_KEY, USDA_CLAMP_LIMITS).
src/mcp-server/toolsTool definitions (*.tool.ts) — search, get, batch, compare, list-nutrients.
src/mcp-server/resourcesResource definitions (*.resource.ts) — food profile and nutrient reference.
src/services/fdcFdcService — USDA FDC API client, normalization, and static nutrient reference data.
skills/Published guidance for agents calling the server.
tests/Unit tests mirroring src/ — every tool, resource, and the FDC service.

Development guide

See CLAUDE.md for development guidelines and architectural rules. The short version:

  • Handlers throw, framework catches — no try/catch in tool logic
  • Use ctx.log for request-scoped logging, ctx.state for tenant-scoped storage
  • Register new tools and resources via the barrels in src/mcp-server/*/definitions/index.ts
  • Wrap 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 test

License

Apache-2.0 — see LICENSE for details.

Frequently asked questions

What is usda-mcp-server MCP Server?

Search foods, compare nutrients, and look up the full USDA FoodData Central database.

How do I install usda-mcp-server MCP Server in Claude Desktop, Cursor, or VS Code?

Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. usda-mcp-server MCP Server runs locally from the npm package @cyanheads/usda-mcp-server with the command npx -y @cyanheads/usda-mcp-server@0.2.3.

Is usda-mcp-server MCP Server free and open source?

Yes. usda-mcp-server MCP Server is released under the Apache-2.0 license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.

Does usda-mcp-server MCP Server support remote (HTTP) connections?

Yes. usda-mcp-server MCP Server offers a hosted endpoint over Streamable HTTP, so HTTP-capable clients can connect to it without running anything locally.

What tools does usda-mcp-server MCP Server provide?

usda-mcp-server MCP Server provides 7 tools, including ctx.log, not_found, usda_compare_foods, and usda_get_food. See the full tool list for descriptions and parameters.

How is usda-mcp-server MCP Server's trust score calculated?

usda-mcp-server MCP Server scores 71 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.

Reviews

No reviews yet

—Be the first to review

5 star0 reviews at 5 stars
4 star0 reviews at 4 stars
3 star0 reviews at 3 stars
2 star0 reviews at 2 stars
1 star0 reviews at 1 stars

No published reviews yet. Used it? Tell the next person how it went.

Add badge to your README

Paste either snippet into the repository README. The image links to this listing.

Listed on MCPpedia

Top 5 MCP servers

Daily or weekly. Confirm by email, unsubscribe any time.

How often

Manage this listing

Claim this server