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 <noreply@anthropic.com>
This commit is contained in:
2026-04-17 11:45:28 +02:00
parent bf086a4f84
commit e7e242151f
6 changed files with 67 additions and 6 deletions
+43
View File
@@ -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
# ---------------------------------------------------------------------------