From d118726d3010d5b0133c7665fc20008c055f2757 Mon Sep 17 00:00:00 2001 From: Tom Flux Date: Tue, 23 Jun 2026 21:07:18 +0100 Subject: Phase 3a: close the Django API gaps for the MCP server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend prerequisites for the FastMCP service (mcp.md §6) — no model changes, no migration. - log_cook: accepts `rating`, validates via full_clean (enforces the exactly-one-recipe rule), and returns `used_ingredients` as a suggestion set instead of mutating the pantry. Auto-deduct path and _deduct_ingredient removed — pantry state changes only via set-state after the user confirms. - New POST /api/pantry/set-state/ — set in/low/out by ingredient name (alias-aware), optional location; registered before the router so the pantry detail route doesn't capture "set-state" as a pk. - what_can_i_cook: presence-based (exclude 'out', tolerate null quantity) so the API matcher agrees with the web one. - bulk-pantry-add: restocks an existing ingredient+location row to 'in' instead of duplicating; quantity is an optional int. Tests cover all four + that pantry `state` is serialized (24 pass). Co-Authored-By: Claude Opus 4.8 --- kitchen/urls.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'kitchen/urls.py') diff --git a/kitchen/urls.py b/kitchen/urls.py index ff3745f..69d2f30 100644 --- a/kitchen/urls.py +++ b/kitchen/urls.py @@ -16,6 +16,9 @@ router.register(r"cook-log", views.CookLogViewSet) router.register(r"shopping-list", views.ShoppingListItemViewSet) urlpatterns = [ + # Must precede the router include — otherwise the PantryItem detail route + # (pantry//) captures "set-state" as a pk. + path("pantry/set-state/", views.set_pantry_state, name="set-pantry-state"), path("", include(router.urls)), path("what-can-i-cook/", views.what_can_i_cook, name="what-can-i-cook"), path("log-cook/", views.log_cook, name="log-cook"), -- cgit v1.2.3