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

rbctmz
Quick Info
Actions
Tags
Strava Data Processor with Model Context Protocol (MCP) Integration
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
- Navigate to the API Settings portal.
- Register a new application:
- Application Identifier: MCP Strava Integration
- Domain Classification: Training Analysis
- Site URL: http://localhost
- Redirect URI: localhost
Environment Variable Setup
- Duplicate the template for environment variables:
bash cp .env-template .env
- Execute the authentication script to acquire initial access tokens:
bash python scripts/auth.py
- 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
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
- Protection of sensitive credentials:
- Exclusion of
.envvia.gitignore. - Utilization of GitHub Secrets for CI/CD contexts.
-
API request limits enforced: 100 requests per 15-minute interval.
-
Secret configuration procedure:
bash
# Configure within GitHub Repository Settings → Secrets → Actions
STRAVA_CLIENT_ID=
Contribution Guidelines
- Fork the primary repository.
- Install required dependencies:
uv pip install -e ".[dev]". - Establish a feature branch:
git checkout -b feature/topic-name. - Validate all changes:
bash ruff format . ruff check . pytest --cov=src
- Submit a comprehensive Pull Request.
📞 Support & Contact
- Issue Tracker: File a new issue
- Direct Contact (Telegram): @greg_kisel
📜 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.
