mcp-server-strava

mcp-server-strava

3.5

Integration for workout analysis and recommendations based on Strava data using Model Context Protocol SDK.

The MCP Server Strava integration allows users to analyze their workouts and receive personalized training recommendations by leveraging data from Strava. This integration utilizes the Model Context Protocol SDK to facilitate seamless communication and data exchange between the Strava API and the user's application. It supports features such as automatic token updates, rate limiting for API requests, and provides a structured approach to accessing and analyzing workout data. The integration is designed to work with Python 3.10+ and is recommended to be used with the 'uv' tool for installation and management. Users can set up their environment by configuring the Strava API settings and obtaining necessary access tokens. The integration also includes resources and tools for accessing activity details, training zones, and analyzing training loads.

Features

  • Workout analysis from Strava
  • Training recommendations
  • Automatic token updates
  • Rate limiting for API requests

MCP Tools

  • analyze_activity(activity_id): Analyzes a specific workout activity.
  • analyze_training_load(activities): Analyzes the training load from multiple activities.
  • get_activity_recommendations(): Provides training recommendations based on activities.

MCP Resources

  • {'name': 'strava://activities', 'description': 'List of activities.'}
  • {'name': 'strava://activities/{id}', 'description': 'Details of a specific activity.'}
  • {'name': 'strava://athlete/zones', 'description': 'Training zones of the athlete.'}
  • {'name': 'strava://athlete/clubs', 'description': 'Clubs associated with the athlete.'}
  • {'name': 'strava://gear/{gear_id}', 'description': 'Information about specific gear.'}

Usage with Different Platforms

mcp

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}
            ]
        }
    }
    """