Skip to main content
Glama
mcp-server-strava

mcp-server-strava

by rbctmz

Strava API 与模型上下文协议 (MCP) SDK 集成

CI编解码器Python许可证:MIT拉夫

使用模型上下文协议 SDK 集成基于 Strava 数据的训练分析和建议。

🚀 功能

  • Strava 锻炼分析

  • 培训建议

  • 自动令牌更新

  • API 请求的速率限制

Related MCP server: Strava MCP Server

📋 要求

⚙️ 安装

# Клонируем репозиторий
git clone https://github.com/rbctmz/mcp-server-strava.git
cd mcp-server-strava

# Установка через uv (рекомендуется)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install .

# Установка в режиме разработки
uv pip install -e ".[dev]"

安装 MCP SDK

uv add "mcp[cli]"

🔧 设置

设置 Strava API

  1. 前往API 设置页面

  2. 创建应用程序:

    • 应用程序名称:MCP Strava Integration

    • 类别:训练分析

    • 网站: http://localhost

    • 授权回调域:localhost

设置环境

  1. 创建包含环境变量的文件:

    cp .env-template .env
  2. 获取访问令牌:

    python scripts/auth.py
  3. 检查设置:

    mcp dev src/server.py
    curl -X GET "http://localhost:8000/activities"

📚 API 和示例

资源和工具

类型

姓名

描述

资源

strava://activities

活动列表

资源

strava://activities/{id}

活动详情

资源

strava://athlete/zones

训练区

资源

strava://athlete/clubs

运动员俱乐部

资源

strava://gear/{gear_id}

设备信息

工具

analyze_activity(activity_id)

训练分析

工具

analyze_training_load(activities)

负载分析

工具

get_activity_recommendations()

建议

使用示例

from mcp import ClientSession

# Получение активностей
async with ClientSession() as session:
    activities = await session.read_resource("strava://activities")
    activity = await session.read_resource("strava://activities/12345678")

# Анализ тренировки
result = analyze_activity(activity_id="12345678")
"""
{
    "type": "Run",
    "distance": 5000,
    "moving_time": 1800,
    "analysis": {
        "pace": 5.5,  # мин/км
        "effort": "Средняя"
    }
}
"""

# Анализ нагрузки
summary = analyze_training_load(activities)
"""
{
    "activities_count": 10,
    "total_distance": 50.5,  # км
    "total_time": 5.2,      # часы
    "heart_rate_zones": {
        "easy": 4,    # ЧСС < 120
        "medium": 4,  # ЧСС 120-150
        "hard": 2     # ЧСС > 150
    }
}
"""

# Получение тренировочных зон
async with ClientSession() as session:
    zones = await session.read_resource("strava://athlete/zones")
    """
    {
        "heart_rate": {
            "custom_zones": true,
            "zones": [
                {"min": 0, "max": 120, "name": "Z1 - Recovery"},
                {"min": 120, "max": 150, "name": "Z2 - Endurance"},
                {"min": 150, "max": 170, "name": "Z3 - Tempo"},
                {"min": 170, "max": 185, "name": "Z4 - Threshold"},
                {"min": 185, "max": -1, "name": "Z5 - Anaerobic"}
            ]
        },
        "power": {
            "zones": [
                {"min": 0, "max": 180},
                {"min": 181, "max": 250},
                {"min": 251, "max": 300},
                {"min": 301, "max": 350},
                {"min": 351, "max": -1}
            ]
        }
    }
    """

🛠 开发

CI/CD 和安全

  • 覆盖范围

  • 测试

  • 拉夫

GitHub Actions 中的检查

类型

工具

描述

代码检查

皱领

代码格式化和分析

测试

pytest

单元和集成测试

涂层

pytest-cov

代码覆盖率报告

安全和秘密

  1. 代币保护:

    • .env到.gitignore

    • GitHub 的 CI/CD 秘诀

    • 速率限制:100 个请求/15 分钟

  2. 设置秘密:

    # В GitHub: Settings → Secrets → Actions
    STRAVA_CLIENT_ID=<client_id>
    STRAVA_CLIENT_SECRET=<client_secret>
    STRAVA_REFRESH_TOKEN=<refresh_token>

贡献

  1. 分叉存储库

  2. 安装依赖项: uv pip install -e ".[dev]"

  3. 创建分支: git checkout -b feature/name

  4. 检查更改:

    ruff format .
    ruff check .
    pytest --cov=src
  5. 创建拉取请求

📫 支持

📄 许可证

麻省理工学院

Available Tools

4 tools
analyze_activityC

Анализ активности из Strava

Args:
    activity_id: ID активности (строка или число)
Returns:
    dict: Результаты анализа активности

Inputs: activity_id (required).

analyze_training_loadD

Анализ тренировочной нагрузки

Inputs: activities (required).

get_activity_by_idC

Get activity details from Strava

Args:
    activity_id (Union[str, int]): Activity ID to fetch
    
Returns:
    Dict: Activity details including type, distance, time and other metrics

Inputs: activity_id (required).

get_activity_recommendationsB

Получить рекомендации по тренировкам на основе анализа последних активностей

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.2/5.0

    Scored across 4 tools

    Disambiguation2/5

    There is significant overlap between analyze_activity and get_activity_by_id, as both appear to retrieve and process activity data based on activity_id, making them easily confused. analyze_training_load and get_activity_recommendations are more distinct but still related to activity analysis, creating some ambiguity in the set.

    Naming Consistency3/5

    The naming is mixed with both English and Russian terms (e.g., analyze_activity vs. analyze_training_load in English, but get_activity_recommendations in Russian description), and the verb patterns vary (analyze_ vs. get_). While readable, this inconsistency reduces predictability and coherence.

    Tool Count3/5

    With 4 tools, the count is borderline thin for a Strava server, as it might lack broader functionality like user management, activity creation, or social features. However, it covers core analysis aspects, so it's not severely mismatched but feels slightly under-scoped.

    Completeness2/5

    The tool set is focused on activity analysis and recommendations, but there are significant gaps: no CRUD operations for activities (e.g., create, update, delete), no user profile or authentication tools, and no social or leaderboard features typical of Strava's domain. This will likely cause agent failures for common workflows.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers