get_activities
Retrieve recent Strava activities for the authenticated athlete, with configurable limits for data analysis and tracking.
Instructions
Get the authenticated athlete's recent activities.
Args:
limit: Maximum number of activities to return (default: 10)
Returns:
Dictionary containing activities data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- src/strava_mcp_server/server.py:214-235 (handler)MCP tool handler for 'get_activities': fetches recent Strava activities using the StravaClient, handles errors and client initialization.@mcp.tool() def get_activities(limit: int = 10) -> dict[str, Any]: """ Get the authenticated athlete's recent activities. Args: limit: Maximum number of activities to return (default: 10) Returns: Dictionary containing activities data """ if strava_client is None: return { "error": "Strava client not initialized. Please provide refresh token, client ID, and client secret." # noqa: E501 } try: activities = strava_client.get_activities(limit=limit) return {"data": activities} except Exception as e: return {"error": str(e)}
- StravaClient helper method that performs the actual API call to retrieve activities, filters results, and is called by the tool handler.def get_activities( self, limit: int = 10, before: Optional[int] = None, after: Optional[int] = None ) -> list: """ Get the authenticated athlete's activities. Args: limit: Maximum number of activities to return before: Unix timestamp to filter activities before this time after: Unix timestamp to filter activities after this time Returns: List of activities """ params = {"per_page": limit} if before: params["before"] = before if after: params["after"] = after activities = self._make_request("athlete/activities", params) return self._filter_activities(activities)