[
  {
    "name": "food_search",
    "title": "Search foods by name",
    "description": "Full-text search (prefix matching) over food names in English, French, German, Italian or Spanish: 15,961 generic foods (USDA, CIQUAL), 430,443 branded products (USDA Branded Foods, English) and 150 dishes. Without a type, generic foods and dishes come before branded products. Returns summaries; fetch a food by id for all values and provenance. (Quota cost: 1 unit.)",
    "inputSchema": {
      "type": "object",
      "properties": {
        "q": {
          "type": "string",
          "minLength": 2,
          "maxLength": 200,
          "description": "Search text"
        },
        "lang": {
          "type": "string",
          "enum": [
            "en",
            "fr",
            "de",
            "it",
            "es",
            "any"
          ],
          "default": "en",
          "description": "Language of the name; non-English names of USDA foods are machine translations (marked as such)"
        },
        "type": {
          "type": "string",
          "enum": [
            "generic",
            "branded",
            "dish"
          ]
        },
        "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "default": 10
        },
        "offset": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000,
          "default": 0
        }
      },
      "required": [
        "q"
      ],
      "additionalProperties": false
    },
    "annotations": {
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false
    }
  },
  {
    "name": "food_get",
    "title": "Get a food by id",
    "description": "All nutrients per 100 g (or per 100 ml for products labelled per ml) with per-value provenance (source dataset, record id, source nutrient id, retrieval date, method), names in five languages with how each was made, portions with gram weights and their sources, and flags. Dishes include their recipe, cooking-yield tier and the computation trail. (Quota cost: 1 unit.)",
    "inputSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^(fdc|ciqual|gtin|dish):[A-Za-z0-9_.-]{1,40}$",
          "description": "fdc:<FDC id>, ciqual:<code>, gtin:<GTIN-14> or dish:<id>"
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "annotations": {
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false
    }
  },
  {
    "name": "food_barcode",
    "title": "Look up a packaged product by barcode",
    "description": "GTIN-8, UPC-A (12), EAN-13 or GTIN-14. The check digit is validated and the code normalised to GTIN-14. Returns the product from USDA Branded Foods with the FDC records behind it. (Quota cost: 1 unit.)",
    "inputSchema": {
      "type": "object",
      "properties": {
        "gtin": {
          "type": "string",
          "pattern": "^[0-9 -]{8,20}$"
        }
      },
      "required": [
        "gtin"
      ],
      "additionalProperties": false
    },
    "annotations": {
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false
    }
  },
  {
    "name": "food_nutrients_for_portion",
    "title": "Nutrients for a portion",
    "description": "Scales per-100 g values to a portion: give grams, or a portion (index or description from the food's portions) and a quantity. Missing values stay null. Products labelled per 100 ml are refused (density unknown). (Quota cost: 1 unit.)",
    "inputSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^(fdc|ciqual|gtin|dish):[A-Za-z0-9_.-]{1,40}$",
          "description": "fdc:<FDC id>, ciqual:<code>, gtin:<GTIN-14> or dish:<id>"
        },
        "grams": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 100000
        },
        "portion": {
          "type": "string",
          "maxLength": 200,
          "description": "Portion index (0-based) or description"
        },
        "quantity": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1000,
          "default": 1
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "annotations": {
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false
    }
  },
  {
    "name": "food_recipe_calculate",
    "title": "Calculate a recipe",
    "description": "Nutrients per 100 g as eaten (and per serving) of a recipe from ingredient foods and grams, with the food dataset's recipe engine (the code that computed its 150 dishes). Weight changes come only from cited sources you name: a cooked record of the same food (convert.to_cooked, by dry-matter balance), FNDDS moisture change, a USDA meat/poultry yield row, a verified AH-102 row, or an SR refuse portion; no yield is ever assumed (T6) and the result's tier says which kind was used. A nutrient missing for an ingredient is taken from a USDA crosswalk-linked record of the same food, else the result is null with a lower bound (never zero, T7). Nutrient numbers in the request are rejected. (Quota cost: 1 unit per 5 ingredients (minimum 1).)",
    "inputSchema": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 200
        },
        "cooked": {
          "type": "boolean",
          "description": "false: no heat step (tier T0); true: cooked (T1-T3 from the references used)"
        },
        "servings": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000
        },
        "ingredients": {
          "type": "array",
          "minItems": 1,
          "maxItems": 60,
          "items": {
            "type": "object",
            "required": [
              "food"
            ],
            "additionalProperties": false,
            "properties": {
              "food": {
                "type": "string",
                "pattern": "^(fdc|ciqual|gtin|fdc_branded):[0-9A-Za-z]{1,20}$",
                "description": "Ingredient food: fdc:<FDC id>, ciqual:<code>, gtin:<GTIN-14> (per-100 g products only) or fdc_branded:<FDC id>"
              },
              "grams": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 100000,
                "description": "Grams as written in the recipe (raw weight)"
              },
              "label": {
                "type": "string",
                "maxLength": 200
              },
              "convert": {
                "type": "object",
                "additionalProperties": false,
                "description": "Enter the ingredient as a cooked record of the same food",
                "properties": {
                  "to_cooked": {
                    "type": "string",
                    "pattern": "^(fdc|ciqual|gtin|fdc_branded):[0-9A-Za-z]{1,20}$",
                    "description": "Ingredient food: fdc:<FDC id>, ciqual:<code>, gtin:<GTIN-14> (per-100 g products only) or fdc_branded:<FDC id>"
                  },
                  "yield": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Weight raw -> cooked from a cited yield (else dry-matter balance between the two records)",
                    "properties": {
                      "fndds_moisture": {
                        "type": "integer",
                        "description": "FNDDS 2021-2023 food code: its recipe moisture change"
                      },
                      "meat_yield_row": {
                        "type": "integer",
                        "description": "Row of the USDA Table of Cooking Yields for Meat and Poultry"
                      },
                      "fat": {
                        "type": "string",
                        "enum": [
                          "drained",
                          "kept"
                        ],
                        "description": "meat_yield_row: 'drained' removes the fat change (only when the method drains fat)"
                      },
                      "ah102_item": {
                        "type": "integer",
                        "description": "Verified row of USDA Agriculture Handbook 102"
                      },
                      "evaporate_all_water": {
                        "type": "boolean",
                        "description": "All water of the ingredient cooks off (flagged as estimated, T3)"
                      },
                      "match": {
                        "type": "string",
                        "enum": [
                          "same_food",
                          "analog"
                        ],
                        "description": "analog: the yield of a similar food (flags the result T3 estimated)"
                      },
                      "sr_refuse_portion": {
                        "type": "object",
                        "required": [
                          "food",
                          "seq"
                        ],
                        "additionalProperties": false,
                        "properties": {
                          "food": {
                            "type": "string",
                            "pattern": "^(fdc|ciqual|gtin|fdc_branded):[0-9A-Za-z]{1,20}$",
                            "description": "Ingredient food: fdc:<FDC id>, ciqual:<code>, gtin:<GTIN-14> (per-100 g products only) or fdc_branded:<FDC id>"
                          },
                          "seq": {
                            "type": "integer",
                            "minimum": 1
                          }
                        },
                        "description": "SR 'yield from 1 lb raw' portion"
                      }
                    }
                  },
                  "edible_ah102": {
                    "type": "integer",
                    "description": "AH-102 item for the edible portion (refuse removed)"
                  },
                  "match": {
                    "type": "string",
                    "enum": [
                      "same_food",
                      "analog"
                    ]
                  }
                }
              },
              "cook": {
                "type": "object",
                "additionalProperties": false,
                "description": "One cited weight-change source (from GET /v1/food/cooking-yields): exactly one of fndds_moisture, meat_yield_row, ah102_item, evaporate_all_water",
                "properties": {
                  "fndds_moisture": {
                    "type": "integer",
                    "description": "FNDDS 2021-2023 food code: its recipe moisture change"
                  },
                  "meat_yield_row": {
                    "type": "integer",
                    "description": "Row of the USDA Table of Cooking Yields for Meat and Poultry"
                  },
                  "fat": {
                    "type": "string",
                    "enum": [
                      "drained",
                      "kept"
                    ],
                    "description": "meat_yield_row: 'drained' removes the fat change (only when the method drains fat)"
                  },
                  "ah102_item": {
                    "type": "integer",
                    "description": "Verified row of USDA Agriculture Handbook 102"
                  },
                  "evaporate_all_water": {
                    "type": "boolean",
                    "description": "All water of the ingredient cooks off (flagged as estimated, T3)"
                  },
                  "match": {
                    "type": "string",
                    "enum": [
                      "same_food",
                      "analog"
                    ],
                    "description": "analog: the yield of a similar food (flags the result T3 estimated)"
                  }
                }
              },
              "retention_code": {
                "type": "integer",
                "minimum": 1,
                "description": "USDA Release 6 nutrient retention code (minerals; alcohol with its energy)"
              },
              "grams_rule": {
                "type": "object",
                "required": [
                  "fndds_ratio"
                ],
                "additionalProperties": false,
                "description": "Grams from an FNDDS recipe ratio (e.g. water absorbed per gram of rice)",
                "properties": {
                  "fndds_ratio": {
                    "type": "object",
                    "required": [
                      "food_code",
                      "ingredient_codes",
                      "per_codes",
                      "of"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "food_code": {
                        "type": "integer"
                      },
                      "ingredient_codes": {
                        "type": "array",
                        "items": {
                          "type": "integer"
                        }
                      },
                      "per_codes": {
                        "type": "array",
                        "items": {
                          "type": "integer"
                        }
                      },
                      "of": {
                        "type": "array",
                        "items": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "description": "0-based indexes of earlier ingredients the ratio applies to"
                      }
                    }
                  },
                  "match": {
                    "type": "string",
                    "enum": [
                      "same_food",
                      "analog"
                    ]
                  }
                }
              }
            }
          }
        },
        "hydrate": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "type": "object",
            "required": [
              "members",
              "like"
            ],
            "additionalProperties": false,
            "properties": {
              "members": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "like": {
                "type": "string",
                "pattern": "^(fdc|ciqual|gtin|fdc_branded):[0-9A-Za-z]{1,20}$",
                "description": "Ingredient food: fdc:<FDC id>, ciqual:<code>, gtin:<GTIN-14> (per-100 g products only) or fdc_branded:<FDC id>"
              },
              "match": {
                "type": "string",
                "enum": [
                  "same_food",
                  "analog"
                ]
              }
            }
          },
          "description": "Bring a group of ingredients to the water content of a cooked record (e.g. a dough)"
        },
        "group_cook": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "type": "object",
            "required": [
              "members",
              "cook"
            ],
            "additionalProperties": false,
            "properties": {
              "members": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "cook": {
                "type": "object",
                "additionalProperties": false,
                "description": "One cited weight-change source (from GET /v1/food/cooking-yields): exactly one of fndds_moisture, meat_yield_row, ah102_item, evaporate_all_water",
                "properties": {
                  "fndds_moisture": {
                    "type": "integer",
                    "description": "FNDDS 2021-2023 food code: its recipe moisture change"
                  },
                  "meat_yield_row": {
                    "type": "integer",
                    "description": "Row of the USDA Table of Cooking Yields for Meat and Poultry"
                  },
                  "fat": {
                    "type": "string",
                    "enum": [
                      "drained",
                      "kept"
                    ],
                    "description": "meat_yield_row: 'drained' removes the fat change (only when the method drains fat)"
                  },
                  "ah102_item": {
                    "type": "integer",
                    "description": "Verified row of USDA Agriculture Handbook 102"
                  },
                  "evaporate_all_water": {
                    "type": "boolean",
                    "description": "All water of the ingredient cooks off (flagged as estimated, T3)"
                  },
                  "match": {
                    "type": "string",
                    "enum": [
                      "same_food",
                      "analog"
                    ],
                    "description": "analog: the yield of a similar food (flags the result T3 estimated)"
                  }
                }
              }
            }
          },
          "description": "Weight change of a group of ingredients (e.g. a sauce reduced)"
        },
        "dish_cook": {
          "type": "object",
          "additionalProperties": false,
          "description": "One cited weight-change source (from GET /v1/food/cooking-yields): exactly one of fndds_moisture, meat_yield_row, ah102_item, evaporate_all_water",
          "properties": {
            "fndds_moisture": {
              "type": "integer",
              "description": "FNDDS 2021-2023 food code: its recipe moisture change"
            },
            "meat_yield_row": {
              "type": "integer",
              "description": "Row of the USDA Table of Cooking Yields for Meat and Poultry"
            },
            "fat": {
              "type": "string",
              "enum": [
                "drained",
                "kept"
              ],
              "description": "meat_yield_row: 'drained' removes the fat change (only when the method drains fat)"
            },
            "ah102_item": {
              "type": "integer",
              "description": "Verified row of USDA Agriculture Handbook 102"
            },
            "evaporate_all_water": {
              "type": "boolean",
              "description": "All water of the ingredient cooks off (flagged as estimated, T3)"
            },
            "match": {
              "type": "string",
              "enum": [
                "same_food",
                "analog"
              ],
              "description": "analog: the yield of a similar food (flags the result T3 estimated)"
            }
          }
        },
        "uncovered_heat_steps": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "type": "string",
            "maxLength": 200
          },
          "description": "Heat steps you know of that have no USDA yield (flags the result T3)"
        },
        "retention_code": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "cooked",
        "ingredients"
      ],
      "additionalProperties": false
    },
    "annotations": {
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false
    }
  },
  {
    "name": "food_cooking_yields",
    "title": "Find cooking-yield references",
    "description": "Rows of the USDA Table of Cooking Yields for Meat and Poultry, verified rows of USDA Agriculture Handbook 102 and FNDDS recipe moisture changes, each with the `reference` to use in a recipe. (Quota cost: 1 unit.)",
    "inputSchema": {
      "type": "object",
      "properties": {
        "q": {
          "type": "string",
          "maxLength": 100
        },
        "source": {
          "type": "string",
          "enum": [
            "meat",
            "ah102",
            "fndds"
          ]
        },
        "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "annotations": {
      "readOnlyHint": true,
      "destructiveHint": false,
      "idempotentHint": true,
      "openWorldHint": false
    }
  }
]
