Skip to main content
Glama

Compare USDA Foods

usda_compare_foods
Read-only

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. Omit nutrients[] to use the 12 most common defaults (energy, protein, fat, saturated fat, carbs, fiber, sugars, sodium, potassium, calcium, iron, vitamin C); provide nutrients[] with specific FDC IDs to compare different nutrients. All values are scaled to the same gram basis (default 100g). If one or more FDC IDs are not found, the comparison proceeds with the valid foods — only throws too_few_foods when fewer than 2 IDs return data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
unitNoUnit for quantity. Default "g". Does not support "serving" (use a fixed gram basis for consistent comparison).g
fdcIdsYesFDC IDs to compare — 2 to 5 foods. Use usda_search_foods to discover IDs.
quantityNoGram basis for comparison. All values scaled to this amount. Must be positive. Default 100.
nutrientsNoNutrient 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). Use usda_list_nutrients to look up other IDs.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
basisNoThe common scaling basis applied to all nutrient values.
errorNoPresent when the call failed. Absent on success.
foodsNoThe compared foods, in the same order as the values arrays below.
nutrientsNoNutrient rows — one entry per requested nutrient, with per-food values in the values[] array.
missingDataNoFoods or food+nutrient pairs where data was unavailable. Absent when all data was present.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • removedOutput schema / properties / missingData / items / properties / nutrientId / anyOf
      Removed value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / missingData / items / properties / nutrientId / type
      Added value: +[
      +  "number",
      +  "null"
      +]
    • removedOutput schema / properties / nutrients / items / properties / values / items / anyOf
      Removed value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / nutrients / items / properties / values / items / type
      Added value: +[
      +  "number",
      +  "null"
      +]
  2. Changed6 schema fields changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / additionalProperties
      Added value: +false
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedOutput schema / anyOf
      Added value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "basis",
      +      "foods",
      +      "nutrients"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / error
      Added value: +{
      +  "additionalProperties": {},
      +  "description": "Present when the call failed. Absent on success.",
      +  "properties": {
      +    "code": {
      +      "description": "JSON-RPC error code for this failure.",
      +      "maximum": 9007199254740991,
      +      "minimum": -9007199254740991,
      +      "type": "integer"
      +    },
      +    "data": {
      +      "additionalProperties": {},
      +      "properties": {
      +        "reason": {
      +          "description": "Machine-readable failure mode. Declared by this tool: `too_few_foods`: Fewer than 2 of the provided FDC IDs returned data, making comparison impossible. Other values are possible when a failure originates below the handler.",
      +          "examples": [
      +            "too_few_foods"
      +          ],
      +          "type": "string"
      +        },
      +        "recovery": {
      +          "additionalProperties": {},
      +          "description": "Actionable next step for the caller.",
      +          "properties": {
      +            "hint": {
      +              "type": "string"
      +            }
      +          },
      +          "required": [
      +            "hint"
      +          ],
      +          "type": "object"
      +        },
      +        "retryable": {
      +          "description": "Whether retrying may succeed.",
      +          "type": "boolean"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "message": {
      +      "description": "Human-readable description of what went wrong.",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "code",
      +    "message"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / required
      Removed value: -[
      -  "basis",
      -  "foods",
      -  "nutrients"
      -]
  3. First observed

TDQS

A4.4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description adds substantial behavioral detail beyond that: all values are scaled to a common gram basis, results are returned as a markdown table, missing FDC IDs are tolerated, and only fewer than 2 valid foods triggers too_few_foods. This is high-value behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded: purpose first, then use cases, then behavior, then fallback handling. It is slightly longer than needed because it repeats the full default nutrient ID list already present in the schema, but each sentence otherwise earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite a rich input schema and output schema, the description covers all needed invocation details: valid food count, nutrient selection, gram scaling, discovery pathways to sibling tools, and graceful degradation when invalid IDs are supplied. An agent has everything needed to select and call the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description reinforces parameter behavior by mentioning the default nutrient list, the 100g basis, and the use of search/list tools to discover IDs, but most of this is already present in the input schema descriptions, so it adds limited extra meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: "Compare nutrients side-by-side for 2–5 foods." It also distinguishes itself from sibling tools by describing the multi-food comparison and markdown table output, so an agent knows it is not usda_get_food, usda_search_foods, or usda_list_nutrients.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly frames when to use it: "Best for 'spinach vs kale iron' or 'which has more protein?' questions." It also names sibling tools as discovery helpers (usda_search_foods, usda_list_nutrients), giving clear context, though it does not explicitly exclude single-food alternatives like usda_get_food.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.