MCP HubMCP Hub
tomekkorbak

strava-mcp-server

by: tomekkorbak

strava mcp server

8created 28/02/2025
Visit
strava

📌Overview

Purpose: The Strava MCP Server serves as a bridge for language models to access and query athlete activities data via the Strava API.

Overview: This server implements the Model Context Protocol (MCP), enabling seamless queries of athlete activity data from Strava. It provides structured access to various metrics related to an athlete's performance.

Key Features:

  • Activities Queries: A set of functions to retrieve various activity data:

    • get_activities: Fetches recent activities of the authenticated athlete.
    • get_activities_by_date_range: Retrieves activities within a specified date range.
    • get_activity_by_id: Provides detailed information for a specified activity.
    • get_recent_activities: Allows querying of activity data from the past days.
  • Structured Data Format: Returns consistent activity data with standardized field names and units, making it easy to interpret and utilize the information.

  • Authentication Flow: Requires authentication via the Strava API, ensuring secure access to personalized athlete data. Clear instructions are provided for obtaining necessary tokens.


Strava MCP Server

A Model Context Protocol (MCP) server that provides access to the Strava API. It allows language models to query athlete activities data from the Strava API.

Available Tools

The server exposes the following tools:

Activities Queries

  • get_activities(limit: int = 10): Get the authenticated athlete's recent activities.
  • get_activities_by_date_range(start_date: str, end_date: str, limit: int = 30): Get activities within a specific date range.
  • get_activity_by_id(activity_id: int): Get detailed information about a specific activity.
  • get_recent_activities(days: int = 7, limit: int = 10): Get activities from the past X days.

Dates should be provided in ISO format (YYYY-MM-DD).

Activity Data Format

The server returns activity data with consistent field names and units:

FieldDescriptionUnit
nameActivity name-
sport_typeType of sport-
start_dateStart date and timeISO 8601
distance_metresDistancemeters
elapsed_time_secondsTotal elapsed timeseconds
moving_time_secondsMoving timeseconds
average_speed_mpsAverage speedmeters per second
max_speed_mpsMaximum speedmeters per second
total_elevation_gain_metresTotal elevation gainmeters
elev_high_metresHighest elevationmeters
elev_low_metresLowest elevationmeters
caloriesCalories burnedkcal
start_latlngStart coordinates[lat, lng]
end_latlngEnd coordinates[lat, lng]

Authentication

To use this server, you'll need to authenticate with the Strava API. Follow these steps:

  1. Create a Strava API application:

    • Go to Strava API Settings and create an application to obtain your Client ID and Client Secret.
    • Set the Authorization Callback Domain to localhost.
  2. Get your refresh token:

    • Use the included get_strava_token.py script:
      python get_strava_token.py
      
    • Follow the prompts to authorize your application. The script will save your tokens to a .env file.
  3. Set environment variables: The server requires the following environment variables:

    • STRAVA_CLIENT_ID: Your Strava API Client ID
    • STRAVA_CLIENT_SECRET: Your Strava API Client Secret
    • STRAVA_REFRESH_TOKEN: Your Strava API Refresh Token

Usage

Claude for Desktop

Update your claude_desktop_config.json to include the following configuration:

{
    "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"
            }
        }
    }
}

Claude Web

For Claude Web, you can run the server locally and connect it using the MCP extension.

Example Queries

Once connected, you can ask Claude questions like:

  • "What are my recent activities?"
  • "Show me my activities from last week."
  • "What was my longest run in the past month?"
  • "Get details about my latest cycling activity."

Error Handling

The server provides human-readable error messages for common issues, including:

  • Invalid date formats
  • API authentication errors
  • Network connectivity problems

License

This project is licensed under the MIT License - see the LICENSE file for details.