Skip to main content
Glama

get_exercise_history

Retrieve historical workout data for a specific exercise to track progress over time. Filter by date range and set result limits to analyze performance trends.

Instructions

Get history of a specific exercise across workouts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exercise_nameYes
from_dateNo
to_dateNo
limitNo

Implementation Reference

  • Implementation of the get_exercise_history tool which queries the database for exercise history based on exercise name and date range.
    def get_exercise_history(
        exercise_name: str,
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
        limit: int = 20,
    ) -> dict[str, list[dict[str, Any]]]:
        """Get history of a specific exercise across workouts."""
        conn = get_connection()
        cursor = conn.cursor()
    
        base = """
        SELECT w.id as workout_id, w.date_time, w.workout_type, w.tags, w.notes as workout_notes,
               e.id as exercise_id, e.name as exercise_name, e.category as exercise_category, e.notes as exercise_notes
        FROM workouts w
        JOIN exercises e ON e.workout_id = w.id
        WHERE LOWER(e.name) = LOWER(?)
        """
        params: list[Any] = [exercise_name]
    
        if from_date:
            base += " AND w.date_time >= ?"
            params.append(f"{_ensure_date(from_date)}T00:00:00")
        if to_date:
            base += " AND w.date_time <= ?"
            params.append(f"{_ensure_date(to_date)}T23:59:59")
    
        base += " ORDER BY w.date_time DESC LIMIT ?"
        params.append(limit)
    
        cursor.execute(base, params)
        rows = cursor.fetchall()
    
        entries: list[dict[str, Any]] = []
        for row in rows:
            item = _row_to_dict(row)
            item["tags"] = deserialize_tags(item["tags"])
            item["sets"] = _load_sets(conn, item["exercise_id"])
            entries.append(item)
    
        conn.close()
        return {"entries": entries}

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