add_set
Add a set to an existing exercise in the MCP Logger fitness tracker, specifying reps, weight, distance, duration, side, RPE, RIR, and warmup status for comprehensive workout logging.
Instructions
Add a set to an existing exercise.
Args: exercise_id: ID of the exercise to add set to reps: Number of repetitions weight_kg: Weight in kilograms weight_lbs: Weight in pounds distance_m: Distance in meters distance_yards: Distance in yards duration_s: Duration in seconds side: 'left', 'right', or 'both' for unilateral exercises rpe: Rate of Perceived Exertion (1-10) rir: Reps In Reserve (0-5) is_warmup: Whether this is a warmup set
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exercise_id | Yes | ||
| reps | No | ||
| weight_kg | No | ||
| weight_lbs | No | ||
| distance_m | No | ||
| distance_yards | No | ||
| duration_s | No | ||
| side | No | ||
| rpe | No | ||
| rir | No | ||
| is_warmup | No |
Implementation Reference
- src/main.py:198-246 (handler)The `add_set` tool is defined here, which registers with the FastMCP app and handles inserting a new set into the database for a given `exercise_id`.
def add_set( exercise_id: int, reps: Optional[float] = None, weight_kg: Optional[float] = None, weight_lbs: Optional[float] = None, distance_m: Optional[float] = None, distance_yards: Optional[float] = None, duration_s: Optional[float] = None, side: Optional[str] = None, rpe: Optional[float] = None, rir: Optional[float] = None, is_warmup: bool = False, ) -> dict[str, int]: """Add a set to an existing exercise. Args: exercise_id: ID of the exercise to add set to reps: Number of repetitions weight_kg: Weight in kilograms weight_lbs: Weight in pounds distance_m: Distance in meters distance_yards: Distance in yards duration_s: Duration in seconds side: 'left', 'right', or 'both' for unilateral exercises rpe: Rate of Perceived Exertion (1-10) rir: Reps In Reserve (0-5) is_warmup: Whether this is a warmup set """ conn = get_connection() cursor = conn.cursor() # Get current max set_index cursor.execute("SELECT COALESCE(MAX(set_index), 0) FROM sets WHERE exercise_id = ?", (exercise_id,)) max_set = cursor.fetchone()[0] 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, max_set + 1, reps, weight_kg, weight_lbs, distance_m, distance_yards, duration_s, side, rpe, rir, 1 if is_warmup else 0 ), ) set_id = cursor.lastrowid conn.commit() conn.close() return {"set_id": set_id}