Skip to main content
Glama

delete_nutrition_day

Remove a nutrition day from fitness tracking records and optionally delete associated meals and food items to maintain clean data.

Instructions

Delete a nutrition day and optionally cascade to meals/items.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
cascadeNo

Implementation Reference

  • The implementation of the 'delete_nutrition_day' tool, which deletes a nutrition day from the database, with an optional cascading delete for associated meals and meal items.
    @app.tool()
    def delete_nutrition_day(date: str, cascade: bool = True) -> dict[str, bool]:
        """Delete a nutrition day and optionally cascade to meals/items."""
        date = _ensure_date(date)
        conn = get_connection()
        cursor = conn.cursor()
        if cascade:
            # Get meal IDs first
            cursor.execute("SELECT id FROM meals WHERE day_id IN (SELECT id FROM nutrition_days WHERE date = ?)", (date,))
            meal_ids = [r[0] for r in cursor.fetchall()]
            if meal_ids:
                placeholders = ",".join("?" * len(meal_ids))
                cursor.execute(f"DELETE FROM meal_items WHERE meal_id IN ({placeholders})", meal_ids)
            cursor.execute("DELETE FROM meals WHERE day_id IN (SELECT id FROM nutrition_days WHERE date = ?)", (date,))
        cursor.execute("DELETE FROM nutrition_days WHERE date = ?", (date,))
        conn.commit()
        conn.close()
        return {"deleted": cursor.rowcount > 0}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JohnZolton/MCP-logger'

If you have feedback or need assistance with the MCP directory API, please join our Discord server