Skip to main content
Glama

get_workouts

Retrieve workout data from the MCP Logger fitness tracking server using filters like date range, workout type, tags, or exercise names to analyze exercise history.

Instructions

Query workouts with various filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_dateNo
to_dateNo
workout_typeNo
tagNo
exercise_name_containsNo
limitNo
offsetNo

Implementation Reference

  • Implementation of the get_workouts tool, which queries the workouts table with various filters and hydrates the results with related exercise and set data.
    def get_workouts(
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
        workout_type: Optional[str] = None,
        tag: Optional[str] = None,
        exercise_name_contains: Optional[str] = None,
        limit: int = 20,
        offset: int = 0,
    ) -> dict[str, list[dict[str, Any]]]:
        """Query workouts with various filters."""
        conn = get_connection()
        cursor = conn.cursor()
    
        filters: list[str] = []
        params: list[Any] = []
    
        if from_date:
            filters.append("date_time >= ?")
            params.append(f"{_ensure_date(from_date)}T00:00:00")
        if to_date:
            filters.append("date_time <= ?")
            params.append(f"{_ensure_date(to_date)}T23:59:59")
        if workout_type:
            filters.append("workout_type = ?")
            params.append(workout_type)
        if tag:
            filters.append("tags LIKE ?")
            params.append(f'%"{tag}"%')
    
        base = "SELECT * FROM workouts"
        if filters:
            base += " WHERE " + " AND ".join(filters)
        base += " ORDER BY date_time DESC LIMIT ? OFFSET ?"
        params.extend([limit, offset])
    
        cursor.execute(base, params)
        rows = cursor.fetchall()
    
        workouts = [_hydrate_workout(conn, _row_to_dict(row)) for row in rows]
        conn.close()
        return {"workouts": workouts}

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