Update Food
update_foodEdit one of the user's foods, the way the app's edit does. Use when the user asks to change a food. A food the user owns keeps its id and its diary entries. The diary is a record, so editing a food doesn't change days already logged; recalculating a day brings it up to date. Send only what changes: anything left out stays as it is. There is no way to delete or replace a food here.
On a packaged food, a nutrient edit changes that value. What can follow from it, such as salt from sodium, is only filled in where the food has none: a value it already has stays as it is, so send each one that changes. An ingredient edit changes only the ingredient list. Neither recalculates the rest of the nutrition. Ingredients sends the whole new list, so include the ones that stay: those keep their amounts unless new ones are sent. serving_grams sets the food's serving measure and changes no nutrient. servings and total_weight_g are only for recipes.
On a recipe, an ingredient edit recalculates the nutrition, so each new ingredient needs a food_measure_id and quantity. Nutrients can't be edited directly on a recipe, because they come from its ingredients.
Each nutrient's value is per the food's base amount, in that nutrient's own unit from the components list. Other units are refused.
A food the user doesn't own, such as a catalog food, is never changed: the edit goes on a private copy, the result gives the copy's food id and the original's id as copied_from, and entries already logged stay on the original.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"food_id": "<food_id>",
"request_id": "<request_id>"
},
"name": "update_food"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | A new name, in English. | |
| food_id | Yes | The food to edit. | |
| servings | No | Recipes only: how many servings it makes, a whole number. | |
| nutrients | No | Nutrient values to change, on a packaged food. | |
| request_id | Yes | A new unique string for this action. Reuse it only when retrying the same action. | |
| ingredients | No | The whole new ingredient list, up to 100. | |
| serving_grams | No | Packaged foods only: the grams in one serving. Sets the food's serving measure, and changes no nutrient. | |
| total_weight_g | No | Recipes only: the finished weight in grams. Send this or servings, not both. |