Skip to main content

Strava integration for MCP

Project description

Strava MCP Server

CI/CD Pipeline

A Model Context Protocol (MCP) server for interacting with the Strava API. Supports both stdio and streamable-http transports.

User Guide

Installation

You can install Strava MCP with uvx:

uvx strava-mcp

Docker

Build and run the server with Docker (defaults to streamable-http on port 8000):

docker build -t strava-mcp .
docker run -p 8000:8000 \
  -e STRAVA_CLIENT_ID=your_client_id \
  -e STRAVA_CLIENT_SECRET=your_client_secret \
  strava-mcp

Setting Up Strava Credentials

  1. Create a Strava API Application:

  2. Configure Your Credentials: Create a credentials file (e.g., ~/.ssh/strava.sh):

    export STRAVA_CLIENT_ID=your_client_id
    export STRAVA_CLIENT_SECRET=your_client_secret
    
  3. Configure Claude Desktop (stdio transport): Add the following to your Claude configuration (/Users/<username>/Library/Application Support/Claude/claude_desktop_config.json):

    "strava": {
        "command": "bash",
        "args": [
            "-c",
            "source ~/.ssh/strava.sh && uvx strava-mcp"
        ]
    }
    
  4. HTTP transport (e.g. for remote or Docker deployments):

    strava-mcp --transport streamable-http --host 0.0.0.0 --port 8000
    

Authentication

The first time you use the Strava MCP tools:

  1. An authentication flow will automatically start
  2. Your browser will open to the Strava authorization page
  3. After authorizing, you'll be redirected back to a local page
  4. Your refresh token will be saved automatically for future use

Available Tools

Get User Activities

Retrieves activities for the authenticated user.

Parameters:

  • before (optional): Epoch timestamp for filtering
  • after (optional): Epoch timestamp for filtering
  • page (optional): Page number (default: 1)
  • per_page (optional): Number of items per page (default: 30)

Get Activity

Gets detailed information about a specific activity.

Parameters:

  • activity_id: The ID of the activity
  • include_all_efforts (optional): Include segment efforts (default: false)

Get Activity Segments

Retrieves segments from a specific activity.

Parameters:

  • activity_id: The ID of the activity

Developer Guide

Project Setup

  1. Clone the repository:

    git clone git@github.com:piwibardy/strava-mcp-http.git
    cd strava-mcp-http
    
  2. Install dependencies:

    uv sync
    
  3. Set up environment variables:

    export STRAVA_CLIENT_ID=your_client_id
    export STRAVA_CLIENT_SECRET=your_client_secret
    

    Alternatively, create a .env file with these variables.

Running in Development Mode

Run the server with MCP CLI:

mcp dev strava_mcp/main.py

Or with HTTP transport:

uv run strava-mcp --transport streamable-http --port 8000

Manual Authentication

You can get a refresh token manually by running:

python get_token.py

Project Structure

  • strava_mcp/: Main package directory
    • __init__.py: Package initialization
    • config.py: Configuration settings using pydantic-settings
    • models.py: Pydantic models for Strava API entities
    • api.py: Low-level API client for Strava
    • auth.py: Strava OAuth authentication implementation
    • oauth_server.py: Standalone OAuth server implementation
    • service.py: Service layer for business logic
    • server.py: MCP server implementation
    • main.py: Main entry point (argparse for transport/host/port)
  • tests/: Unit tests
  • Dockerfile: Multi-stage Docker build
  • get_token.py: Utility script to get a refresh token manually

Running Tests

pytest

Publishing to PyPI

Building the package

uv build

Publishing to PyPI

# Publish to Test PyPI first
uv publish --index testpypi

# Publish to PyPI
uv publish

License

MIT License

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strava_mcp_http-0.5.1.tar.gz (140.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strava_mcp_http-0.5.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file strava_mcp_http-0.5.1.tar.gz.

File metadata

  • Download URL: strava_mcp_http-0.5.1.tar.gz
  • Upload date:
  • Size: 140.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for strava_mcp_http-0.5.1.tar.gz
Algorithm Hash digest
SHA256 da9f6181e3bb360193a93cdf5230f3fc67ce05ea2e5c9b7b3e7ac2293986f6a1
MD5 b1bb07a1cebe979ec0c6b516912cc4b8
BLAKE2b-256 ddcdac22b55d178e331650d0094ccce46e821e9141cc48e5821a8ef6f5915cbc

See more details on using hashes here.

File details

Details for the file strava_mcp_http-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for strava_mcp_http-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f970a4619d5fbd64d2cd914401f274cf22b3e2131868294664d0261372316fa3
MD5 1cd0602c43d55e1ac5606c68472ba533
BLAKE2b-256 cdbc3fa1d5e6c8e9b0694a7508dd07e8bae1f1568818839dc5c5ea2693c6ddbe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page