Strava Training MCP

Strava Training MCP

Provides comprehensive access to Strava API for marathon training and race analysis, enabling language models to query athlete data, analyze training patterns, track performance metrics, monitor heart rate zones, and detect injury risks.

Category
访问服务器

README

Strava Training MCP

License: MIT Python 3.12

A comprehensive Model Context Protocol (MCP) server that provides full access to the Strava API, specifically designed for marathon training and race analysis. This server enables language models to query detailed athlete data, analyze training patterns, track performance metrics, and plan races.

Features

  • Comprehensive Activity Data: Access detailed activity information including pace, heart rate, power, cadence, GPS coordinates, and more
  • Training Analysis: Weekly and monthly training metrics, pace trends, and long run analysis
  • Detailed Streams: Time-series data for analyzing performance throughout activities
  • Laps & Splits: Analyze pace consistency and splits for race preparation
  • Zone Analysis: Heart rate and power zone data for training intensity analysis
  • Athlete Statistics: Year-to-date totals, personal records, and achievement tracking
  • Marathon Training Tools: Heart rate zone analysis, training load monitoring, injury risk detection, and recovery analysis
  • Built-in Authentication: Streamlined OAuth flow with MCP tools - no separate scripts needed
  • Multiple Transports: Support for stdio, SSE, and streamable-http transports

Installation

Using uv (Recommended)

# Clone the repository
git clone <your-repo-url>
cd strava-training-mcp

# Install dependencies
uv sync

# Run the server
uv run src/server.py --transport sse --port 9186

Using pip

pip install strava-training-mcp

Quick Start

  1. Get Strava API credentials from Strava API Settings
  2. Start the server (it will guide you through authentication)
  3. Use MCP tools to authenticate and query your Strava data

See QUICK_START.md for detailed authentication instructions.

Available Tools

Authentication & Setup

  • get_strava_auth_token(client_id, client_secret, auth_code): Complete authentication in one step (recommended)
  • save_credentials(client_id, client_secret): Save your Strava API credentials
  • get_auth_url(redirect_uri): Get the authorization URL using stored credentials
  • complete_strava_auth(auth_code): Complete authentication with authorization code
  • check_auth_status(): Check if authentication is configured and tokens are available

Basic Activity Queries

  • get_activities(limit): Get recent activities
  • get_activities_by_range(start_date, end_date, limit): Get activities within a date range
  • get_activity_by_id(activity_id): Get detailed information about a specific activity
  • get_recent(days, limit): Get activities from the past X days
  • get_runs_by_range(start_date, end_date, limit): Get running activities within a date range

Detailed Activity Analysis

  • get_activity_streams(activity_id, keys): Get time-series data (heart rate, pace, power, cadence, GPS, etc.)
  • get_activity_laps(activity_id): Get laps/splits for analyzing pace consistency
  • get_activity_zones(activity_id): Get heart rate and power zone data

Athlete Statistics

  • get_athlete_stats(athlete_id): Get athlete statistics including YTD totals, PRs, and achievements

Training Analysis

  • analyze_weekly(start_date, end_date): Analyze weekly training metrics
  • analyze_monthly(year, month): Analyze monthly training with weekly breakdown
  • find_long_runs(start_date, end_date, min_distance_km): Find long runs within a date range
  • analyze_pace_trends(start_date, end_date): Analyze pace trends over time

Heart Rate Zone & Injury Prevention

  • analyze_hr_zones(start_date, end_date): Analyze heart rate zone distribution (80/20 principle)
  • analyze_training_load(start_date, end_date): Analyze training load and identify injury risk indicators
  • analyze_hr_trends(start_date, end_date, reference_pace_min_per_km): Track heart rate trends to monitor fitness improvements
  • analyze_recovery(start_date, end_date): Analyze recovery patterns including rest days and training stress distribution

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

Usage

Claude for Desktop

Update your claude_desktop_config.json:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

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

Running Locally

# SSE transport (recommended for remote connections)
uv run src/server.py --transport sse --port 9186

# Streamable-http transport (stateless HTTP POST)
uv run src/server.py --transport streamable-http --port 9186

# stdio transport (default, for local use)
uv run src/server.py --transport stdio

Example Queries

Authentication

  • "Check my Strava authentication status"
  • "Save my Strava credentials: client_id=12345, client_secret=abc123"
  • "Get the authorization URL for Strava OAuth"
  • "Complete Strava authentication with code XYZ789"

Basic Queries

  • "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 run"

Marathon Training Analysis

  • "Analyze my weekly training from last week"
  • "Show me my long runs from the past month"
  • "What's my pace trend over the last 3 months?"
  • "Analyze my training for January 2024"

Heart Rate Zone & Injury Prevention

  • "Analyze my heart rate zones for the past month"
  • "Check my training load and injury risk for the last 4 weeks"
  • "Show me my heart rate trends over the past 3 months"
  • "Analyze my recovery patterns - am I getting enough rest?"

Activity Data Format

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

Field Description Unit
id Activity ID -
name Activity name -
sport_type Type of sport -
start_date Start date and time ISO 8601
distance_metres Distance meters
elapsed_time_seconds Total elapsed time seconds
moving_time_seconds Moving time seconds
average_speed_mps Average speed meters per second
max_speed_mps Maximum speed meters per second
average_cadence_rpm Average cadence revolutions per minute
average_heartrate_bpm Average heart rate beats per minute
max_heartrate_bpm Maximum heart rate beats per minute
average_watts Average power watts
weighted_average_watts Weighted average power watts
kilojoules Energy output kilojoules
total_elevation_gain_metres Total elevation gain meters
elev_high_metres Highest elevation meters
elev_low_metres Lowest elevation meters
calories Calories burned kcal
workout_type Workout type (0=default, 1=race, 2=long run, 3=workout) -
suffer_score Perceived exertion score -
start_latlng Start coordinates [lat, lng]
end_latlng End coordinates [lat, lng]

Development

Project Structure

strava-training-mcp/
├── src/
│   ├── server.py      # Main MCP server implementation
│   ├── client.py      # Strava API client wrapper
│   ├── tools.py       # MCP tool definitions
│   └── auth.py        # Authentication utilities
├── README.md
├── QUICK_START.md
├── AUTHENTICATION.md
├── STEP_BY_STEP_AUTH.md
└── pyproject.toml

Running Tests

# Run linting
uv run ruff check src/

# Type checking
uv run mypy src/

Authentication

The MCP server includes built-in authentication tools. See AUTHENTICATION.md for detailed instructions.

Quick Authentication

  1. Get your Client ID and Client Secret from Strava API Settings
  2. Use the MCP tool: get_strava_auth_token(client_id, client_secret, auth_code)
  3. Restart the server

For step-by-step instructions, see STEP_BY_STEP_AUTH.md.

License

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

Credits

This project is inspired by and builds upon the excellent work from tomekkorbak/strava-mcp-server. The original project provided the foundation and inspiration for this enhanced version, which adds comprehensive training analysis features, improved authentication flow, and marathon-specific tools.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选