Skip to main content
Glama

upsert_meal

Create or update a meal entry within a nutrition day for fitness tracking, enabling food logging and nutrition management in the MCP Logger server.

Instructions

Create or update a meal within a nutrition day.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
nameYes
order_indexNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implementation of the upsert_meal tool which creates or updates a meal entry within a specific nutrition day.
    def upsert_meal(date: str, name: str, order_index: int = 0) -> dict[str, int]:
        """Create or update a meal within a nutrition day."""
        date = _ensure_date(date)
        conn = get_connection()
        cursor = conn.cursor()
    
        # Ensure day exists
        cursor.execute("INSERT OR IGNORE INTO nutrition_days (date) VALUES (?)", (date,))
        cursor.execute("SELECT id FROM nutrition_days WHERE date = ?", (date,))
        day_id = cursor.fetchone()[0]
    
        # Upsert meal
        cursor.execute(
            """INSERT INTO meals (day_id, name, order_index) VALUES (?, ?, ?)
               ON CONFLICT(day_id, name) DO UPDATE SET order_index = ?""",
            (day_id, name, order_index, order_index),
        )
        meal_id = cursor.lastrowid or cursor.execute(
            "SELECT id FROM meals WHERE day_id = ? AND name = ?", (day_id, name)
        ).fetchone()[0]
    
        conn.commit()
        conn.close()
        return {"meal_id": meal_id}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Create or update') but doesn't clarify permissions, side effects (e.g., if updates overwrite existing data), or error handling. This is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste, clearly front-loaded with the core action. Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with 3 parameters), no annotations, and 0% schema coverage, the description is incomplete—it lacks behavioral and parametric details. However, the presence of an output schema mitigates some need to explain return values, keeping it from a lower score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'a meal within a nutrition day' but doesn't explain the meaning of 'date', 'name', or 'order_index', nor their formats or constraints. This adds minimal value beyond the schema's structure.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create or update') and resource ('a meal within a nutrition day'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'add_or_update_meal_item' or 'upsert_nutrition_day', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'add_or_update_meal_item' or 'delete_meal', nor does it mention prerequisites like the existence of a nutrition day. It lacks explicit when/when-not instructions or context for selection among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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