Skip to main content
Glama

get_last_workout

Retrieve your most recent workout by specifying type or tag to track exercise history and monitor fitness progress.

Instructions

Get the most recent workout matching type or tag.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workout_typeNo
tagNo

Implementation Reference

  • The get_last_workout function is defined and decorated as an app.tool, acting as the handler for retrieving the most recent workout matching specified type or tags.
    @app.tool()
    def get_last_workout(
        workout_type: Optional[str] = None,
        tag: Optional[str] = None,
    ) -> dict[str, Any | None]:
        """Get the most recent workout matching type or tag."""
        if not workout_type and not tag:
            raise ValueError("At least one of workout_type or tag is required")
    
        conn = get_connection()
        cursor = conn.cursor()
    
        filters: list[str] = []
        params: list[Any] = []
        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 1"
    
        cursor.execute(base, params)
        row = cursor.fetchone()
        if not row:
            conn.close()
            return {"workout": None}
    
        workout = _hydrate_workout(conn, _row_to_dict(row))
        conn.close()
        return {"workout": workout}

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