garmin-mcp

garmin-mcp

Enables AI assistants to read Garmin activities and create/schedule structured workouts and multi-week training plans directly on Garmin Connect, syncing to your watch with guided prompts.

Category
访问服务器

README

garmin-mcp

ci python license: MIT

Replace OWNER in the badge and clone URLs with your GitHub username.

An MCP server that lets an AI assistant (Claude, or any MCP client) read your Garmin activities and create and schedule structured workouts and multi-week training plans directly on your Garmin Connect calendar — where they sync to your watch with guided, rep-by-rep prompts.

Describe a session in plain language and it lands on your watch:

"Schedule a 4×1mi threshold workout for Tuesday and a 16-miler with 4
 marathon-pace miles on Saturday."   →   built, scheduled, synced.

Built on python-garminconnect (garth SSO auth) and the official MCP Python SDK. Activities are read-only by design; write access is scoped to workouts and the training calendar.


⚠️ Read this first (security & terms)

  • No official individual API. Garmin's API program is enterprise-only, so this uses Garmin's unofficial SSO via garth, like every Garmin automation tool. It can break if Garmin changes their login flow.
  • Long-lived tokens. Auth caches a ~1-year token that grants full account access. Treat GARMINTOKENS like a production secret — it is git-ignored here.
  • Your own risk. This may be against Garmin's Terms of Service. It's intended for personal use on your own account.
  • Lock down the HTTP transport. A publicly reachable server that can write to a Garmin account is dangerous. The remote transport requires a bearer token (below). For most people, local stdio with Claude Desktop is the right choice.

Quick start

git clone https://github.com/yashhooda1/mcp-garmin
cd garmin-mcp
pip install -e ".[dev]"

# one-time login — caches tokens to $GARMINTOKENS (default ~/.garminconnect)
export GARMINTOKENS="$HOME/.garminconnect"
garmin-mcp-auth          # prompts for email / password / MFA

pytest -q                # offline sanity check (no Garmin calls)

After auth, the server runs with no credentials in its environment — it resumes from the cached tokens.

Connect it to Claude

Local (Claude Desktop, stdio) — add to your Claude Desktop MCP config (see examples/claude_desktop_config.json):

{
  "mcpServers": {
    "garmin": {
      "command": "garmin-mcp",
      "env": { "TRANSPORT": "stdio", "GARMINTOKENS": "/Users/you/.garminconnect" }
    }
  }
}

Remote (claude.ai custom connector, HTTP) — deploy with the included Dockerfile / railway.toml, then add the server URL (https://<host>/mcp) as a custom connector. Required env on the host:

TRANSPORT=streamable-http
MCP_AUTH_TOKEN=<openssl rand -hex 32>      # clients must send Authorization: Bearer <token>
GARMINTOKENS=/data/.garminconnect          # mount a volume; upload tokens you generated locally

Without MCP_AUTH_TOKEN the server logs a loud warning and stays open — so set it. Every HTTP request is checked with a constant-time bearer comparison; missing or wrong tokens get a 401.


Tools

Tool Access Description
list_activities read Recent activities (id, type, distance, HR…)
get_activity read Full detail for one activity
get_athlete_zones read Heart-rate zones / settings
list_scheduled read Workouts on the calendar
create_workout write Build a structured workout from a spec; optionally schedule
schedule_workout write Put an existing workout on a date
delete_workout write Delete a workout template
unschedule_workout write Remove a calendar occurrence
create_training_plan write Build + schedule a whole multi-week plan
create_boulderthon_demo write A bundled 13-week example plan

Workout spec

The format the assistant fills in — readable and unit-aware:

WorkoutSpec(name="4x1mi threshold", steps=[
    StepSpec(kind="warmup",   duration="15:00", target="hr:2"),
    RepeatSpec(repeat=4, steps=[
        StepSpec(kind="run",      duration="1mi",  target="pace:6:35-6:55"),
        StepSpec(kind="recovery", duration="2:30", target="hr:2"),
    ]),
    StepSpec(kind="cooldown", duration="10:00", target="hr:2"),
])
  • Durations: "15:00"/"90s" = time · "1mi"/"1.5mi"/"400m"/"1km" = distance
  • Targets: null · "hr:2" (HR zone) · "pace:6:35-6:55" (pace window, min/mi)

Everything compiles to Garmin's exact workout-service JSON schema (validated against garminconnect 0.3.6).

Example: a full marathon block

plans/boulderthon.py is a complete 13-week marathon build expressed in this spec — pace-targeted quality sessions, HR-zone easy/long runs, down weeks, two 20-milers, a marathon-pace rehearsal, and a taper. It's the worked example that proves the plan engine. Dry-run it without touching Garmin:

python -c "from plans.boulderthon import build_plan; from garmin_mcp.plans import preview_plan; \
[print(r['date'], r['name']) for r in preview_plan(build_plan())]"

Write your own plan the same way: a list of (date, WorkoutSpec) via the week() helper in garmin_mcp.plans, then create_training_plan (or push_plan) schedules the lot, idempotently.


Project structure

garmin-mcp/
├── src/garmin_mcp/
│   ├── server.py      FastMCP app + tools
│   ├── workouts.py    spec models + validated Garmin compiler
│   ├── plans.py       plan engine (week() helper, push/preview)
│   ├── auth.py        garth login + token cache + MFA
│   ├── http_auth.py   bearer-token gate for the HTTP transport
│   └── cli.py         garmin-mcp-auth
├── plans/boulderthon.py   example 13-week build as data
├── examples/          Claude Desktop config
├── tests/             offline build/serialize/auth tests (CI-safe, no network)
├── Dockerfile · railway.toml   remote deploy
└── .github/workflows/ci.yml

Tests

pytest -q       # offline — compiles + serializes workouts, checks the auth gate

CI runs ruff + pytest on every push. No test makes a network call, so the suite is safe to run anywhere without Garmin credentials.


Why I built this

I wanted my running coach and my watch to be the same workflow. I follow structured marathon training, but turning a coach's plan into Garmin workouts meant tediously hand-building every interval session in the Garmin web UI, week after week. Garmin has no individual API, so "just script it" isn't an option out of the box.

So I reverse-engineered the workout schema, wrapped it in a typed, LLM-friendly spec, and exposed it through MCP — so an assistant can take "give me a 13-week sub-3 block" and turn it into 60+ scheduled, structured sessions on my watch. Along the way it became a small but complete piece of engineering:

  • Protocol integration — a real MCP server (stdio + streamable-HTTP) with least-privilege tool design (activities read-only, writes scoped to workouts).
  • Schema reverse-engineering — a validated compiler from a friendly spec to Garmin's exact workout-service JSON, with pace/HR/distance targets and nested repeat groups.
  • Auth & security — garth SSO with cached-token resumption and MFA, plus a constant-time bearer gate for safe remote deployment.
  • Operability — typed Pydantic models, an offline test suite, CI, and one-command Docker/Railway deploy.

It scratched a real itch and doubles as a reference for building MCP servers around closed, unofficial APIs.

License

MIT. Not affiliated with or endorsed by Garmin.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选