feat(meal-planner): add delete_meal_plan_entry tool (v0.11.4)
Reuses the existing metadelete endpoint (already used for tasks and recipes). Validates that entry_id starts with 'dish/' or 'meal/' before calling the API. SPEC.md updated to reflect metadelete's broader scope. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2463,6 +2463,42 @@ def add_meal_to_meal_plan(
|
||||
return json.dumps(result, ensure_ascii=False, indent=2)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tool: delete_meal_plan_entry
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def delete_meal_plan_entry(entry_id: str) -> str:
|
||||
"""Permanently delete a meal plan entry (dish or meal).
|
||||
|
||||
IMPORTANT: Ask the user for confirmation before calling this tool.
|
||||
|
||||
Works for both ``dish/...`` entries (planned meals/recipes) and
|
||||
``meal/...`` entries (notes/servings). Use ``get_meal_plan`` to
|
||||
retrieve entry IDs.
|
||||
|
||||
Args:
|
||||
entry_id: Entry metaId from get_meal_plan
|
||||
(e.g. ``"dish/16282169_20009811"`` or ``"meal/16282169_1620659"``).
|
||||
|
||||
Returns:
|
||||
JSON success indicator or an error message.
|
||||
"""
|
||||
if not entry_id.startswith(("dish/", "meal/")):
|
||||
return (
|
||||
"Error: entry_id must be a dish or meal metaId "
|
||||
"(e.g. 'dish/16282169_20009811' or 'meal/16282169_1620659')."
|
||||
)
|
||||
|
||||
try:
|
||||
_authenticated_call("metadelete", {"id": entry_id})
|
||||
except RuntimeError as exc:
|
||||
return f"Error: {exc}"
|
||||
|
||||
return json.dumps({"deleted": True, "id": entry_id}, ensure_ascii=False, indent=2)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Factory
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user