io.github.cyanheads/usda-mcp-server is an MCP server published by io.github.cyanheads, hosted at usda.caseyjhand.com. When last checked on 2026-11-22 it was working: it answers and lists its tools. It declares 5 tools, including usda_list_nutrients, usda_search_foods, usda_get_food, usda_get_foods, usda_compare_foods.
Search foods, compare nutrients, and look up the full USDA FoodData Central database.
428 connections through 5 shared values. Tap any node.
Look up the FDC nutrient reference table — 269 nutrients with their numeric IDs, names, SR reference numbers, units, and categories. Use to resolve a nutrient name (e.g. "vitamin C") to its FDC ID (1162) before passing it to the nutrients[] filter on other tools. Pass query to match a name, ID, or SR number, and category (macronutrients, vitamins, minerals, lipids, amino_acids, or other) to narrow to one group. The data is static — call once and reuse the IDs.
| Parameter | Type | Description |
|---|---|---|
| query | string | Part of a nutrient name, matched case-insensitively (e.g. "lutein", "18:1"), or a whole FDC nutrient ID ("1062") or SR number ("268"). Combines with category. A blank query is ignored. |
| category | string | Filter to a nutrient category. Options: macronutrients, vitamins, minerals, lipids, amino_acids, other. Omit both category and query to list all 269 tracked nutrients. |
None yet. Changes appear after a server's second daily check.
Squares are this server's values; dots are other servers sharing them. A shared address or publisher is a lead, not proof of a common operator.
Inferred from the host name and headers: what a server runs on, not who runs it.
{
"name": "usda_list_nutrients",
"title": "List USDA Nutrients",
"description": "Look up the FDC nutrient reference table — 269 nutrients with their numeric IDs, names, SR reference numbers, units, and categories. Use to resolve a nutrient name (e.g. \"vitamin C\") to its FDC ID (1162) before passing it to the nutrients[] filter on other tools. Pass query to match a name, ID, or SR number, and category (macronutrients, vitamins, minerals, lipids, amino_acids, or other) to narrow to one group. The data is static — call once and reuse the IDs.",
"inputSchema": {
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"query": {
"type": "string",
"description": "Part of a nutrient name, matched case-insensitively (e.g. \"lutein\", \"18:1\"), or a whole FDC nutrient ID (\"1062\") or SR number (\"268\"). Combines with category. A blank query is ignored."
},
"category": {
"enum": [
"macronutrients",
"vitamins",
"minerals",
"lipids",
"amino_acids",
"other"
],
"type": "string",
"description": "Filter to a nutrient category. Options: macronutrients, vitamins, minerals, lipids, amino_acids, other. Omit both category and query to list all 269 tracked nutrients."
}
},
"additionalProperties": false
},
"outputSchema": {
"type": "object",
"anyOf": [
{
"not": {
"required": [
"error"
]
},
"required": [
"nutrients"
]
},
{
"required": [
"error"
]
}
],
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"description": "JSON-RPC error code for this failure."
},
"data": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"description": "Machine-readable failure mode."
},
"recovery": {
"type": "object",
"required": [
"hint"
],
"properties": {
"hint": {
"type": "string"
}
},
"description": "Actionable next step for the caller.",
"additionalProperties": {}
},
"retryable": {
"type": "boolean",
"description": "Whether retrying may succeed."
}
},
"additionalProperties": {}
},
"message": {
"type": "string",
"description": "Human-readable description of what went wrong."
}
},
"description": "Present when the call failed. Absent on success.",
"additionalProperties": {}
},
"notice": {
"type": "string",
"description": "Present when no nutrient matches the filters: what to try instead."
},
"nutrients": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"name",
"number",
"unit",
"category"
],
"properties": {
"id": {
"type": "number",
"description": "FDC nutrient ID — pass this to nutrients[] params on other tools."
},
"name": {
"type": "string",
"description": "Human-readable nutrient name (e.g. \"Protein\", \"Iron, Fe\")."
},
"unit": {
"type": "string",
"description": "Measurement unit (e.g. \"G\", \"MG\", \"UG\", \"KCAL\")."
},
"number": {
"type": "string",
"description": "SR reference number (legacy identifier, e.g. \"203\"); empty when FDC assigns none."
},
"category": {
"type": "string",
"description": "Nutrient category grouping."
}
},
"description": "A nutrient reference entry with ID, name, unit, and category.",
"additionalProperties": false
},
"description": "Nutrient reference entries matching category and query, or the whole table when both are omitted. Grouped by category, in FDC rank order within each."
},
"effectiveQuery": {
"type": "string",
"description": "The trimmed query, echoed when no nutrient matches it."
}
},
"additionalProperties": false
},
"annotations": {
"readOnlyHint": true,
"openWorldHint": false
}
}Search USDA FoodData Central foods by keyword. Returns matching foods with FDC IDs and 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), preserving distinct fiber and energy measures. Missing nutrients are omitted. Use the returned fdcId with usda_get_food for other nutrients or the full profile, or usda_compare_foods for side-by-side comparisons. When dataType is omitted, defaults to SR Legacy (common whole foods with complete profiles), to Branded when brandOwner is set (only Branded records carry one), or to Branded and Survey (FNDDS) when the query is 8–14 digits alone (a UPC/GTIN barcode or an FNDDS food code). A 12–14-digit barcode with a valid check digit also matches the other digit forms FDC stores it in. Set dataType to ["Branded"] for packaged products. Pass brandOwner (e.g. "General Mills") to narrow branded results.
| Parameter | Type | Description |
|---|---|---|
| query * | string | Search terms — food name, ingredient, or UPC/GTIN code. Examples: "chicken breast raw", "banana", "02114029705". A food matching any one unqualified word counts, so a multi-word query also returns foods holding only some of its words; set requireAllWords, or prefix each word with +, to require them … |
| dataType | array | FDC data sources to search. Omitting this defaults to ["SR Legacy"] (common whole foods, complete nutrient profiles), to ["Branded"] when brandOwner is set, or to ["Branded", "Survey (FNDDS)"] when the query is 8–14 digits alone (a UPC/GTIN barcode or an FNDDS food code). Include "Branded" for packa… |
| pageSize | integer | Number of results per page. Default 10; a larger value returns at most 200 and says so (a server configured with strict limits rejects more than 200). |
| brandOwner | string | Filter branded results by brand owner name (e.g. "General Mills", "Kraft"). Matched as one phrase, ignoring case and punctuation: "Kellogg Company" matches owners holding those words in that order. A value containing * or ? is sent as wildcard terms instead, each word matched on its own (e.g. "Kello… |
| pageNumber | integer | Page number (1-based), counted at the pageSize served. Use with totalPages to paginate. FDC serves only the first 100,000 results of a search, so a page whose pageSize × pageNumber exceeds 100,000 fails with result_window_exceeded, naming the last reachable page, unless it is also past the last page… |
| foodCategory | string | Filter by USDA food category (e.g. "Poultry Products", "Vegetables and Vegetable Products"). Matched as one phrase, ignoring case and punctuation. A value containing * or ? is sent as wildcard terms instead, each word matched on its own (e.g. "Poult*"); a whole word followed by * can match nothing (… |
| requireAllWords | boolean | Match only foods containing every query word (FDC requireAllWords). Default false: a food matching any one word counts. Explicit OR and "quoted phrases" keep their meaning. |
{
"name": "usda_search_foods",
"title": "Search USDA Foods",
"description": "Search USDA FoodData Central foods by keyword. Returns matching foods with FDC IDs and 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), preserving distinct fiber and energy measures. Missing nutrients are omitted. Use the returned fdcId with usda_get_food for other nutrients or the full profile, or usda_compare_foods for side-by-side comparisons. When dataType is omitted, defaults to SR Legacy (common whole foods with complete profiles), to Branded when brandOwner is set (only Branded records carry one), or to Branded and Survey (FNDDS) when the query is 8–14 digits alone (a UPC/GTIN barcode or an FNDDS food code). A 12–14-digit barcode with a valid check digit also matches the other digit forms FDC stores it in. Set dataType to [\"Branded\"] for packaged products. Pass brandOwner (e.g. \"General Mills\") to narrow branded results.",
"inputSchema": {
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"query"
],
"properties": {
"query": {
"type": "string",
"minLength": 1,
"description": "Search terms — food name, ingredient, or UPC/GTIN code. Examples: \"chicken breast raw\", \"banana\", \"02114029705\". A food matching any one unqualified word counts, so a multi-word query also returns foods holding only some of its words; set requireAllWords, or prefix each word with +, to require them all. A query of 8–14 digits alone matches a Branded UPC/GTIN code or an 8-digit Survey (FNDDS) food code. A 12-, 13-, or 14-digit code with a valid GTIN check digit (a printed UPC-A or EAN-13) also matches the other digit forms FDC stores that GTIN in: leading zeros added or dropped down to 12 digits, and the 12-digit form without its check digit. Any other code matches only as FDC stores it, leading zeros included. FDC reads Lucene syntax: \"quoted phrases\", +required and -excluded terms, AND/OR/NOT, wildcards (chick*), fuzzy matches (beeef~), boosts (beef^5), grouping parentheses, field:value, regex terms (/chick.*/), and ranges ([a TO c], {a TO c}). Any other slash, bracket, or brace (1/8, w/o, beef [raw]), any unpaired parenthesis, and every double quote when the query holds an odd number of them are sent as literal characters."
},
"dataType": {
"type": "array",
"items": {
"enum": [
"SR Legacy",
"Foundation",
"Survey (FNDDS)",
"Branded"
],
"type": "string"
},
"description": "FDC data sources to search. Omitting this defaults to [\"SR Legacy\"] (common whole foods, complete nutrient profiles), to [\"Branded\"] when brandOwner is set, or to [\"Branded\", \"Survey (FNDDS)\"] when the query is 8–14 digits alone (a UPC/GTIN barcode or an FNDDS food code). Include \"Branded\" for packaged products. Multiple values allowed."
},
"pageSize": {
"type": "integer",
"default": 10,
"maximum": 9007199254740991,
"minimum": 1,
"description": "Number of results per page. Default 10; a larger value returns at most 200 and says so (a server configured with strict limits rejects more than 200)."
},
"brandOwner": {
"type": "string",
"description": "Filter branded results by brand owner name (e.g. \"General Mills\", \"Kraft\"). Matched as one phrase, ignoring case and punctuation: \"Kellogg Company\" matches owners holding those words in that order. A value containing * or ? is sent as wildcard terms instead, each word matched on its own (e.g. \"Kellog*\"). For other operators, use field syntax in query (e.g. \"+cereal +brandOwner:Kellog*\"). Only Branded records carry one, so setting this defaults dataType to [\"Branded\"] unless dataType is given explicitly."
},
"pageNumber": {
"type": "integer",
"default": 1,
"maximum": 9007199254740991,
"minimum": 1,
"description": "Page number (1-based), counted at the pageSize served. Use with totalPages to paginate. FDC serves only the first 100,000 results of a search, so a page whose pageSize × pageNumber exceeds 100,000 fails with result_window_exceeded, naming the last reachable page, unless it is also past the last page. A page past the last returns empty foods with a notice naming the last reachable page when the query has matches."
},
"foodCategory": {
"type": "string",
"description": "Filter by USDA food category (e.g. \"Poultry Products\", \"Vegetables and Vegetable Products\"). Matched as one phrase, ignoring case and punctuation. A value containing * or ? is sent as wildcard terms instead, each word matched on its own (e.g. \"Poult*\"); a whole word followed by * can match nothing (\"Poultry*\" does), so shorten it. For other operators, use field syntax in query (e.g. chicken -foodCategory:\"Fast Foods\" excludes a category)."
},
"requireAllWords": {
"type": "boolean",
"default": false,
"description": "Match only foods containing every query word (FDC requireAllWords). Default false: a food matching any one word counts. Explicit OR and \"quoted phrases\" keep their meaning."
}
},
"additionalProperties": false
},
"outputSchema": {
"type": "object",
"anyOf": [
{
"not": {
"required": [
"error"
]
},
"required": [
"totalHits",
"currentPage",
"totalPages",
"foods",
"totalCount"
]
},
{
"required": [
"error"
]
}
],
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"description": "JSON-RPC error code for this failure."
},
"data": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"examples": [
"query_empty",
"query_syntax",
"no_results",
"result_window_exceeded",
"retry_deadline_exceeded"
],
"description": "Machine-readable failure mode. Declared by this tool: `query_empty`: The query is empty or contains only whitespace. `query_syntax`: FDC rejected the query syntax, e.g. a dangling operator or a trailing backslash. `no_results`: No foods matched the query in the specified data sources. `result_window_exceeded`: pageSize × pageNumber, at the pageSize served, exceeds the first 100,000 results FDC serves for a search, on a page that holds matches. `retry_deadline_exceeded`: FDC did not answer within the call's 45-second budget, across every attempt. Other values are possible when a failure originates below the handler."
},
"recovery": {
"type": "object",
"required": [
"hint"
],
"properties": {
"hint": {
"type": "string"
}
},
"description": "Actionable next step for the caller.",
"additionalProperties": {}
},
"retryable": {
"type": "boolean",
"description": "Whether retrying may succeed."
}
},
"additionalProperties": {}
},
"message": {
"type": "string",
"description": "Human-readable description of what went wrong."
}
},
"description": "Present when the call failed. Absent on success.",
"additionalProperties": {}
},
"foods": {
"type": "array",
"items": {
"type": "object",
"required": [
"fdcId",
"description",
"dataType",
"nutrients"
],
"properties": {
"fdcId": {
"type": "number",
"description": "FDC ID — pass to usda_get_food, usda_get_foods, or usda_compare_foods."
},
"gtinUpc": {
"type": "string",
"description": "UPC/GTIN barcode as FDC stores it, leading zeros kept (e.g. \"02114029705\"). After a 12–14-digit query it can differ from the query in leading zeros or a missing check digit, naming the stored form that matched. Branded only; a query of exactly these digits finds the product again."
},
"dataType": {
"type": "string",
"description": "FDC data source: SR Legacy, Foundation, Survey (FNDDS), or Branded."
},
"basisUnit": {
"enum": [
"ml",
"g"
],
"type": "string",
"description": "What the nutrient amounts are per 100 of: \"g\" for every non-Branded food and for Branded labels in g, GRM, or GM; \"ml\" for Branded labels in ml or MLT. Absent when the Branded label unit (e.g. IU, MG), or its absence, fixes neither: the amounts are then per 100 label units, basis unverified."
},
"brandName": {
"type": "string",
"description": "Brand name. Present for Branded items only."
},
"nutrients": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"name",
"amount",
"unit"
],
"properties": {
"id": {
"type": "number",
"description": "FDC nutrient ID."
},
"name": {
"type": "string",
"description": "Nutrient name."
},
"unit": {
"type": "string",
"description": "Unit (e.g. \"G\", \"MG\", \"KCAL\")."
},
"amount": {
"type": "number",
"description": "Amount per 100 g, per 100 ml when basisUnit is \"ml\", or per 100 label units when basisUnit is absent."
}
},
"description": "A preview nutrient entry with ID, name, and amount on the food's per-100 basis (basisUnit).",
"additionalProperties": false
},
"description": "Available preview nutrients on the food's per-100 basis (basisUnit): protein (1003), fat (1004), carbohydrate (1005), fiber (1079, and 2033 for AOAC 2011.25 total dietary fiber, a separate measure), and energy (1008, 1062, 2047, 2048). Source order, values and distinct fiber and energy measures are preserved. Missing entries are omitted; use usda_get_food for other nutrients."
},
"brandOwner": {
"type": "string",
"description": "Brand owner name. Present for Branded items only."
},
"description": {
"type": "string",
"description": "USDA food description (e.g. \"Chicken, broilers or fryers, breast, meat only, raw\")."
},
"servingSize": {
"type": "number",
"description": "Serving size from the product label, in servingSizeUnit. Branded only."
},
"foodCategory": {
"type": "string",
"description": "USDA food category (e.g. \"Poultry Products\"). Absent for some branded items."
},
"publishedDate": {
"type": "string",
"description": "Date the food entry was published in FDC."
},
"servingSizeUnit": {
"type": "string",
"description": "Unit for servingSize as FDC reports it (e.g. \"GRM\", \"MLT\", \"IU\"); it sets basisUnit. Branded only."
},
"householdServingFullText": {
"type": "string",
"description": "Serving description as it appears on the label (e.g. \"1 cup\", \"1 oz\"). Branded only."
}
},
"description": "A food item matching the search query.",
"additionalProperties": false
},
"description": "Foods matching the search query."
},
"notice": {
"type": "string",
"description": "Guidance when the requested pageSize is above FDC's maximum of 200 and pages are served at 200, when the requested page is past the last reachable page, or when more foods match than the first 100,000 FDC serves."
},
"totalHits": {
"type": "number",
"description": "Total number of foods matching the query across all pages."
},
"totalCount": {
"type": "number",
"description": "Total foods matching the query across all pages."
},
"totalPages": {
"type": "number",
"description": "Total number of pages at the pageSize served (the one requested, or 200 when more was requested), as FDC counts them. FDC serves only the first 100,000 results of a search, so when totalHits exceeds 100,000, pages past 100,000 / pageSize (rounded down) are out of reach."
},
"currentPage": {
"type": "number",
"description": "Current page number (1-based); the requested page for exhausted pages."
}
},
"additionalProperties": false
},
"annotations": {
"readOnlyHint": true,
"openWorldHint": true
}
}Get the full nutrient profile for one food by FDC ID. Returns all available nutrients (or a filtered subset via the nutrients[] param) with optional per-portion scaling. Use usda_search_foods to discover FDC IDs. Values are per 100 g (basisUnit "g"), except Branded foods FDC reports per 100 ml (basisUnit "ml") or per 100 of a label unit that fixes neither (basisUnit absent, basis unverified). Provide unit, optionally with quantity, to scale all nutrient values from that basis to that amount (e.g. quantity=200, unit="g" → per-200g values); a mass unit is applied to an ml or label-unit basis without conversion, and a notice says so. quantity defaults to 100 for g, oz, lb, and kg and to 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; quantity multiplies that weight. A label in any other unit sets the basis rather than a serving weight, so it requires an explicit mass-unit request. quantity without unit is rejected. Narrow nutrients[] to specific IDs to reduce response size for focused queries. Set provenance=true to add to each nutrient how FDC obtained its value (derivation code, description, and source), its sample count (dataPoints), and the sample min, max, and median scaled with amount, each only where FDC sends it.
| Parameter | Type | Description |
|---|---|---|
| unit | string | Unit for quantity. "serving" uses the weight of the valid portion FDC displays first (lowest sequenceNumber), or a Branded label size in g/GRM/GM (case-insensitive) when no portion exists, multiplied by quantity. Required when quantity is provided. Given alone, scales to 100 g, oz, lb, or kg, or to … |
| fdcId * | integer | FDC ID of the food. Use usda_search_foods to discover IDs. |
| quantity | number | Amount of food, in unit, to scale nutrient values to. Must be positive. Requires unit. Defaults to 100 when unit is g, oz, lb, or kg, and to 1 when unit is "serving". Omit both quantity and unit for the per-100 values FDC reports (per 100 g, or per 100 ml when basisUnit is "ml"). |
| nutrients | array | Filter to specific nutrient IDs (e.g. [1003, 1004, 1005, 1008] for protein, fat, carbs, energy). Use usda_list_nutrients to look up IDs. Omit to return all available nutrients. Requested IDs the food does not report are listed in missingNutrients. |
| provenance | boolean | Add to each nutrient what FDC records about its value: derivation (code, description, source), dataPoints (sample count), and min, max, median (sample spread, scaled with amount). Each is present only where FDC sends it: Survey (FNDDS) foods send none, Branded foods only a derivation. Off by default… |
{
"name": "usda_get_food",
"title": "Get USDA Food",
"description": "Get the full nutrient profile for one food by FDC ID. Returns all available nutrients (or a filtered subset via the nutrients[] param) with optional per-portion scaling. Use usda_search_foods to discover FDC IDs. Values are per 100 g (basisUnit \"g\"), except Branded foods FDC reports per 100 ml (basisUnit \"ml\") or per 100 of a label unit that fixes neither (basisUnit absent, basis unverified). Provide unit, optionally with quantity, to scale all nutrient values from that basis to that amount (e.g. quantity=200, unit=\"g\" → per-200g values); a mass unit is applied to an ml or label-unit basis without conversion, and a notice says so. quantity defaults to 100 for g, oz, lb, and kg and to 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; quantity multiplies that weight. A label in any other unit sets the basis rather than a serving weight, so it requires an explicit mass-unit request. quantity without unit is rejected. Narrow nutrients[] to specific IDs to reduce response size for focused queries. Set provenance=true to add to each nutrient how FDC obtained its value (derivation code, description, and source), its sample count (dataPoints), and the sample min, max, and median scaled with amount, each only where FDC sends it.",
"inputSchema": {
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"fdcId"
],
"properties": {
"unit": {
"enum": [
"g",
"oz",
"lb",
"kg",
"serving"
],
"type": "string",
"description": "Unit for quantity. \"serving\" uses the weight of the valid portion FDC displays first (lowest sequenceNumber), or a Branded label size in g/GRM/GM (case-insensitive) when no portion exists, multiplied by quantity. Required when quantity is provided. Given alone, scales to 100 g, oz, lb, or kg, or to 1 serving."
},
"fdcId": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1,
"description": "FDC ID of the food. Use usda_search_foods to discover IDs."
},
"quantity": {
"type": "number",
"description": "Amount of food, in unit, to scale nutrient values to. Must be positive. Requires unit. Defaults to 100 when unit is g, oz, lb, or kg, and to 1 when unit is \"serving\". Omit both quantity and unit for the per-100 values FDC reports (per 100 g, or per 100 ml when basisUnit is \"ml\").",
"exclusiveMinimum": 0
},
"nutrients": {
"type": "array",
"items": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1
},
"description": "Filter to specific nutrient IDs (e.g. [1003, 1004, 1005, 1008] for protein, fat, carbs, energy). Use usda_list_nutrients to look up IDs. Omit to return all available nutrients. Requested IDs the food does not report are listed in missingNutrients."
},
"provenance": {
"type": "boolean",
"default": false,
"description": "Add to each nutrient what FDC records about its value: derivation (code, description, source), dataPoints (sample count), and min, max, median (sample spread, scaled with amount). Each is present only where FDC sends it: Survey (FNDDS) foods send none, Branded foods only a derivation. Off by default; it makes the response two to three times as large."
}
},
"additionalProperties": false
},
"outputSchema": {
"type": "object",
"anyOf": [
{
"not": {
"required": [
"error"
]
},
"required": [
"fdcId",
"description",
"dataType",
"nutrients"
]
},
{
"required": [
"error"
]
}
],
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"description": "JSON-RPC error code for this failure."
},
"data": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"examples": [
"not_found",
"quantity_without_unit",
"no_portion_data",
"retry_deadline_exceeded"
],
"description": "Machine-readable failure mode. Declared by this tool: `not_found`: The FDC ID does not exist in the database. `quantity_without_unit`: quantity is provided but unit is omitted. `no_portion_data`: unit=\"serving\" was requested but the food has no valid portion or supported Branded gram-label serving. `retry_deadline_exceeded`: FDC did not answer within the call's 45-second budget, across every attempt. Other values are possible when a failure originates below the handler."
},
"recovery": {
"type": "object",
"required": [
"hint"
],
"properties": {
"hint": {
"type": "string"
}
},
"description": "Actionable next step for the caller.",
"additionalProperties": {}
},
"retryable": {
"type": "boolean",
"description": "Whether retrying may succeed."
}
},
"additionalProperties": {}
},
"message": {
"type": "string",
"description": "Human-readable description of what went wrong."
}
},
"description": "Present when the call failed. Absent on success.",
"additionalProperties": {}
},
"fdcId": {
"type": "number",
"description": "FDC ID of the food."
},
"notice": {
"type": "string",
"description": "Basis caveat when a food not reported per 100 g is scaled: the resolved amount was applied to its per-100 ml or unverified label-unit basis without conversion."
},
"gtinUpc": {
"type": "string",
"description": "GTIN/UPC barcode as FDC stores it, leading zeros kept (e.g. \"011110044174\"). Branded items only."
},
"dataType": {
"type": "string",
"description": "FDC data source: SR Legacy, Foundation, Survey (FNDDS), or Branded."
},
"scaledTo": {
"type": "object",
"required": [
"quantity",
"unit",
"gramWeight"
],
"properties": {
"unit": {
"type": "string",
"description": "Unit provided in the request (g, oz, lb, kg, or serving)."
},
"quantity": {
"type": "number",
"description": "Quantity applied — the requested value, or the default for unit (100 for g, oz, lb, kg; 1 for serving)."
},
"gramWeight": {
"type": "number",
"description": "Amount resolved from quantity and unit (for serving, quantity × servingInfo.gramWeight); all nutrient values are per this many grams. With basisUnit \"ml\" it is applied as millilitres, and with no basisUnit as label units, without conversion."
}
},
"description": "Scaling basis when unit was provided. Absent when returning per-100 values.",
"additionalProperties": false
},
"basisUnit": {
"enum": [
"g",
"ml"
],
"type": "string",
"description": "What the per-100 nutrient values are measured in: \"g\" for every non-Branded food and for Branded labels in g/GRM/GM, \"ml\" for Branded labels in ml/MLT. Absent when the label unit (e.g. IU, MG) fixes neither, so the basis is unverified."
},
"brandName": {
"type": "string",
"description": "Brand name. Branded items only."
},
"nutrients": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"name",
"number",
"amount",
"unit"
],
"properties": {
"id": {
"type": "number",
"description": "FDC nutrient ID."
},
"max": {
"type": "number",
"description": "Highest sample value, in the same unit and basis as amount and scaled with it; with provenance=true only. Foundation sends it on most values, SR Legacy on some; Branded and Survey (FNDDS) send none."
},
"min": {
"type": "number",
"description": "Lowest sample value, in the same unit and basis as amount and scaled with it; with provenance=true only. Foundation sends it on most values, SR Legacy on some; Branded and Survey (FNDDS) send none."
},
"name": {
"type": "string",
"description": "Nutrient name (e.g. \"Protein\", \"Energy\", \"Iron, Fe\")."
},
"unit": {
"type": "string",
"description": "Measurement unit (e.g. \"G\", \"MG\", \"KCAL\")."
},
"amount": {
"type": "number",
"description": "Nutrient amount — per 100 of basisUnit, or per scaledTo.gramWeight when unit is provided."
},
"median": {
"type": "number",
"description": "Median sample value, in the same unit and basis as amount and scaled with it; with provenance=true only. Foundation sends it on most values; SR Legacy, Branded, and Survey (FNDDS) send none."
},
"number": {
"type": "string",
"description": "SR reference number (legacy identifier)."
},
"dataPoints": {
"type": "number",
"description": "Number of samples behind the value, as FDC sends it; with provenance=true only. SR Legacy sends it on every value (0 for calculated and assumed values), Foundation on analytical values; Branded and Survey (FNDDS) send none. A count, never scaled."
},
"derivation": {
"type": "object",
"required": [
"code",
"description"
],
"properties": {
"code": {
"type": "string",
"description": "FDC derivation code (e.g. \"A\", \"NC\", \"Z\", \"LCCS\")."
},
"source": {
"type": "string",
"description": "Source category FDC files the derivation under (e.g. \"Analytical or derived from analytical\", \"Calculated or imputed\", \"Assumed zero\"). Absent when FDC sends none."
},
"description": {
"type": "string",
"description": "What the code means, as FDC words it (e.g. \"Analytical\", \"Calculated\", \"Summed\")."
}
},
"description": "How FDC obtained the value; with provenance=true only. Foundation and Branded send one on every value, SR Legacy on some (a measured SR Legacy value can carry only dataPoints), Survey (FNDDS) on none. Absent when FDC sends none, never inferred. Code \"Z\" is an assumed zero, not a measurement.",
"additionalProperties": false
},
"percentDailyValue": {
"type": "number",
"description": "Percent daily value from product label. Branded items only."
}
},
"description": "A single nutrient entry with ID, name, amount, and unit.",
"additionalProperties": false
},
"description": "Nutrient values for this food, per 100 of basisUnit or scaled to the scaledTo basis."
},
"brandOwner": {
"type": "string",
"description": "Brand owner. Branded items only."
},
"allPortions": {
"type": "array",
"items": {
"type": "object",
"required": [
"description",
"gramWeight"
],
"properties": {
"amount": {
"type": "number",
"description": "How many of the described unit gramWeight covers (0.5 for \"0.5 cup\"), when FDC sends one. Absent for Survey (FNDDS) portions, whose description carries the amount."
},
"gramWeight": {
"type": "number",
"description": "Gram weight of this portion."
},
"description": {
"type": "string",
"description": "Portion description (e.g. \"0.5 cup\", \"1 small/regular\")."
}
},
"description": "A named portion for this food.",
"additionalProperties": false
},
"description": "All named portions for this food, in FDC's display order: ascending sequenceNumber, ties as FDC lists them, unnumbered portions last."
},
"description": {
"type": "string",
"description": "Full USDA food name (e.g. \"Chicken, broilers or fryers, breast, meat only, raw\")."
},
"ingredients": {
"type": "string",
"description": "Ingredient list from label. Branded items only."
},
"servingInfo": {
"type": "object",
"required": [
"description",
"gramWeight"
],
"properties": {
"amount": {
"type": "number",
"description": "How many of the described unit gramWeight covers (0.5 for \"0.5 cup\"), when FDC sends one. Absent for Survey (FNDDS) portions, whose description carries the amount, and for a label serving."
},
"gramWeight": {
"type": "number",
"description": "Gram weight of this portion."
},
"description": {
"type": "string",
"description": "Portion description: the Survey (FNDDS) portion text, or the amount, measure unit, and modifier (e.g. \"0.5 cup\"); for a Branded gram label, \"Label serving:\" with its size, unit, and household text."
}
},
"description": "The portion one serving weighs: the first of allPortions (the one FDC displays first), or, when the food has no portion, a Branded gram-label serving identified in its description.",
"additionalProperties": false
},
"servingSize": {
"type": "number",
"description": "Serving size from the product label, in servingSizeUnit. Branded items only."
},
"foodCategory": {
"type": "string",
"description": "USDA food category (e.g. \"Poultry Products\"): the food category for SR Legacy and Foundation, the label category for Branded, the WWEIA category for Survey (FNDDS). Absent when FDC reports none."
},
"publicationDate": {
"type": "string",
"description": "Date this food entry was published in FDC, as YYYY-MM-DD (e.g. \"2019-04-01\"). A date FDC sends in another form is returned as sent."
},
"servingSizeUnit": {
"type": "string",
"description": "Unit for servingSize as FDC reports it (e.g. \"GRM\", \"MLT\", \"IU\"); it sets basisUnit. Branded items only."
},
"missingNutrients": {
"type": "array",
"items": {
"type": "number"
},
"description": "Requested nutrient IDs this food's profile does not report, deduplicated, in request order. Absent when nutrients[] was omitted or every requested ID is present."
},
"householdServingFullText": {
"type": "string",
"description": "Serving as the label words it (e.g. \"1 cup\"). Branded items only."
}
},
"additionalProperties": false
},
"annotations": {
"readOnlyHint": true,
"openWorldHint": false
}
}Fetch nutrient profiles for several foods at once. More efficient than calling usda_get_food N times when you already have multiple FDC IDs. Accepts up to 500 IDs: repeats are dropped, the first 20 distinct IDs are fetched, and the rest are returned in deferredIds for a follow-up call. IDs FDC does not return before the call's deadline (slow Foundation records, most often) or keeps failing on also come back in deferredIds, ahead of those, named in a notice. Values are per 100 of each food's basisUnit, with no portion scaling: per 100 g (basisUnit "g"), except Branded foods FDC reports per 100 ml (basisUnit "ml") or per 100 of a label unit that fixes neither (basisUnit absent, basis unverified). Use the nutrients[] filter to limit response size — strongly recommended for batch calls; requested IDs a food does not report are listed in its missingNutrients. Set provenance=true to add to each nutrient how FDC obtained its value (derivation code, description, and source), its sample count (dataPoints), and the sample min, max, and median, each only where FDC sends it. For side-by-side comparison with a formatted table, use usda_compare_foods instead. Failed IDs (not found or no data) are reported in the failed[] array rather than aborting the entire batch.
| Parameter | Type | Description |
|---|---|---|
| fdcIds * | array | FDC IDs to fetch — 2 to 500 entries (a server configured with strict limits rejects more than 20). Repeats are dropped; the first 20 distinct IDs are fetched and the rest are returned in deferredIds. Use usda_search_foods to discover IDs. |
| nutrients | array | Filter to specific nutrient IDs (e.g. [1003, 1004, 1005, 1008]). Strongly recommended — full profiles can be large. Use usda_list_nutrients to look up IDs. Requested IDs a food does not report are listed in its missingNutrients. |
| provenance | boolean | Add to each nutrient what FDC records about its value: derivation (code, description, source), dataPoints (sample count), and min, max, median (sample spread, per 100 of basisUnit like amount). Each is present only where FDC sends it: Survey (FNDDS) foods send none, Branded foods only a derivation. … |
{
"name": "usda_get_foods",
"title": "Get USDA Foods (Batch)",
"description": "Fetch nutrient profiles for several foods at once. More efficient than calling usda_get_food N times when you already have multiple FDC IDs. Accepts up to 500 IDs: repeats are dropped, the first 20 distinct IDs are fetched, and the rest are returned in deferredIds for a follow-up call. IDs FDC does not return before the call's deadline (slow Foundation records, most often) or keeps failing on also come back in deferredIds, ahead of those, named in a notice. Values are per 100 of each food's basisUnit, with no portion scaling: per 100 g (basisUnit \"g\"), except Branded foods FDC reports per 100 ml (basisUnit \"ml\") or per 100 of a label unit that fixes neither (basisUnit absent, basis unverified). Use the nutrients[] filter to limit response size — strongly recommended for batch calls; requested IDs a food does not report are listed in its missingNutrients. Set provenance=true to add to each nutrient how FDC obtained its value (derivation code, description, and source), its sample count (dataPoints), and the sample min, max, and median, each only where FDC sends it. For side-by-side comparison with a formatted table, use usda_compare_foods instead. Failed IDs (not found or no data) are reported in the failed[] array rather than aborting the entire batch.",
"inputSchema": {
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"fdcIds"
],
"properties": {
"fdcIds": {
"type": "array",
"items": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1
},
"maxItems": 500,
"minItems": 2,
"description": "FDC IDs to fetch — 2 to 500 entries (a server configured with strict limits rejects more than 20). Repeats are dropped; the first 20 distinct IDs are fetched and the rest are returned in deferredIds. Use usda_search_foods to discover IDs."
},
"nutrients": {
"type": "array",
"items": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1
},
"description": "Filter to specific nutrient IDs (e.g. [1003, 1004, 1005, 1008]). Strongly recommended — full profiles can be large. Use usda_list_nutrients to look up IDs. Requested IDs a food does not report are listed in its missingNutrients."
},
"provenance": {
"type": "boolean",
"default": false,
"description": "Add to each nutrient what FDC records about its value: derivation (code, description, source), dataPoints (sample count), and min, max, median (sample spread, per 100 of basisUnit like amount). Each is present only where FDC sends it: Survey (FNDDS) foods send none, Branded foods only a derivation. Off by default; it makes the response two to three times as large."
}
},
"additionalProperties": false
},
"outputSchema": {
"type": "object",
"anyOf": [
{
"not": {
"required": [
"error"
]
},
"required": [
"foods",
"failed"
]
},
{
"required": [
"error"
]
}
],
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"description": "JSON-RPC error code for this failure."
},
"data": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"examples": [
"retry_deadline_exceeded"
],
"description": "Machine-readable failure mode. Declared by this tool: `retry_deadline_exceeded`: FDC did not answer within the call's 45-second budget, across every attempt. Other values are possible when a failure originates below the handler."
},
"recovery": {
"type": "object",
"required": [
"hint"
],
"properties": {
"hint": {
"type": "string"
}
},
"description": "Actionable next step for the caller.",
"additionalProperties": {}
},
"retryable": {
"type": "boolean",
"description": "Whether retrying may succeed."
}
},
"additionalProperties": {}
},
"message": {
"type": "string",
"description": "Human-readable description of what went wrong."
}
},
"description": "Present when the call failed. Absent on success.",
"additionalProperties": {}
},
"foods": {
"type": "array",
"items": {
"type": "object",
"required": [
"fdcId",
"description",
"dataType",
"nutrients"
],
"properties": {
"fdcId": {
"type": "number",
"description": "FDC ID of this food."
},
"dataType": {
"type": "string",
"description": "FDC data source: SR Legacy, Foundation, Survey (FNDDS), or Branded."
},
"basisUnit": {
"enum": [
"g",
"ml"
],
"type": "string",
"description": "What the per-100 nutrient values are measured in: \"g\" for every non-Branded food and for Branded labels in g/GRM/GM, \"ml\" for Branded labels in ml/MLT. Absent when the label unit (e.g. IU, MG) fixes neither, so the basis is unverified."
},
"nutrients": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"name",
"number",
"amount",
"unit"
],
"properties": {
"id": {
"type": "number",
"description": "FDC nutrient ID."
},
"max": {
"type": "number",
"description": "Highest sample value, in the same unit and basis as amount and scaled with it; with provenance=true only. Foundation sends it on most values, SR Legacy on some; Branded and Survey (FNDDS) send none."
},
"min": {
"type": "number",
"description": "Lowest sample value, in the same unit and basis as amount and scaled with it; with provenance=true only. Foundation sends it on most values, SR Legacy on some; Branded and Survey (FNDDS) send none."
},
"name": {
"type": "string",
"description": "Nutrient name."
},
"unit": {
"type": "string",
"description": "Measurement unit (e.g. \"G\", \"MG\", \"KCAL\")."
},
"amount": {
"type": "number",
"description": "Amount per 100 of basisUnit."
},
"median": {
"type": "number",
"description": "Median sample value, in the same unit and basis as amount and scaled with it; with provenance=true only. Foundation sends it on most values; SR Legacy, Branded, and Survey (FNDDS) send none."
},
"number": {
"type": "string",
"description": "SR reference number."
},
"dataPoints": {
"type": "number",
"description": "Number of samples behind the value, as FDC sends it; with provenance=true only. SR Legacy sends it on every value (0 for calculated and assumed values), Foundation on analytical values; Branded and Survey (FNDDS) send none. A count, never scaled."
},
"derivation": {
"type": "object",
"required": [
"code",
"description"
],
"properties": {
"code": {
"type": "string",
"description": "FDC derivation code (e.g. \"A\", \"NC\", \"Z\", \"LCCS\")."
},
"source": {
"type": "string",
"description": "Source category FDC files the derivation under (e.g. \"Analytical or derived from analytical\", \"Calculated or imputed\", \"Assumed zero\"). Absent when FDC sends none."
},
"description": {
"type": "string",
"description": "What the code means, as FDC words it (e.g. \"Analytical\", \"Calculated\", \"Summed\")."
}
},
"description": "How FDC obtained the value; with provenance=true only. Foundation and Branded send one on every value, SR Legacy on some (a measured SR Legacy value can carry only dataPoints), Survey (FNDDS) on none. Absent when FDC sends none, never inferred. Code \"Z\" is an assumed zero, not a measurement.",
"additionalProperties": false
}
},
"description": "A nutrient entry with ID, name, amount, and unit.",
"additionalProperties": false
},
"description": "Nutrient values per 100 of basisUnit."
},
"description": {
"type": "string",
"description": "Full USDA food name (e.g. \"Chicken, broilers or fryers, breast, meat only, raw\")."
},
"servingSizeUnit": {
"type": "string",
"description": "Label serving unit as FDC reports it (e.g. \"GRM\", \"MLT\", \"IU\"); it sets basisUnit. Branded items only."
},
"missingNutrients": {
"type": "array",
"items": {
"type": "number"
},
"description": "Requested nutrient IDs this food's profile does not report, deduplicated, in request order. Absent when nutrients[] was omitted or every requested ID is present."
}
},
"description": "Nutrient profile for one food.",
"additionalProperties": false
},
"description": "Successfully fetched foods."
},
"failed": {
"type": "array",
"items": {
"type": "object",
"required": [
"fdcId",
"error"
],
"properties": {
"error": {
"type": "string",
"description": "Why this ID failed — not found, no data returned, etc."
},
"fdcId": {
"type": "number",
"description": "FDC ID that could not be fetched."
}
},
"description": "A failed food fetch with the FDC ID and error reason.",
"additionalProperties": false
},
"description": "IDs that returned no data. Check these with usda_search_foods to verify they exist."
},
"notice": {
"type": "string",
"description": "Deferral notice when deferredIds is present: how many of the distinct IDs past the first 20 were not fetched, which fetched IDs FDC did not return before the deadline or kept failing on, and the call that fetches them."
},
"deferredIds": {
"type": "array",
"items": {
"type": "number"
},
"description": "Distinct requested IDs this call did not fetch, in request order: any FDC did not return before the call's deadline or kept failing on, then those past the first 20, which were never requested from FDC. foods and failed cover neither. Pass them to usda_get_foods again, or a single one to usda_get_food, with the same nutrients and provenance. Absent when every distinct ID was fetched."
}
},
"additionalProperties": false
},
"annotations": {
"readOnlyHint": true,
"openWorldHint": false
}
}Compare nutrients side-by-side for 2–5 foods. Returns a structured table — one row per nutrient, one column per food — formatted as markdown. Best for "spinach vs kale iron" or "which has more protein?" questions. Accepts up to 500 FDC IDs: repeats are dropped, the first 5 distinct IDs are compared, and the rest are returned in deferredIds without being requested from FDC, with a notice naming the follow-up call. Omit nutrients[] to use the 12 most common defaults (energy, protein, fat, saturated fat, carbs, fiber, sugars, sodium, potassium, calcium, iron, vitamin C); a food that lacks the default energy (1008) or total sugars (2000) value has that cell filled from its equivalent nutrient — energy from 2048, then 2047; sugars from 1063 — and each fill is listed in substitutions. Provide nutrients[] with specific FDC IDs to compare different nutrients; an explicit list is compared as given, repeats dropped, without fills. All values are scaled to the same basis, quantity in unit: default 100 g, so unit="oz" alone compares per 100 oz and quantity alone is grams. A Branded food FDC reports per 100 ml (basisUnit "ml") or per 100 of a label unit that fixes neither (basisUnit absent) is compared on that basis without conversion, and a notice names it. If one or more FDC IDs are not found, the comparison proceeds with the valid foods — only throws too_few_foods when fdcIds holds fewer than 2 distinct IDs or fewer than 2 of the compared IDs return data. IDs FDC does not return before the call's deadline (slow Foundation records, most often) or keeps failing on are left out, listed in deferredIds ahead of any past the first 5, and named in a notice; when that leaves fewer than 2 foods, the call fails with retry_deadline_exceeded instead, or with too_few_foods when even answers for those IDs could not make 2 foods.
| Parameter | Type | Description |
|---|---|---|
| unit | string | Unit for quantity. Default "g". Does not support "serving" (each food's portion weight differs, so a serving basis would not compare equal amounts). |
| fdcIds * | array | FDC IDs to compare — 2 to 500 entries (a server configured with strict limits rejects more than 5). Repeats are dropped; the first 5 distinct IDs are compared and the rest are returned in deferredIds. Use usda_search_foods to discover IDs. |
| quantity | number | Amount of food, in unit, that every value is scaled to. Must be positive. Default 100. |
| nutrients | array | Nutrient IDs to include in the comparison. Defaults to the 12 most common: energy (1008), protein (1003), total fat (1004), saturated fat (1258), carbohydrate (1005), fiber (1079), total sugars (2000), sodium (1093), potassium (1092), calcium (1087), iron (1089), vitamin C (1162). Under the defaults… |
{
"name": "usda_compare_foods",
"title": "Compare USDA Foods",
"description": "Compare nutrients side-by-side for 2–5 foods. Returns a structured table — one row per nutrient, one column per food — formatted as markdown. Best for \"spinach vs kale iron\" or \"which has more protein?\" questions. Accepts up to 500 FDC IDs: repeats are dropped, the first 5 distinct IDs are compared, and the rest are returned in deferredIds without being requested from FDC, with a notice naming the follow-up call. Omit nutrients[] to use the 12 most common defaults (energy, protein, fat, saturated fat, carbs, fiber, sugars, sodium, potassium, calcium, iron, vitamin C); a food that lacks the default energy (1008) or total sugars (2000) value has that cell filled from its equivalent nutrient — energy from 2048, then 2047; sugars from 1063 — and each fill is listed in substitutions. Provide nutrients[] with specific FDC IDs to compare different nutrients; an explicit list is compared as given, repeats dropped, without fills. All values are scaled to the same basis, quantity in unit: default 100 g, so unit=\"oz\" alone compares per 100 oz and quantity alone is grams. A Branded food FDC reports per 100 ml (basisUnit \"ml\") or per 100 of a label unit that fixes neither (basisUnit absent) is compared on that basis without conversion, and a notice names it. If one or more FDC IDs are not found, the comparison proceeds with the valid foods — only throws too_few_foods when fdcIds holds fewer than 2 distinct IDs or fewer than 2 of the compared IDs return data. IDs FDC does not return before the call's deadline (slow Foundation records, most often) or keeps failing on are left out, listed in deferredIds ahead of any past the first 5, and named in a notice; when that leaves fewer than 2 foods, the call fails with retry_deadline_exceeded instead, or with too_few_foods when even answers for those IDs could not make 2 foods.",
"inputSchema": {
"type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"fdcIds"
],
"properties": {
"unit": {
"enum": [
"g",
"oz",
"lb",
"kg"
],
"type": "string",
"default": "g",
"description": "Unit for quantity. Default \"g\". Does not support \"serving\" (each food's portion weight differs, so a serving basis would not compare equal amounts)."
},
"fdcIds": {
"type": "array",
"items": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1
},
"maxItems": 500,
"minItems": 2,
"description": "FDC IDs to compare — 2 to 500 entries (a server configured with strict limits rejects more than 5). Repeats are dropped; the first 5 distinct IDs are compared and the rest are returned in deferredIds. Use usda_search_foods to discover IDs."
},
"quantity": {
"type": "number",
"default": 100,
"description": "Amount of food, in unit, that every value is scaled to. Must be positive. Default 100.",
"exclusiveMinimum": 0
},
"nutrients": {
"type": "array",
"items": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1
},
"description": "Nutrient IDs to include in the comparison. Defaults to the 12 most common: energy (1008), protein (1003), total fat (1004), saturated fat (1258), carbohydrate (1005), fiber (1079), total sugars (2000), sodium (1093), potassium (1092), calcium (1087), iron (1089), vitamin C (1162). Under the defaults, a food missing energy or total sugars has that cell filled from its equivalent nutrient (listed in substitutions); IDs given here are compared as given, repeats dropped. Use usda_list_nutrients to look up other IDs."
}
},
"additionalProperties": false
},
"outputSchema": {
"type": "object",
"anyOf": [
{
"not": {
"required": [
"error"
]
},
"required": [
"basis",
"foods",
"nutrients"
]
},
{
"required": [
"error"
]
}
],
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"basis": {
"type": "object",
"required": [
"quantity",
"unit",
"gramWeight"
],
"properties": {
"unit": {
"type": "string",
"description": "Unit applied (g, oz, lb, or kg) — the requested value or the default \"g\"."
},
"quantity": {
"type": "number",
"description": "Quantity applied, in unit — the requested value or the default 100."
},
"gramWeight": {
"type": "number",
"description": "Gram weight resolved from quantity and unit — every column is per this many grams, except that a food with basisUnit \"ml\" is per this many millilitres and one with no basisUnit per this many label units, compared without conversion."
}
},
"description": "The common scaling basis applied to all nutrient values.",
"additionalProperties": false
},
"error": {
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"description": "JSON-RPC error code for this failure."
},
"data": {
"type": "object",
"properties": {
"reason": {
"type": "string",
"examples": [
"too_few_foods",
"retry_deadline_exceeded"
],
"description": "Machine-readable failure mode. Declared by this tool: `too_few_foods`: fdcIds holds fewer than 2 distinct IDs, or fewer than 2 of the compared IDs returned data, making comparison impossible. `retry_deadline_exceeded`: FDC did not answer within the call's 45-second budget, across every attempt. Other values are possible when a failure originates below the handler."
},
"recovery": {
"type": "object",
"required": [
"hint"
],
"properties": {
"hint": {
"type": "string"
}
},
"description": "Actionable next step for the caller.",
"additionalProperties": {}
},
"retryable": {
"type": "boolean",
"description": "Whether retrying may succeed."
}
},
"additionalProperties": {}
},
"message": {
"type": "string",
"description": "Human-readable description of what went wrong."
}
},
"description": "Present when the call failed. Absent on success.",
"additionalProperties": {}
},
"foods": {
"type": "array",
"items": {
"type": "object",
"required": [
"fdcId",
"description",
"dataType"
],
"properties": {
"fdcId": {
"type": "number",
"description": "FDC ID."
},
"dataType": {
"type": "string",
"description": "FDC data source: SR Legacy, Foundation, Survey (FNDDS), or Branded."
},
"basisUnit": {
"enum": [
"g",
"ml"
],
"type": "string",
"description": "What the per-100 nutrient values are measured in: \"g\" for every non-Branded food and for Branded labels in g/GRM/GM, \"ml\" for Branded labels in ml/MLT. Absent when the label unit (e.g. IU, MG) fixes neither, so the basis is unverified."
},
"description": {
"type": "string",
"description": "Full USDA food name (e.g. \"Spinach, raw\")."
},
"servingSizeUnit": {
"type": "string",
"description": "Label serving unit as FDC reports it (e.g. \"GRM\", \"MLT\", \"IU\"); it sets basisUnit. Branded items only."
}
},
"description": "One of the compared foods.",
"additionalProperties": false
},
"description": "The compared foods, in the same order as the values arrays below."
},
"notice": {
"type": "string",
"description": "Present when deferredIds is, or a compared food is not reported per 100 g. First, how many distinct IDs past the first 5 were not requested, which of the first 5 FDC did not return before the deadline or kept failing on, and the call that fetches them; then the basis caveat naming each food not per 100 g: an ml food compared per basis.gramWeight millilitres, or a food whose per-100 basis is unverified, both without conversion."
},
"nutrients": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"name",
"unit",
"values"
],
"properties": {
"id": {
"type": "number",
"description": "FDC nutrient ID."
},
"name": {
"type": "string",
"description": "Nutrient name (e.g. \"Protein\", \"Energy\")."
},
"unit": {
"type": "string",
"description": "Measurement unit (e.g. \"G\", \"MG\", \"KCAL\")."
},
"values": {
"type": "array",
"items": {
"type": [
"number",
"null"
]
},
"description": "One value per food in the same order as foods[]. null when data is unavailable for that food."
}
},
"description": "One nutrient row with per-food values.",
"additionalProperties": false
},
"description": "Nutrient rows — one entry per requested nutrient, with per-food values in the values[] array."
},
"deferredIds": {
"type": "array",
"items": {
"type": "number"
},
"description": "Distinct requested IDs this call did not compare, in request order: any of the first 5 FDC did not return before the call's deadline or kept failing on, then those past the first 5, which were never requested from FDC. The comparison leaves them out: they appear in neither foods nor missingData. Call usda_compare_foods with them and the same nutrients, quantity, and unit (pair a single one with an ID already compared), or fetch an unanswered one with usda_get_food. Absent when every distinct ID was requested and FDC answered each one."
},
"missingData": {
"type": "array",
"items": {
"type": "object",
"required": [
"fdcId",
"nutrientId"
],
"properties": {
"fdcId": {
"type": "number",
"description": "FDC ID that had missing data."
},
"nutrientId": {
"type": [
"number",
"null"
],
"description": "Nutrient ID that was missing, or null when the entire food was not found."
}
},
"description": "A food or food+nutrient pair where data was unavailable.",
"additionalProperties": false
},
"description": "Foods or food+nutrient pairs where data was unavailable. A cell filled from an equivalent nutrient is listed in substitutions, not here. Absent when all data was present."
},
"substitutions": {
"type": "array",
"items": {
"type": "object",
"required": [
"fdcId",
"requested",
"used"
],
"properties": {
"used": {
"type": "number",
"description": "Nutrient ID the value was taken from: 2048 or 2047 for energy, 1063 for sugars."
},
"fdcId": {
"type": "number",
"description": "FDC ID of the food whose cell was filled."
},
"requested": {
"type": "number",
"description": "Nutrient ID of the row: 1008 (energy) or 2000 (total sugars)."
}
},
"description": "One default-row cell filled from an equivalent nutrient.",
"additionalProperties": false
},
"description": "Default-row cells filled from an equivalent nutrient because the food does not report the row ID, in nutrients[] then foods[] order. Absent when nothing was filled."
}
},
"additionalProperties": false
},
"annotations": {
"readOnlyHint": true,
"openWorldHint": false
}
}USDA FoodData Central (FDC) — authoritative US food composition database (~400K+ foods). Key workflow: usda_search_foods → fdcId → usda_get_food (single), usda_get_foods (batch), or usda_compare_foods (comparison). Use usda_list_nutrients to resolve nutrient names to numeric IDs before filtering.
Names, descriptions and schemas were written by the server and are shown as data.
Shared addresses on big platforms (Cloudflare, Vercel and the like) put unrelated servers together; those are marked shared_infrastructure. A match is a pivot, not a link between operators.