livetrack-mcp
livetrack-mcp
自主 MCP 服务器,用于轮询 Garmin LiveTrack,将时间序列存储在 SQLite 中,并通过 claude-runner 每 10 分钟触发一次 Claude 分析。
架构
Garmin LiveTrack URL
│
│ (poll every 60 s)
▼
livetrack-mcp (port 38100)
├── poller.py — fetch trackpoints from Garmin API
├── store.py — SQLite time-series persistence (/data/livetrack.db)
├── tracker.py — asyncio scheduling + race-end detection
└── analyzer.py — build prompt, call claude-runner
│
│ POST /run (fire-and-forget)
▼
claude-runner (port 38095)
│
│ claude -p <analysis prompt>
▼
Claude (sonnet)
├── analyze timeseries
├── curl POST /control if thresholds need adjustment
└── mcp__telegram__send_message → coaching push核心设计: livetrack-mcp 是完全自主的——比赛期间无需保持 Claude 会话处于活动状态。Claude 作为无状态分析函数每 10 分钟被调用一次。如果 claude-runner 暂时不可用,下一个分析周期会自动重试。
Related MCP server: Garmin-Strava-mcp
MCP 工具
工具 | 描述 |
| 开始轮询 LiveTrack 分享 URL |
| 停止轮询(比赛结束时也会自动停止) |
| 活动状态、已用时间、陈旧时间、轮询错误 |
| 来自 SQLite 的近期数据 |
| 在比赛中途更新心率/功率阈值 |
| 手动按需分析,绕过计划任务 |
自定义 HTTP 端点
端点 | 方法 | 描述 |
| POST | 在比赛中途更新阈值(由 Claude 通过 Bash 工具中的 curl 调用) |
| GET | 健康检查 — 跟踪状态 + 存储统计信息 |
/control 用法(来自 Claude 的分析提示词)
curl -sf -X POST http://localhost:38100/control \
-H 'Content-Type: application/json' \
-d '{"power_max": 150}'允许的字段:hr_max, hr_min, power_max, power_min, cadence_min, run_hr_max, run_hr_min, run_cadence_min
race_config 字段
字段 | 类型 | 默认值 | 描述 |
| int | — | 骑行心率上限 (bpm) |
| int | — | 骑行心率下限 |
| int | — | ERG 功率上限 (瓦特) |
| int | — | ERG 功率下限 |
| int | — | 最低骑行踏频 (rpm) |
| int | — | 跑步心率上限 |
| int | — | 跑步心率下限 |
| int | — | 最低跑步步频 (spm) |
| int | 60 | 轮询 LiveTrack 的频率 |
| int | 600 | 触发 Claude 分析的频率 |
| int | 10 | 传递给 Claude 的数据窗口(分钟) |
完整铁人三项的 race_config 示例
{
"race_name": "CT2026",
"race_type": "triathlon",
"hr_max": 144,
"hr_min": 115,
"power_max": 165,
"cadence_min": 82,
"run_hr_max": 152,
"run_hr_min": 125,
"run_cadence_min": 165,
"poll_interval_secs": 60,
"analyze_interval_secs": 600,
"analyze_window_min": 10
}比赛结束检测
服务器在以下情况自动停止:
≥ 15 分钟没有新的轨迹点 (
STALE_STOP_MIN)且总耗时 ≥ 30 分钟 (
MIN_ELAPSED_MIN)
这处理了 Garmin 24 小时 URL 延迟问题:URL 在比赛后仍然有效,但当运动员完成比赛时,新的轨迹点会停止到达。30 分钟的最小值防止了在开始时 GPS 数据稀疏导致的错误停止。
配置(环境变量)
变量 | 默认值 | 描述 |
|
| 服务器端口 |
|
| 绑定地址 |
|
| MCP 端点路径 |
|
| SQLite 数据库路径 |
|
| claude-runner 基础 URL |
|
| claude-runner 任务的工作区 |
|
| 日志级别 |
| — | OpenTelemetry 收集器 URL(可选) |
部署
cd ~/ai-platform/mcps
# Build and start
docker compose up -d --build livetrack-mcp
# Logs
docker compose logs -f livetrack-mcp
# Restart
docker compose restart livetrack-mcp
# Health check
curl http://localhost:38100/health典型会话(通过训练工作区中的 Claude)
# Start tracking
use_mcp_tool livetrack-mcp start_tracking \
url="https://livetrack.garmin.com/session/.../token/..." \
race_config={"hr_max": 144, "power_max": 165, "run_hr_max": 152}
# Check status
use_mcp_tool livetrack-mcp get_tracking_status
# Manual analysis trigger
use_mcp_tool livetrack-mcp trigger_analysis
# Stop (or let it auto-stop)
use_mcp_tool livetrack-mcp stop_tracking项目结构
livetrack_mcp/
├── Dockerfile
├── pyproject.toml
├── README.md
└── src/livetrack_mcp/
├── __init__.py
├── __main__.py
├── otel.py # OpenTelemetry setup
├── poller.py # Garmin LiveTrack URL parsing + HTTP fetch
├── store.py # SQLite time-series (sqlite3 + asyncio.to_thread)
├── tracker.py # Scheduling (asyncio.create_task) + race-end detection
├── analyzer.py # Prompt builder + claude-runner caller
└── server.py # FastMCP tools + /control + /healthThis server cannot be deployed
Maintenance
Related MCP Connectors
Adaptive running coach MCP server — training data, plans, and recovery for AI assistants.
Garmin data in Claude: 135 tools — activities, sleep, HRV, training, workouts. Free, open source.
Pace is a remote MCP server that exposes wearable and fitness data to Claude via the Model Context Protocol. It connects to Garmin, Oura, Whoop, Polar, Fitbit and 20+ devices and provides 15 tools for querying sleep, activity, recovery, and training data. Hosted on Google Cloud Run, OAuth 2.1 authentication, Streamable HTTP transport. Instructions: First you need to create an account at: https://pacetraining.co and connect your wearables. After that you can connect the remote Server via Custom Connector in Claude and OAuth 2.1 Flow startet.
Garmin data in Claude & ChatGPT via the Garmin Health API. OAuth sign-in, no password sharing.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceMCP server that connects Garmin Connect data to Claude, enabling training analysis, recovery checks, and personalized plans based on real metrics like HRV, training load, and activities.21MIT
- FlicenseNot gradedqualityCmaintenanceMCP server that gives Claude access to real-time Garmin Connect and Strava data for analyzing training and suggesting sessions.-
- AlicenseNot gradedqualityDmaintenanceSelf-hosted MCP server that exposes 90+ Garmin Connect tools to Claude and includes a live triathlon dashboard.MIT
- AlicenseAqualityBmaintenanceLocal MCP server that connects Claude Desktop with Garmin and Apple Health data to read training and recovery, estimate heart rate and pace zones, analyze performance, and create structured workouts.22MIT