From e7e242151f4897958c88730f75e980e4f10bc2da Mon Sep 17 00:00:00 2001 From: Marcus van Elst Date: Fri, 17 Apr 2026 11:45:28 +0200 Subject: [PATCH] feat(meal-planner): add add_recipe_to_meal_plan tool (v0.11.0) New write tool using mpcreateByRecipeId endpoint (parameters verified from JS-bundle). Returns raw response pending production verification; structured output planned for v0.11.1. Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 6 +++-- README.md | 3 ++- SPEC.md | 17 +++++++++++++- pyproject.toml | 2 +- src/mcp_familywall/__init__.py | 2 +- src/mcp_familywall/server.py | 43 ++++++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 6 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 43b2968..4c42bfd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -24,7 +24,7 @@ und wird in Claude Desktop eingebunden. ## Aktueller Stand -### Implementierte Tools (v0.10.3) +### Implementierte Tools (v0.11.0) | Kategorie | Tools | |---|---| @@ -34,6 +34,7 @@ und wird in Claude Desktop eingebunden. | Kategorien | `create_category`, `delete_category` | | Aktivitäten | `like_post` | | Rezepte | `get_recipes`, `get_recipe`, `create_recipe`, `update_recipe`, `delete_recipe`, `get_recipe_categories` | +| Essensplaner | `get_meal_plan`, `add_recipe_to_meal_plan` | | Kreise | `create_circle`, `update_circle`, `delete_circle`, `add_member_to_circle` | ## Roadmap @@ -61,7 +62,8 @@ und wird in Claude Desktop eingebunden. - v0.10.0: get_meal_plan (read-only, raw JSON; Premium-Feature Essensplaner) ✓ - v0.10.1: get_meal_plan strukturierter Output + SPEC.md mplistinterval Response verifiziert ✓ - v0.10.2: get_meal_plan mealList[] einbinden (Freitext-Notizen + Portionen), merged + sortiert ✓ -- v0.10.3: get_meal_plan is_from_recipe_box Feld (recipeList[].isRecipe Lookup) ✓ ← aktuell +- v0.10.3: get_meal_plan is_from_recipe_box Feld (recipeList[].isRecipe Lookup) ✓ +- v0.11.0: add_recipe_to_meal_plan (mpcreateByRecipeId; raw response bis Struktur verifiziert) ✓ ← aktuell - v2.0: Schreibzugriff auf Wall-Posts (Erstellen, Kommentieren) diff --git a/README.md b/README.md index 8e37630..c2466c5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ MCP server for [Family Wall](https://www.familywall.com) -- read and manage your family's circles, lists, tasks, and recipes directly from Claude. -## Features (v0.10.3) +## Features (v0.11.0) ### Read @@ -32,6 +32,7 @@ MCP server for [Family Wall](https://www.familywall.com) -- read and manage your - `create_recipe` -- create a new recipe (name, description, ingredients, instructions, prep/cook time, serves, url, category_ids); use `\n` to separate ingredient lines - `update_recipe` -- update any field of an existing recipe (partial update — omitted fields unchanged; supports `category_ids` list to change categories) - `delete_recipe` -- permanently delete a recipe (only own recipes) +- `add_recipe_to_meal_plan` -- add a recipe from the recipe box to the meal plan for a specific date and meal slot (BREAKFAST/LUNCH/SNACK/DINNER) - `create_circle` -- create a new Family Wall circle (group) - `update_circle` -- rename a circle (server capitalises first letter; only name is changeable via API; primary circle is protected) - `delete_circle` -- permanently delete a circle and all its content (primary circle is protected) diff --git a/SPEC.md b/SPEC.md index 95dbff6..117cbaf 100644 --- a/SPEC.md +++ b/SPEC.md @@ -722,12 +722,27 @@ Rezept-Details bei Bedarf separat via `get_recipe` abrufen. **Verifiziert am:** 2026-04-17 via FW_DEBUG=1 +### `mpcreateByRecipeId` – Rezept in Essensplan eintragen +POST https://api.familywall.com/api/mpcreateByRecipeId + +**Body-Parameter (verifiziert aus JS-Bundle startupmodule.js):** + +| Parameter | Pflicht | Wert | +|---|---|---| +| `recipeId` | ja | Rezept-metaId (z.B. `"recipe/16282169_7932720"`) | +| `date` | ja | Ziel-Datum ISO 8601 (z.B. `"2026-04-20"`) | +| `type` | ja | Mahlzeiten-Typ: `BREAKFAST`, `LUNCH`, `SNACK`, `DINNER` | +| `clientOpId` | nein | Optionale Client-seitige Idempotenz-ID (wird weggelassen) | + +**Response-Struktur:** TBD — Tool liefert Raw JSON zur Verifizierung (→ v0.11.1). + +**Verifiziert am:** 2026-04-17 (Parameter aus JS-Bundle; Response TBD) + ### Weitere Meal Planner Endpoints (nicht implementiert) | Endpoint | Parameter | Bedeutung | |---|---|---| | `mpcreate` | `name`, `date`, `type`, `clientOpId` | Mahlzeit mit freiem Text erstellen | -| `mpcreateByRecipeId` | `recipeId`, `date`, `type`, `clientOpId` | Mahlzeit aus Rezept erstellen | | `mpmealput` | Mahlzeiten-Objekt (encoded) | Mahlzeit aktualisieren | | `mpmove` | `metaId`, `date`, `type`, `clientOpId` | Mahlzeit zu anderem Datum/Typ verschieben | | `mpdelete` | `metaId` | Mahlzeit löschen | diff --git a/pyproject.toml b/pyproject.toml index e4a9598..ecc2458 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "mcp-familywall" -version = "0.10.3" +version = "0.11.0" description = "MCP server for Family Wall — read your family's lists and tasks via Claude" readme = "README.md" requires-python = ">=3.12" diff --git a/src/mcp_familywall/__init__.py b/src/mcp_familywall/__init__.py index b2385cb..ae6db5f 100644 --- a/src/mcp_familywall/__init__.py +++ b/src/mcp_familywall/__init__.py @@ -1 +1 @@ -__version__ = "0.10.3" +__version__ = "0.11.0" diff --git a/src/mcp_familywall/server.py b/src/mcp_familywall/server.py index 9be52e6..1b04739 100644 --- a/src/mcp_familywall/server.py +++ b/src/mcp_familywall/server.py @@ -2320,6 +2320,49 @@ def get_meal_plan(date_from: str, date_to: str) -> str: return json.dumps(result, ensure_ascii=False, indent=2) +# --------------------------------------------------------------------------- +# Tool: add_recipe_to_meal_plan +# --------------------------------------------------------------------------- + + +@mcp.tool() +def add_recipe_to_meal_plan( + recipe_id: str, + date: str, + meal_type: str, +) -> str: + """Add a recipe from the recipe box to the meal plan. + + IMPORTANT: Ask the user for confirmation before calling this tool. + + Args: + recipe_id: Recipe metaId from get_recipes + (e.g. ``"recipe/16282169_7932720"``). + date: Target date in ISO format (e.g. ``"2026-04-20"``). + meal_type: Meal slot — one of ``"BREAKFAST"``, ``"LUNCH"``, + ``"SNACK"``, or ``"DINNER"``. + + Returns: + JSON with the new dish entry on success, or an error message. + """ + if meal_type not in ("BREAKFAST", "LUNCH", "SNACK", "DINNER"): + return "Error: meal_type must be one of 'BREAKFAST', 'LUNCH', 'SNACK', 'DINNER'." + + params: dict[str, Any] = { + "recipeId": recipe_id, + "date": date, + "type": meal_type, + } + + try: + data = _authenticated_call("mpcreateByRecipeId", params) + except RuntimeError as exc: + return f"Error: {exc}" + + # Return raw response until the structure is verified in production. + return json.dumps(data, ensure_ascii=False, indent=2) + + # --------------------------------------------------------------------------- # Factory # ---------------------------------------------------------------------------