Skip to main content
Glama
mcp-server-strava

mcp-server-strava

by rbctmz

Strava API と Model Context Protocol (MCP) SDK の統合

CIコーデックパイソンライセンス: MITラフ

Model Context Protocol 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 統合

    • カテゴリー: トレーニング分析

    • ウェブサイト: 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へ

    • CI/CD のための GitHub Secrets

    • レート制限: 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
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers