Recipes phase 5
This commit is contained in:
+27
-1
@@ -1,6 +1,6 @@
|
||||
# TaskNest MCP server
|
||||
|
||||
The Streamable HTTP MCP endpoint exposes the Food and Kitchen API to an AI assistant. The server in `mcp_server.server` is an HTTP adapter: every user operation goes through `/api/v1/` with the connected user's bearer token. It does not read Django models directly.
|
||||
The Streamable HTTP MCP endpoint exposes the Food, Kitchen, and Recipes API to an AI assistant. The server in `mcp_server.server` is an HTTP adapter: every user operation goes through `/api/v1/` with the connected user's bearer token. It does not read Django models directly.
|
||||
|
||||
## Local development
|
||||
|
||||
@@ -64,6 +64,32 @@ Image interpretation belongs to the AI client. For a grocery photograph, identif
|
||||
|
||||
For ambiguous candidates, ask the user to select one or supply more identifying details. Report batch item statuses individually: `added`, `needs_review`, or `skipped`. A batch can return `partial_success`; successful items remain added while failed items do not leave partial product or inventory writes. A changed payload with the same idempotency key returns a conflict.
|
||||
|
||||
## Recipes
|
||||
|
||||
Recipe tools use the connected user's recipes and products. `recipe_search` and `recipe_get` require `food:read`. Creation, updates, deletion, variation, ingredient, and subrecipe tools require `food:write`. Ingredient product IDs must belong to the user. Variations copy ingredients, substitutions, and component links; later edits are independent. Component recipes cannot form cycles.
|
||||
|
||||
Create a recipe, then add ingredients:
|
||||
|
||||
```json
|
||||
{"recipe":{"title":"Oat bowl","default_servings":"2","instructions_markdown":"Mix oats and milk."},"idempotency_key":"recipe-oat-bowl-1"}
|
||||
```
|
||||
|
||||
```json
|
||||
{"recipe_id":"<recipe UUID>","ingredient":{"name":"Oats","quantity":"150","unit":"g","inventory_product_id":"<owned product UUID>","nutrition_product_id":"<owned product UUID>"},"idempotency_key":"oat-ingredient-1"}
|
||||
```
|
||||
|
||||
`recipe_create_variation` accepts `recipe_id`, an optional `title`, and an optional `idempotency_key`. `recipe_subrecipe_add` accepts the parent `recipe_id`, owned `component_id`, positive decimal `quantity` (default 1), `unit` (default `servings`), and an optional `idempotency_key`. `recipe_subrecipe_remove` takes the parent `recipe_id` and returned `subrecipe_id`.
|
||||
|
||||
Inventory deduction is an explicit two-step action. Call `recipe_check_inventory` with the recipe ID and an optional `options` object containing `servings`, `include_optional`, or `substitutions`. It returns shortages, the package deduction plan, and a signed `confirmation` only when stock is ready. After the user confirms that plan, pass its exact `confirmation` and `recipe_id` to `recipe_deduct_inventory`. A repeated confirmation returns the existing operation without deducting twice. `recipe_undo_inventory` takes the returned `stock_use_id` and reverses the deduction when affected packages have not changed. Preview requires `inventory:read`; deduction and undo require `inventory:write`.
|
||||
|
||||
`recipe_log_meal` is a separate `food:write` action. It logs a nutrition snapshot for consumed servings and never deducts inventory. Supply `recipe_id`, `consumed_servings`, `meal`, and an `idempotency_key`; `servings`, `date`, and `time` are optional. Repeat the same key and arguments on retry to avoid duplicate diary entries. A recipe meal can be logged even when inventory is short.
|
||||
|
||||
```json
|
||||
{"recipe_id":"<recipe UUID>","consumed_servings":"1","meal":"dinner","date":"2026-10-12","idempotency_key":"recipe-dinner-2026-10-12-1"}
|
||||
```
|
||||
|
||||
The corresponding HTTP routes are listed in `GET /api/v1/schema/`. Recipe meal dates use the user's local calendar date by default. Inventory deduction never creates a food diary entry as a side effect.
|
||||
|
||||
## Partial inventory use
|
||||
|
||||
`inventory_get_stock` returns owned products, remaining totals, and individual packages. Use a product ID for a definite match; a text query returns candidates. `inventory_preview_consumption` is read only and shows package deductions and any shortage. `inventory_consume` requires a product ID, positive decimal amount, compatible unit, and idempotency key. It uses opened packages first, then best-before date and age. Set `allow_partial` only after the user explicitly accepts a shortage. `inventory_undo_consumption` records a reversal when the affected package quantities have not changed. All four tools enforce the existing inventory read or write scopes through the HTTP API.
|
||||
|
||||
Reference in New Issue
Block a user