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 basis, quantity in unit: default 100 g, so unit="oz" alone compares per 100 oz and quantity alone is grams. 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

NameRequiredDescriptionDefault
unitNoUnit for quantity. Default "g". Does not support "serving" (each food's portion weight differs, so a serving basis would not compare equal amounts).g
fdcIdsYesFDC IDs to compare — 2 to 5 foods. Use usda_search_foods to discover IDs.
quantityNoAmount of food, in unit, that every value is scaled to. 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

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. Changed5 schema fields changed
    • changedInput schema / properties / quantity / description
      Previous value: -"Gram basis for comparison. All values scaled to this amount. Must be positive. Default 100."New value: +"Amount of food, in unit, that every value is scaled to. Must be positive. Default 100."
    • changedInput schema / properties / unit / description
      Previous value: -"Unit for quantity. Default \"g\". Does not support \"serving\" (use a fixed gram basis for consistent comparison)."New value: +"Unit for quantity. Default \"g\". Does not support \"serving\" (each food's portion weight differs, so a serving basis would not compare equal amounts)."
    • changedOutput schema / properties / basis / properties / gramWeight / description
      Previous value: -"Gram weight resolved from quantity+unit — all nutrient values are per this many grams."New value: +"Gram weight resolved from quantity and unit — all nutrient values are per this many grams."
    • changedOutput schema / properties / basis / properties / quantity / description
      Previous value: -"Numeric quantity provided in the request."New value: +"Quantity applied, in unit — the requested value or the default 100."
    • changedOutput schema / properties / basis / properties / unit / description
      Previous value: -"Unit provided in the request (g, oz, lb, or kg)."New value: +"Unit applied (g, oz, lb, or kg) — the requested value or the default \"g\"."
  2. 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"
      +]
  3. 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"
      -]
  4. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare a safe read (readOnlyHint=true, openWorldHint=false), and the description goes well beyond by disclosing the return format (markdown table, one row per nutrient, one column per food), the equal-basis scaling rule, and graceful partial-failure behavior including the specific too_few_foods error condition.

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?

Front-loaded with purpose and return format, then behavior, then parameters — good ordering. It is dense and the unit/quantity sentence is slightly convoluted, but nearly every clause carries information an agent needs.

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

Completeness4/5

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

With an output schema present and rich annotations, the description covers what the schema cannot: comparison semantics, defaults, scaling, and partial-failure behavior. Nearly complete; a hint on result ordering or limits would close the last gap, but nothing essential is missing.

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

Parameters5/5

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

Schema coverage is 100%, but the description adds genuinely non-obvious meaning: the unit/quantity interaction ('unit="oz" alone compares per 100 oz and quantity alone is grams') clarifies a scaling rule the schema does not spell out, and it enumerates the default nutrient set and the FDC-ID route for custom nutrients.

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') plus the return shape. It implicitly distinguishes itself from discovery siblings by pointing to usda_search_foods and usda_list_nutrients for ID lookup, so an agent knows this is the comparison step, not a lookup step.

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

Usage Guidelines5/5

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

Gives concrete example questions ('spinach vs kale iron', 'which has more protein?') that define when to use it, and specifies behavior for omitting vs. providing nutrients[]. It also names the discovery tools to use beforehand, leaving little to inference.

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.