ST

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.

Quick Install
npx -y @tomekkorbak/strava-mcp-server

Overview

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):

pip install strava-mcp-server

You can run the server through an MCP runtime (uvx) once installed:

uvx strava-mcp-server

Authentication and configuration:

  1. 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
  2. Obtain a refresh token:

    • Use the included helper script to authorize and persist tokens:
python get_strava_token.py
# follow prompts; this saves tokens to a local .env file
  1. 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:

export STRAVA_CLIENT_ID=your_client_id
export STRAVA_CLIENT_SECRET=your_client_secret
export STRAVA_REFRESH_TOKEN=your_refresh_token
uvx strava-mcp-server

Claude Desktop example (add to claude_desktop_config.json):

{
  "mcpServers": {
    "strava": {
      "command": "uvx",
      "args": ["strava-mcp-server"],
      "env": {
        "STRAVA_CLIENT_ID": "YOUR_CLIENT_ID",
        "STRAVA_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
        "STRAVA_REFRESH_TOKEN": "YOUR_REFRESH_TOKEN"
      }
    }
  }
}

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.

FieldDescriptionUnit
nameActivity name
sport_typeSport type (e.g., Run, Ride)
start_dateStart datetimeISO 8601
distance_metresDistancemetres
elapsed_time_secondsTotal elapsed timeseconds
moving_time_secondsMoving timeseconds
average_speed_mpsAverage speedmeters/second
max_speed_mpsMaximum speedmeters/second
total_elevation_gain_metresTotal elevation gainedmetres
elev_high_metresHighest elevationmetres
elev_low_metresLowest elevationmetres
caloriesEstimated calorieskcal
start_latlngStart coordinates[lat, lng]
end_latlngEnd 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)