feat(recipes): add get_recipe_box + parser-fix ingredients_parsed (v0.11.7)

- New tool get_recipe_box: filtered version of get_recipes returning only real recipes (isRecipe=true), excluding stubs created for free-text meal entries
- Parser fix: ingredients_parsed now generated from free-text ingredients field instead of API's ingredientsList which has parser bug on comma+space (e.g. '1, 5g' breaks)
- Updated SPEC.md with parser bug documentation
- Updated version to 0.11.7 in __init__.py and pyproject.toml
- Updated .gitignore to exclude debug/test scripts

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-04-17 13:55:05 +02:00
parent 343e8eeb58
commit 5e3b7e08a3
12 changed files with 222 additions and 10 deletions
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.11.6"
__version__ = "0.11.7"
+7 -3
View File
@@ -71,9 +71,13 @@ def parse_recipe_full(raw: dict[str, Any]) -> dict[str, Any]:
cook = raw.get("cookTime")
srv = raw.get("serves")
# ingredientsList is auto-parsed by the server; normalise to a plain list of names.
ingredients_list_raw: list[dict[str, Any]] = raw.get("ingredientsList") or []
ingredients_parsed = [item.get("name") for item in ingredients_list_raw if item.get("name")]
# Parse ingredients from the free-text ingredients field.
# The API's ingredientsList has a parser bug: it breaks on comma+space (e.g. "1, 5g").
# We parse the raw ingredients text instead by splitting on \r\n and \n.
raw_ingredients = raw.get("ingredients") or ""
ingredients_parsed = [
line.strip() for line in raw_ingredients.replace("\r\n", "\n").split("\n") if line.strip()
]
# Extract recipe categories from API response.
# The API provides both recipeCategoryIdList (actual IDs) and recipeCategories
+26
View File
@@ -1956,6 +1956,32 @@ def get_recipes() -> str:
return json.dumps(result, ensure_ascii=False, indent=2)
# ---------------------------------------------------------------------------
# Tool: get_recipe_box
# ---------------------------------------------------------------------------
@mcp.tool()
def get_recipe_box() -> str:
"""Return only real recipes from the recipe box (isRecipe=true).
Excludes stub recipes that are auto-created when free-text meal plan
entries are added. Use this for meal planning and ingredient lookups.
For the full list including stubs use get_recipes.
Returns:
JSON list of recipe summary objects (same format as get_recipes).
Returns an error message string on failure.
"""
try:
raw_recipes = _get_raw_recipes()
except RuntimeError as exc:
return f"Error: {exc}"
result = [parse_recipe_summary(r) for r in raw_recipes if r.get("isRecipe") == "true"]
return json.dumps(result, ensure_ascii=False, indent=2)
# ---------------------------------------------------------------------------
# Tool: get_recipe
# ---------------------------------------------------------------------------