strava-mcp
Enables querying and analyzing personal Strava activity data through natural language, including activities, segments, gear, and training trends.
README
strava-mcp
A local Strava data pipeline and MCP server. Syncs your Strava activities to a SQLite database and exposes everything to Claude via the Model Context Protocol.
What it does
-
strava_downloader.py— fetches your athlete profile, activities (with laps, splits, segment efforts, and HR/power zones), gear, routes, and starred segments from the Strava API and stores them locally in SQLite. Run it as a cron job for incremental daily syncs. -
mcp_server.py— an HTTP streamable MCP server (with bearer token auth) that gives Claude tools to query your Strava data conversationally.
Setup
1. Install dependencies
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
2. Configure credentials
Copy .env.example to .env and fill in your Strava credentials:
cp .env.example .env
You need a Strava API application and an OAuth2 refresh token:
- Go to strava.com/settings/api and create an app
- Authorize your app to get an authorization code:
https://www.strava.com/oauth/authorize?client_id=YOUR_CLIENT_ID &redirect_uri=http://localhost&response_type=code &scope=activity:read_all,profile:read_all - Exchange the code for tokens:
curl -X POST https://www.strava.com/oauth/token \ -d client_id=YOUR_CLIENT_ID \ -d client_secret=YOUR_CLIENT_SECRET \ -d code=AUTHORIZATION_CODE \ -d grant_type=authorization_code - Copy
access_token,refresh_token, andexpires_atinto.env
For the MCP server, generate a bearer token:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
Add it as STRAVA_MCP_AUTH_TOKEN in .env.
3. Sync your data
# First run — last 30 days (fast, to verify everything works)
.venv/bin/python strava_downloader.py --days 30
# Full historical sync (2+ years, respects Strava rate limits automatically)
.venv/bin/python strava_downloader.py
# Re-fetch laps/zones for all activities (if you ran a summary-only import before)
.venv/bin/python strava_downloader.py --full
The downloader automatically refreshes expired OAuth2 tokens and saves them back to .env.
4. Start the MCP server
.venv/bin/python mcp_server.py
This starts an HTTP server on port 8080 (default). Connect your MCP client with:
{
"mcpServers": {
"strava": {
"url": "http://localhost:8080/mcp/",
"headers": {
"Authorization": "Bearer YOUR_STRAVA_MCP_AUTH_TOKEN"
}
}
}
}
For stdio transport (Claude Desktop local):
.venv/bin/python mcp_server.py --transport stdio
Cron job (incremental sync)
Add to your crontab for a daily sync at 6 AM:
0 6 * * * cd /path/to/strava-mcp && .venv/bin/python strava_downloader.py >> /var/log/strava-sync.log 2>&1
Each incremental run picks up from the most recent activity already in the database.
What Claude can query
Resources (snapshot data):
- Athlete profile with lifetime totals
- All activities (with pace, speed, and unit conversions pre-computed)
- Aggregate stats by sport type
- Monthly training trends
- Recent activities (last 30 days)
- Gear / equipment list
Tools (parameterized queries):
query_activities— filter by sport, date range, distance, HR, power, commute flagget_activity_details— full detail for one activity: laps, metric splits, zone distribution, segment effortsget_segment_efforts— your history on any segment (progression over time)get_power_analysis— power stats with FTP estimateget_training_trends— weekly or monthly aggregates for any metricget_gear_stats— distance logged per bike or shoeget_routes— your saved routesexecute_sql— custom SELECT queries against any table
Database schema
SQLite database at ./strava_activities.db (configurable via STRAVA_DB_PATH).
| Table | Contents |
|---|---|
athletes |
Athlete profile + YTD/all-time totals |
activities |
All activities — summary + detail fields |
activity_laps |
Lap splits per activity |
activity_splits_metric |
1 km metric splits per activity |
segment_efforts |
Segment efforts within activities |
segments |
Segment master data |
starred_segments |
Your starred segments |
gear |
Bikes and shoes |
routes |
Saved routes |
activity_zones |
HR/power zone distribution per activity |
activity_summary (view) |
Activities with km, pace, speed pre-computed |
monthly_stats (view) |
Aggregated by month + sport type |
Rate limits
Strava enforces 100 requests per 15 minutes and 1000 per day. The downloader:
- Sleeps 0.6s between activity detail fetches
- Automatically waits for the next 15-minute window on a 429 response
- Retries 5xx errors up to 3 times with back-off
Production deployment (Linux)
sudo useradd --system --shell /usr/sbin/nologin strava-mcp
sudo mkdir -p /opt/strava-mcp
# Copy files, set up venv, create .env
sudo cp deploy/strava-mcp.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now strava-mcp
See deploy/strava-mcp.service for the full systemd unit.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。