From b7e12f4a7fe237a9ffa30ffd66e874ddd34a93ca Mon Sep 17 00:00:00 2001 From: Jen Corcyra Date: Fri, 12 Jun 2026 20:54:49 -0400 Subject: [PATCH 1/2] Add saturated_fat_g to add_custom_food MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Custom foods could not include saturated fat — the field had no parameter, so foods created via the API silently undercounted daily saturated fat totals (now surfaced in summaries since #14). Adds saturated_fat_g (per-serving, g, default 0) to add_custom_food, wired to nutrient ID 606 with the same per-100g scaling as other nutrients. Backward compatible — existing calls are unaffected. Field-tested for 3 weeks as a local patch driving a personal food library with cardiovascular-target tracking. The same pattern extends naturally to cholesterol, trans_fat, and omega_3/6 (already in NUTRIENT_IDS) if there's interest in a follow-up. --- src/cronometer_api_mcp/client.py | 2 ++ src/cronometer_api_mcp/server.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/cronometer_api_mcp/client.py b/src/cronometer_api_mcp/client.py index fc0701e..617e57b 100644 --- a/src/cronometer_api_mcp/client.py +++ b/src/cronometer_api_mcp/client.py @@ -307,6 +307,7 @@ def create_custom_food( fiber_g: float = 0, sugar_g: float = 0, sodium_mg: float = 0, + saturated_fat_g: float = 0, serving_name: str = "1 serving", serving_grams: float = 100.0, ) -> dict: @@ -331,6 +332,7 @@ def create_custom_food( {"id": NUTRIENT_IDS["fiber"], "amount": round(fiber_g * scale, 2)}, {"id": NUTRIENT_IDS["sugar"], "amount": round(sugar_g * scale, 2)}, {"id": NUTRIENT_IDS["sodium"], "amount": round(sodium_mg * scale, 2)}, + {"id": NUTRIENT_IDS["saturated_fat"], "amount": round(saturated_fat_g * scale, 2)}, # Derived / calculated fields the app includes {"id": -203, "amount": round(protein_g * scale, 2)}, {"id": -204, "amount": round(fat_g * scale, 2)}, diff --git a/src/cronometer_api_mcp/server.py b/src/cronometer_api_mcp/server.py index ddf0d2d..b041412 100644 --- a/src/cronometer_api_mcp/server.py +++ b/src/cronometer_api_mcp/server.py @@ -517,6 +517,7 @@ def add_custom_food( fiber_g: float = 0, sugar_g: float = 0, sodium_mg: float = 0, + saturated_fat_g: float = 0, serving_name: str = "1 serving", serving_grams: float = 100.0, ) -> str: @@ -534,6 +535,7 @@ def add_custom_food( fiber_g: Fiber per serving (g, default 0). sugar_g: Sugar per serving (g, default 0). sodium_mg: Sodium per serving (mg, default 0). + saturated_fat_g: Saturated fat per serving (g, default 0). serving_name: Name for the serving size (default "1 serving"). serving_grams: Weight of one serving in grams (default 100). """ @@ -548,6 +550,7 @@ def add_custom_food( fiber_g=fiber_g, sugar_g=sugar_g, sodium_mg=sodium_mg, + saturated_fat_g=saturated_fat_g, serving_name=serving_name, serving_grams=serving_grams, ) From a013d72eb26aca6022126169f223809740c4cc1c Mon Sep 17 00:00:00 2001 From: Randy Westergren Date: Mon, 15 Jun 2026 08:09:27 -0400 Subject: [PATCH 2/2] Reformat saturated_fat nutrient entry to satisfy ruff --- src/cronometer_api_mcp/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cronometer_api_mcp/client.py b/src/cronometer_api_mcp/client.py index 617e57b..c1e8546 100644 --- a/src/cronometer_api_mcp/client.py +++ b/src/cronometer_api_mcp/client.py @@ -332,7 +332,10 @@ def create_custom_food( {"id": NUTRIENT_IDS["fiber"], "amount": round(fiber_g * scale, 2)}, {"id": NUTRIENT_IDS["sugar"], "amount": round(sugar_g * scale, 2)}, {"id": NUTRIENT_IDS["sodium"], "amount": round(sodium_mg * scale, 2)}, - {"id": NUTRIENT_IDS["saturated_fat"], "amount": round(saturated_fat_g * scale, 2)}, + { + "id": NUTRIENT_IDS["saturated_fat"], + "amount": round(saturated_fat_g * scale, 2), + }, # Derived / calculated fields the app includes {"id": -203, "amount": round(protein_g * scale, 2)}, {"id": -204, "amount": round(fat_g * scale, 2)},