Skip to main content
Glama

upsert_nutrition_day

Create or update daily nutrition entries to track food intake and dietary patterns within a fitness tracking system.

Instructions

Create or update a nutrition day entry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
notesNo

Implementation Reference

  • The handler for the 'upsert_nutrition_day' tool, which inserts or updates a nutrition day record in the database.
    @app.tool()
    def upsert_nutrition_day(date: str, notes: Optional[str] = None) -> dict[str, int]:
        """Create or update a nutrition day entry."""
        date = _ensure_date(date)
        conn = get_connection()
        cursor = conn.cursor()
        cursor.execute(
            "INSERT INTO nutrition_days (date, notes) VALUES (?, ?) ON CONFLICT(date) DO UPDATE SET notes = ?",
            (date, notes, notes),
        )
        day_id = cursor.lastrowid or cursor.execute("SELECT id FROM nutrition_days WHERE date = ?", (date,)).fetchone()[0]
        conn.commit()
        conn.close()
        return {"day_id": day_id}

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