
Strava API 集成的 MCP 服务器
概览
一个提供 Strava API 访问的模型上下文协议(MCP)服务器。它允许语言模型从 Strava API 查询运动员活动数据。 - get_activities(limit: int = 10):获取认证运动员最近的活动 - get_activities_by_date_range(start_date: str, end_date: str, limit: int = 30): 获取特定日期范围内的活动 - get_activity_by_id(activity_id: int):获取特定活动的详细信息 - get_recent_activities(days: int = 7, limit: int = 10):获取过去X天的活动 日期应以ISO格式(YYYY-MM-DD)提供。 服务器返回具有一致字段名称和单位的活动数据: 要使用该服务器,您需要使用 Strava API 进行身份验证。请按照以下步骤操作: 1. 创建一个 Strava API 应用:- 进入 Strava API 设置 - 创建一个应用程序获取你的客户端 ID 和客户端秘密 - 将授权回调域设置为 localhost 2.
概述(AI 翻译)
一个提供 Strava API 访问的模型上下文协议(MCP)服务器。它允许语言模型从 Strava API 查询运动员活动数据。
可用工具
服务器会提供以下工具:
活动查询
get_activities(limit: int = 10):获取认证运动员的最新活动get_activities_by_date_range(start_date: str, end_date: str, limit: int = 30):获取特定日期范围内的活动get_activity_by_id(activity_id: int):获取特定活动的详细信息get_recent_activities(days: int = 7, limit: int = 10):获取过去X天的活动
日期应以ISO格式(YYYY-MM-DD)提供。
活动数据格式
服务器返回具有一致字段名称和单位的活动数据:
| 田野 | 描述 | 单位 |
|---|---|---|
name |
活动名称 | - |
sport_type |
运动类型 | - |
start_date |
开始日期和时间 | ISO 8601 |
distance_metres |
距离 | 米 |
elapsed_time_seconds |
总经过时间 | 秒 |
moving_time_seconds |
移动时间 | 秒 |
average_speed_mps |
平均速度 | 米每秒 |
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Strava MCP Server
A Model Context Protocol (MCP) server that provides access to the Strava API. It allows language models to query athlete activities data from the Strava API.
Available Tools
The server exposes the following tools:
Activities Queries
get_activities(limit: int = 10): Get the authenticated athlete’s recent activitiesget_activities_by_date_range(start_date: str, end_date: str, limit: int = 30): Get activities within a specific date rangeget_activity_by_id(activity_id: int): Get detailed information about a specific activityget_recent_activities(days: int = 7, limit: int = 10): Get activities from the past X days
Dates should be provided in ISO format (YYYY-MM-DD).
Activity Data Format
The server returns activity data with consistent field names and units:
| Field | Description | Unit |
|---|---|---|
name |
Activity name | - |
sport_type |
Type of sport | - |
start_date |
Start date and time | ISO 8601 |
distance_metres |
Distance | meters |
elapsed_time_seconds |
Total elapsed time | seconds |
moving_time_seconds |
Moving time | seconds |
average_speed_mps |
Average speed | meters per second |
max_speed_mps |
Maximum speed | meters per second |
total_elevation_gain_metres |
Total elevation gain | meters |
elev_high_metres |
Highest elevation | meters |
elev_low_metres |
Lowest elevation | meters |
calories |
Calories burned | kcal |
start_latlng |
Start coordinates | [lat, lng] |
end_latlng |
End coordinates | [lat, lng] |
Authentication
To use this server, you’ll need to authenticate with the Strava API. Follow these steps:
-
Create a Strava API application:
- Go to Strava API Settings
- Create an application to get your Client ID and Client Secret
- Set the Authorization Callback Domain to
localhost
-
Get your refresh token:
- Use the included
get_strava_token.pyscript:
python get_strava_token.py- Follow the prompts to authorize your application
- The script will save your tokens to a
.envfile
- Use the included
-
Set environment variables: The server requires the following environment variables:
安装
uvx strava-mcp-server配置
{
"mcpServers": {
"strava": {
"command": "uvx",
"args": [
"strava-mcp-server"
],
"env": {
"STRAVA_CLIENT_ID": "YOUR_CLIENT_ID",
"STRAVA_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
"STRAVA_REFRESH_TOKEN": "YOUR_REFRESH_TOKEN"
}
}
}
}