logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

mcp-strava-analytics-engine

A robust backend service integrating fitness metrics from Strava via its API, employing the Model Context Protocol (MCP) SDK for advanced session evaluation and tailored performance advice. It natively handles secure token lifecycle management and incorporates traffic shaping (rate limiting) for external service calls.

Author

mcp-strava-analytics-engine logo

rbctmz

MIT License

Quick Info

GitHub GitHub Stars 0
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

apisapirbctmzrequests rbctmzstrava leveragingapi requests

Strava Data Processor with Model Context Protocol (MCP) Integration

CI Status Code Coverage Percentage Python Version Support Software License Type Code Style Enforcer

This solution bridges raw athletic performance data sourced from the Strava platform with the analytical capabilities of the Model Context Protocol SDK to derive actionable insights and personalized coaching suggestions.

✨ Key Features

  • Ingestion and processing of exercise logs from Strava.
  • Generation of prescriptive training guidance.
  • Automated refreshing of necessary authorization credentials.
  • Implementation of request throttling mechanisms to respect API quotas.

📚 Prerequisites

  • Runtime Environment: Python 3.10 or newer.
  • Access to Claude Desktop.
  • An active Strava account.
  • [uv] dependency manager (highly recommended for setup).

🛠️ Installation Guide

bash

Obtain the source code repository

git clone https://github.com/rbctmz/mcp-server-strava.git cd mcp-server-strava

Recommended installation using uv

curl -LsSf https://astral.sh/uv/install.sh | sh uv pip install .

Development environment setup

uv pip install -e ".[dev]"

Installing the MCP Framework

bash uv add "mcp[cli]"

📝 Configuration

Securing Strava API Credentials

  1. Navigate to the API Settings portal.
  2. Register a new application:
  3. Application Identifier: MCP Strava Integration
  4. Domain Classification: Training Analysis
  5. Site URL: http://localhost
  6. Redirect URI: localhost

Environment Variable Setup

  1. Duplicate the template for environment variables:

bash cp .env-template .env

  1. Execute the authentication script to acquire initial access tokens:

bash python scripts/auth.py

  1. Verify operational status:

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

🌐 Resource Access & Tooling

Available Interface Endpoints and Utility Functions

Interface Type Identifier Description
Data Fetcher strava://activities Collection of user activities
Data Fetcher strava://activities/{id} Specific activity record
Metric Source strava://athlete/zones Athlete's physiological metrics zones
Data Fetcher strava://athlete/clubs Affiliated athletic organizations
Data Fetcher strava://gear/{gear_id} Equipment details utilized
Function Call analyze_activity(activity_id) Detailed assessment of a single workout
Function Call analyze_training_load(activities) Aggregated physiological strain calculation
Function Call get_activity_recommendations() Suggested future training protocols

Operational Examples

python from mcp import ClientSession

Retrieving user activity history

async with ClientSession() as session: activity_list = await session.read_resource("strava://activities") single_record = await session.read_resource("strava://activities/12345678")

Performing granular workout analysis

analysis_output = analyze_activity(activity_id="12345678") """ { "type": "Run", "distance": 5000, "moving_time": 1800, "analysis": { "pace": 5.5, # minutes per kilometer "effort": "Moderate" } } """

Summarizing cumulative training stress

load_summary = analyze_training_load(activities) """ { "activities_count": 10, "total_distance": 50.5, # kilometers "total_time": 5.2, # hours "heart_rate_zones": { "easy": 4, "medium": 4, "hard": 2 } } """

Fetching established physiological boundaries

async with ClientSession() as session: zones_data = 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} ] } } """

💻 Development Workflow

Quality Assurance and Security Posture

  • Quality Metric
  • Test Results
  • Code Formatting Standard

Continuous Integration Checks (GitHub Actions)

Check Type Utility Purpose
Syntax/Style ruff Code linting and formatting enforcement
Testing Suite pytest Unit and integration verification
Coverage Report pytest-cov Measurement of code path execution

Security and Secrets Management

  1. Protection of sensitive credentials:
  2. Exclusion of .env via .gitignore.
  3. Utilization of GitHub Secrets for CI/CD contexts.
  4. API request limits enforced: 100 requests per 15-minute interval.

  5. Secret configuration procedure:

bash # Configure within GitHub Repository Settings → Secrets → Actions STRAVA_CLIENT_ID= STRAVA_CLIENT_SECRET= STRAVA_REFRESH_TOKEN=

Contribution Guidelines

  1. Fork the primary repository.
  2. Install required dependencies: uv pip install -e ".[dev]".
  3. Establish a feature branch: git checkout -b feature/topic-name.
  4. Validate all changes:

bash ruff format . ruff check . pytest --cov=src

  1. Submit a comprehensive Pull Request.

📞 Support & Contact

📜 License

This project is governed by the MIT License.


Note: The following sections are derived from the original Wikipedia context provided for stylistic padding and do not directly describe the MCP tool itself, although they conceptually relate to asynchronous data transfer methods.

See Also

`