Skip to main content
Glama

add_exercise

Add exercises to workouts in the MCP Logger fitness tracking system. Specify workout ID, exercise name, optional category, and notes for comprehensive workout logging.

Instructions

Add an exercise to an existing workout.

Args: workout_id: ID of the workout to add exercise to name: Name of the exercise category: Optional category (e.g., 'Squat', 'Push', 'Pull') notes: Optional notes about the exercise

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workout_idYes
nameYes
categoryNo
notesNo

Implementation Reference

  • The `add_exercise` tool is implemented in `src/main.py` using a FastMCP decorator. It takes a `workout_id`, `name`, and optional `category` and `notes`, and inserts a new exercise record into the database with an auto-incrementing `order_index`.
    def add_exercise(
        workout_id: int,
        name: str,
        category: Optional[str] = None,
        notes: Optional[str] = None,
    ) -> dict[str, int]:
        """Add an exercise to an existing workout.
        
        Args:
            workout_id: ID of the workout to add exercise to
            name: Name of the exercise
            category: Optional category (e.g., 'Squat', 'Push', 'Pull')
            notes: Optional notes about the exercise
        """
        conn = get_connection()
        cursor = conn.cursor()
        
        # Get current max order_index
        cursor.execute("SELECT COALESCE(MAX(order_index), 0) FROM exercises WHERE workout_id = ?", (workout_id,))
        max_order = cursor.fetchone()[0]
        
        cursor.execute(
            "INSERT INTO exercises (workout_id, order_index, name, category, notes) VALUES (?, ?, ?, ?, ?)",
            (workout_id, max_order + 1, name, category, notes),
        )
        exercise_id = cursor.lastrowid
        conn.commit()
        conn.close()
        return {"exercise_id": exercise_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