Strava API MCP Server for Athlete Activity Data
Query athlete activity data from the Strava API with an MCP server that enables language models to access and retrieve workouts and performance metrics.
npx -y @tomekkorbak/strava-mcp-serverOverview
This MCP (Model Context Protocol) server exposes Strava athlete activity data to language models and other MCP-capable clients. It acts as a translator between the Strava REST API and an MCP runtime, exposing a small set of typed tools that return consistent, normalized activity records (distances in metres, times in seconds, speeds in m/s, ISO 8601 timestamps). By running the server locally and registering it with a compatible agent (for example, Claude Desktop or other MCP hosts), you can query recent workouts, filter by date range, or fetch detailed information about a single activity programmatically from an LLM.
The server is useful when you want conversational access to training history and metrics, to let an LLM answer questions like “What were my longest rides last month?” or to embed recent performance data into an automated coaching workflow. It handles Strava authentication, token refresh, and basic input validation so the model receives structured data without worrying about API details.
Features
- Exposes Strava athlete activities via MCP tools with clear, typed signatures
- Normalizes activity fields and units (metres, seconds, m/s, ISO timestamps)
- Date-range and ID-based activity queries
- Token management using Strava refresh tokens
- Human-readable error messages for authentication, date parsing, and network issues
- Small footprint Python server suitable for local use with Claude Desktop or other MCP-enabled clients
Installation / Configuration
Install the MCP server package (PyPI):
You can run the server through an MCP runtime (uvx) once installed:
Authentication and configuration:
Create a Strava API application at https://www.strava.com/settings/api to obtain:
- STRAVA_CLIENT_ID
- STRAVA_CLIENT_SECRET
- Set the Authorization Callback Domain to
localhost
Obtain a refresh token:
- Use the included helper script to authorize and persist tokens:
# follow prompts; this saves tokens to a local .env file
- Provide environment variables (example .env):
STRAVA_CLIENT_ID=your_client_id
STRAVA_CLIENT_SECRET=your_client_secret
STRAVA_REFRESH_TOKEN=your_refresh_token
Export variables for a single session:
Claude Desktop example (add to claude_desktop_config.json):
Available Tools
The server exposes these MCP tools (signatures and behavior):
- get_activities(limit: int = 10)
- Returns the authenticated athlete’s most recent activities (default 10).
- get_activities_by_date_range(start_date: str, end_date: str, limit: int = 30)
- Returns activities between two ISO dates (YYYY-MM-DD). Results capped by limit.
- get_activity_by_id(activity_id: int)
- Returns detailed data for a single activity identifier.
- get_recent_activities(days: int = 7, limit: int = 10)
- Returns activities from the past N days (default 7).
Note: date inputs must be ISO-style strings (YYYY-MM-DD).
Activity Data Format
Responses use consistent field names and units to simplify downstream processing.
| Field | Description | Unit |
|---|---|---|
| name | Activity name | — |
| sport_type | Sport type (e.g., Run, Ride) | — |
| start_date | Start datetime | ISO 8601 |
| distance_metres | Distance | metres |
| elapsed_time_seconds | Total elapsed time | seconds |
| moving_time_seconds | Moving time | seconds |
| average_speed_mps | Average speed | meters/second |
| max_speed_mps | Maximum speed | meters/second |
| total_elevation_gain_metres | Total elevation gained | metres |
| elev_high_metres | Highest elevation | metres |
| elev_low_metres | Lowest elevation | metres |
| calories | Estimated calories | kcal |
| start_latlng | Start coordinates | [lat, lng] |
| end_latlng | End coordinates | [lat, lng] |
Use Cases
- Ask a model for summaries of recent workouts: “Show my runs from the last two weeks and list distances and average paces.”
- Compare performance over time: “What was my longest ride in the past 30 days and what was the average speed?”
- Drill into a single effort: “Get details for activity 123456789 — how long, distance, elevation, and start location?”
- Automation/analytics: feed normalized activity objects into a script or LLM prompt for trend detection, HRV correlation, or training-plan adjustments.
Example conversational prompts a model can answer after MCP hookup:
- “List my activities from 2026-03-01 to 2026-03-31 sorted by distance.”
- “Which activity in the past 7 days had the highest elevation gain?”
Error Handling
Common error types and guidance:
- Invalid date format: provide dates in YYYY-MM-DD.
- Authentication errors: verify STRAVA_CLIENT_ID/SECRET and that the refresh token is current; re-run get_strava_token.py if needed.
- Network/API failures: transient 5xx responses can occur; retry or check network connectivity.
- Rate limits: Strava enforces API rate limits — reduce frequency or aggregate requests.
Errors are surfaced as human-readable messages from the MCP server to make debugging straightforward.
Source & License
Repository: https://github.com/tomekkorbak/strava-mcp-server
License: MIT (see repository LICENSE)