get_workout
Fetch a specific workout by ID from Garmin Connect. Access structured strength training data and other workout payloads.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workout_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/garmin_workouts_mcp/server.py:86-89 (handler)The get_workout function is the handler for the 'get_workout' tool. It takes a workout_id string, formats the Garmin API endpoint, calls _connectapi to fetch the workout, and returns it wrapped in a dict.
@mcp.tool def get_workout(workout_id: str) -> dict: endpoint = GET_WORKOUT_ENDPOINT.format(workout_id=workout_id) return {"workout": _connectapi(endpoint)} - src/garmin_workouts_mcp/server.py:86-89 (registration)The @mcp.tool decorator on line 86 registers 'get_workout' as an MCP tool with the FastMCP server instance.
@mcp.tool def get_workout(workout_id: str) -> dict: endpoint = GET_WORKOUT_ENDPOINT.format(workout_id=workout_id) return {"workout": _connectapi(endpoint)} - The GET_WORKOUT_ENDPOINT constant defines the Garmin API endpoint path used by the get_workout handler.
GET_WORKOUT_ENDPOINT = "/workout-service/workout/{workout_id}" - The _connectapi helper function handles authentication and wraps garth.connectapi. It is used by get_workout to make the API call.
def _connectapi(endpoint: str, method: str = "GET", **kwargs) -> dict: _ensure_authenticated() return garth.connectapi(endpoint, method=method, **kwargs)