Skip to main content
Glama
mcp-server-strava

mcp-server-strava

by rbctmz

Strava API와 MCP(Model Context Protocol) SDK 통합

씨아이코덱파이썬라이센스: MIT주름 옷깃

Model Context Protocol SDK를 사용하여 Strava 데이터를 기반으로 한 교육 분석 및 추천을 통합합니다.

🚀 특징

  • Strava에서 운동 분석

  • 교육 권장 사항

  • 자동 토큰 업데이트

  • API 요청에 대한 속도 제한

Related MCP server: Strava MCP Server

📋 요구 사항

⚙️ 설치

지엑스피1

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-cov

코드 커버리지 보고서

보안 및 비밀

  1. 토큰 보호:

    • .env 에서 .gitignore 로

    • CI/CD를 위한 GitHub의 비밀

    • 속도 제한: 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. 풀 리퀘스트 만들기

📫 지원

📄 라이센스

MIT

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