Skip to main content
Glama

log_workout

Record workout details including exercises, sets, and metrics to track fitness progress in a personal database.

Instructions

Log a complete workout with exercises and sets.

Returns the fully logged workout with all exercises and sets for confirmation.

Args: date_time: ISO datetime string (e.g., "2026-01-06T18:30:00") workout_type: Optional type/category for the workout tags: Optional list of tags (e.g., ["legs", "sprint"]) notes: Optional notes for the workout exercises: List of exercises with sets. Each exercise should have: - name: str (required) - category: Optional[str] - notes: Optional[str] - sets: List of sets with fields like reps, weight_kg, weight_lbs, distance_yards, side, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
date_timeYes
workout_typeNo
tagsNo
notesNo
exercisesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'log_workout' tool implementation, which processes the input arguments, handles potential JSON strings for tags/exercises, inserts the workout and exercise/set data into the SQLite database, and returns the fully hydrated workout details.
    @app.tool()
    def log_workout(
        date_time: str,
        workout_type: Optional[str] = None,
        tags: Optional[Any] = None,
        notes: Optional[str] = None,
        exercises: Optional[Any] = None,
    ) -> dict[str, Any]:
        """Log a complete workout with exercises and sets.
    
        Returns the fully logged workout with all exercises and sets for confirmation.
    
        Args:
            date_time: ISO datetime string (e.g., "2026-01-06T18:30:00")
            workout_type: Optional type/category for the workout
            tags: Optional list of tags (e.g., ["legs", "sprint"])
            notes: Optional notes for the workout
            exercises: List of exercises with sets. Each exercise should have:
                - name: str (required)
                - category: Optional[str]
                - notes: Optional[str]
                - sets: List of sets with fields like reps, weight_kg, weight_lbs, distance_yards, side, etc.
        """
        # Handle JSON string inputs (for clients that serialize arrays as strings)
        tags = _parse_json_array(tags)
        exercises = _parse_json_array(exercises)
        
        # Validate types after parsing
        if tags is not None and not isinstance(tags, list):
            raise TypeError(f"tags must be a list, got {type(tags).__name__}")
        if exercises is not None and not isinstance(exercises, list):
            raise TypeError(f"exercises must be a list, got {type(exercises).__name__}")
        
        date_time = _ensure_iso_date(date_time)
        tags_json = serialize_tags(tags)
    
        conn = get_connection()
        cursor = conn.cursor()
        cursor.execute(
            "INSERT INTO workouts (date_time, workout_type, tags, notes) VALUES (?, ?, ?, ?)",
            (date_time, workout_type, tags_json, notes),
        )
        workout_id = cursor.lastrowid
    
        if exercises:
            for order_index, exercise in enumerate(exercises, start=1):
                exercise_name = exercise.get("name")
                if not exercise_name:
                    raise ValueError(f"Exercise at index {order_index} is missing required 'name' field")
                
                cursor.execute(
                    "INSERT INTO exercises (workout_id, order_index, name, category, notes) VALUES (?, ?, ?, ?, ?)",
                    (workout_id, order_index, exercise_name, exercise.get("category"), exercise.get("notes")),
                )
                exercise_id = cursor.lastrowid
    
                for set_index, set_payload in enumerate(exercise.get("sets", []), start=1):
                    cursor.execute(
                        """INSERT INTO sets (
                            exercise_id, set_index, reps, weight_kg, weight_lbs,
                            distance_m, distance_yards, duration_s,
                            side, rpe, rir, is_warmup
                        ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
                        (
                            exercise_id,
                            set_payload.get("set_index") or set_index,
                            set_payload.get("reps"),
                            set_payload.get("weight_kg"),
                            set_payload.get("weight_lbs"),
                            set_payload.get("distance_m"),
                            set_payload.get("distance_yards"),
                            set_payload.get("duration_s"),
                            set_payload.get("side"),
                            set_payload.get("rpe"),
                            set_payload.get("rir"),
                            1 if set_payload.get("is_warmup") else 0,
                        ),
                    )
    
        conn.commit()
        
        # Return the fully hydrated workout for confirmation
        workout = cursor.execute("SELECT * FROM workouts WHERE id = ?", (workout_id,)).fetchone()
        result = _hydrate_workout(conn, _row_to_dict(workout))
        
        conn.close()
        return result
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 it 'Returns the fully logged workout' but doesn't specify success/failure conditions, error handling, or side effects like data persistence. For a write operation with zero annotation coverage, this lacks critical behavioral context like permissions or data validation.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the purpose, the second explains the return, and the 'Args:' section efficiently details parameters. Every sentence adds value, though the nested explanation of 'exercises' could be slightly more structured for readability.

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 5 parameters with 0% schema coverage and no annotations, the description does well on parameters but lacks behavioral context for a write operation. The presence of an output schema means return values don't need explanation, but completeness is moderate due to missing usage guidelines and transparency for a mutation tool.

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

Parameters4/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. It adds significant value by explaining all 5 parameters: it clarifies 'date_time' format, lists optional fields, and details the nested 'exercises' structure with required/optional sub-fields. This goes well beyond the bare schema, though it doesn't cover all possible set fields exhaustively.

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 tool's purpose: 'Log a complete workout with exercises and sets.' It specifies the verb ('Log') and resource ('workout'), and distinguishes it from sibling tools like 'add_exercise' or 'add_set' by emphasizing completeness. However, it doesn't explicitly differentiate from 'get_workouts' or 'get_last_workout' beyond the write vs. read distinction.

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. It doesn't mention prerequisites, when to choose this over 'add_exercise' or 'add_set' for incremental logging, or how it relates to sibling tools like 'get_workouts' for retrieval. Usage is implied by the purpose but not explicitly stated.

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