get_recent_activities
Retrieve recent Strava activities from the past specified days, allowing query and analysis of athlete data. Configure days and limit for precise data retrieval.
Instructions
Get activities from the past X days.
Args:
days: Number of days to look back (default: 7)
limit: Maximum number of activities to return (default: 10)
Returns:
Dictionary containing activities data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | ||
| limit | No |
Implementation Reference
- src/strava_mcp_server/server.py:292-319 (handler)The handler function for the 'get_recent_activities' tool, including the @mcp.tool() decorator which registers it in the FastMCP server. It fetches Strava activities from the past 'days' days, up to 'limit' activities, handling client initialization and errors.@mcp.tool() def get_recent_activities(days: int = 7, limit: int = 10) -> dict[str, Any]: """ Get activities from the past X days. Args: days: Number of days to look back (default: 7) 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: # Calculate timestamp for X days ago now = datetime.now() days_ago = now - timedelta(days=days) after = int(days_ago.timestamp()) activities = strava_client.get_activities(limit=limit, after=after) return {"data": activities} except Exception as e: return {"error": str(e)}