Skip to main content
Glama
Garmin Athlete MCP

Garmin Athlete MCP

by Petrit23
README.md
# Garmin Athlete MCP

**Your Garmin data, plus the training science Garmin's API leaves out.**

<!-- mcp-name: io.github.Petrit23/garmin-athlete-mcp -->

An MCP server that connects your Garmin Connect account to Claude (or any MCP client)
through Garmin's **official Personal API**. It covers every endpoint the API offers,
and then does the part other Garmin servers don't: it works out your training load,
readiness, cardiac drift and best efforts, and knows what you're training for.

> **Unofficial project, official API.** Not made or endorsed by Garmin. It only talks to
> Garmin's documented [Personal API](https://developer.garmin.com/gc-developer-program/personal/personal-api)
> through [Garmin's own Python client](https://github.com/garmin/connect-personal-api-python).
> Read-only. Not medical advice.

## Why another Garmin MCP server?

Garmin's Personal API gives you raw data. It does **not** give you Training Status,
Training Readiness, Training Load, or anything from inside an activity's FIT file.
Other servers pass the raw JSON through. This one adds:

| | What you get |
| --- | --- |
| **Training load** | TRIMP per activity, fatigue (ATL), fitness (CTL), form (TSB), acute:chronic ratio, monotony/strain, weekly volume, with a plain-English read |
| **Readiness** | 0-100 score from last night's HRV and resting HR **against your own baseline**, sleep, Body Battery and fatigue, with the reasons listed |
| **FIT analysis** | watch laps, even km/mile splits, time in HR zones, aerobic decoupling (cardiac drift), best efforts (400 m to marathon, 1/5/20/60-min power) |
| **Your plan** | a small `plan.toml` with your races and sessions, so "should I train hard today?" knows your race is 14 weeks out and tomorrow is a tempo |
| **History** | a local SQLite archive, so trends and baselines work and past days aren't re-fetched |
| **Paces your way** | min/km, min/mile **and mph** (for treadmill runners) |
| **Evals** | questions with known answers, graded automatically, so you can see it answers correctly |

## Quickstart

1. Create a Personal API key in Garmin Connect (web): **Settings → Personal API Key**
   ([direct link](https://connect.garmin.com/app/settings/personalApiToken)).
2. Install and save the key:

   ```bash
   uv tool install git+https://github.com/Petrit23/garmin-athlete-mcp   # not on PyPI yet
   garmin-athlete-mcp auth                # paste the key at the hidden prompt
   garmin-athlete-mcp sync --days 120     # build your history (optional but recommended)
   ```

3. Add it to your MCP client.

   **Claude Code**
   ```bash
   claude mcp add garmin -- garmin-athlete-mcp
   ```

   **Claude Desktop** (`claude_desktop_config.json`)
   ```json
   {
     "mcpServers": {
       "garmin": { "command": "garmin-athlete-mcp" }
     }
   }
   ```
   If Claude Desktop can't find it, use the full path from `which garmin-athlete-mcp`
   (usually `~/.local/bin/garmin-athlete-mcp`).

   **ChatGPT (Codex)**: add to `~/.codex/config.toml`
   ```toml
   [mcp_servers.garmin]
   command = "garmin-athlete-mcp"
   ```
   Works in the Codex tab of the ChatGPT desktop app, and from the ChatGPT phone app via
   Remote connections (your computer must be on). Regular ChatGPT chat can't run local servers.

**Try it without a Garmin account:** `garmin-athlete-mcp --demo` serves realistic sample
data (a marathon runner 14 weeks out), so you can see every tool working first.

## Your plan file (optional, recommended)

`~/.config/garmin-athlete-mcp/plan.toml` (or set `GARMIN_ATHLETE_PLAN`):

```toml
[athlete]
sex = "male"            # used by the TRIMP formula
max_hr = 192            # optional: overrides Garmin's max HR for training load
pace_units = "mph"      # mph | per_km | per_mile
notes = "Trains mostly on a treadmill."

[[races]]
name = "Barcelona Marathon"
date = 2027-03-14
distance = "marathon"
goal = "sub 3:30"
priority = "A"

[[sessions]]
date = 2026-12-06
type = "long"
description = "18 km easy at 7.5 mph"
distance_km = 18
```

`garmin-athlete-mcp plan-template` prints a full example. The file is re-read on every
call, so you can generate it from a spreadsheet, a training app or a script.

## Tools

**Analysis**

| Tool | What it does |
| --- | --- |
| `get_training_context` | Plan, upcoming races (days out), today's and next 7 days' sessions, last 7 days planned vs done, readiness and load. Start here. |
| `get_day` | One day: sleep score/stages, HRV, resting HR, stress, Body Battery, steps, activities |
| `get_readiness` | 0-100 readiness with reasons and missing signals |
| `get_training_load` | ATL / CTL / TSB, ACWR, monotony, strain, weekly volume |
| `get_trend` | HRV, resting HR, sleep score/hours, stress, Body Battery, steps or VO2 max over time, with 7-day averages |
| `analyze_activity` | Laps, splits, time in zones, decoupling, best efforts from the FIT file |
| `get_best_efforts` | Personal bests found inside any activity over a period |
| `list_activities` | Compact activity list with paces incl. mph |
| `sync_history` / `archive_status` / `get_plan_template` | Archive and setup helpers |

**Every Personal API endpoint (28)**

`get_daily_summaries`, `get_user_summary`, `get_steps`, `get_stress`, `get_hydration`,
`get_body_battery`, `get_heart_rate`, `get_spo2`, `get_sleep`, `get_sleep_summaries`,
`get_hrv`, `get_hrv_summaries`, `get_weight` (daily or every weigh-in), `get_weight_goals`,
`get_food_log`, `search_activities` (every documented filter), `get_activity_types`,
`get_activity`, `get_activity_workout`, `download_activity_fit`, `get_profile`,
`get_heart_rate_zones`, `get_vo2_max`, `get_fitness_age`, `get_wellness_activities`,
`get_menstrual_cycle`, `get_menstrual_day`.

Date ranges longer than an endpoint allows (28 days for steps/stress, 31 for sleep, …)
are split for you. All-day sample arrays are left out unless you pass `include_samples`.

**Prompts:** `morning_checkin`, `weekly_review`, `analyze_last_run`, `race_readiness`.

## How the numbers are worked out

- **TRIMP** (Banister): minutes × HRr × 0.64·e^(1.92·HRr) (0.86/1.67 for women), HRr from
  average HR, resting HR and max HR.
- **ATL / CTL**: 7- and 42-day exponentially weighted daily TRIMP, seeded from your first
  four weeks of history. **TSB** = yesterday's CTL − ATL.
- **ACWR**: last 7 days' load ÷ (last 28 days' load ÷ 4). Above ~1.5 is a known injury-risk zone.
- **Readiness**: starts at 75, moves with last night's HRV and resting HR as z-scores
  against your last 60 / 30 days, plus sleep score, Body Battery peak and fatigue.
- **Decoupling**: (speed or power ÷ HR) for the first vs second half of the session
  after a 10-minute warm-up. Under 5% on a steady long run usually means good aerobic durability.

These are transparent estimates, not Garmin's algorithms. Every response says how it was computed.

## Evals

`evals/cases.json` holds real questions with known answers on the demo data ("Should I
train hard today?" after a bad night, "Did my heart rate drift?", "What did I eat
yesterday?" when nothing was logged). `evals/run_evals.py` asks Claude each one with this
server attached and checks that it called a sensible tool, stated the right facts, and
didn't invent anything:

```bash
python evals/run_evals.py                                  # via Claude Code (logged in)
python evals/run_evals.py --backend api --model <model>    # via ANTHROPIC_API_KEY
```

`tests/test_eval_facts.py` checks the expected facts against the demo server on every
test run, so the evals can't silently drift.

## Remote / HTTP

```bash
garmin-athlete-mcp --http --host 127.0.0.1 --port 8492   # streamable HTTP at /mcp
```

There is no built-in authentication. Keep it on localhost or behind a VPN/tailnet or an
authenticating proxy.

## Privacy and Garmin's terms

- Your key stays on your machine (`~/.config/garmin/connect-personal-api-key`, mode 600)
  and is only ever sent to Garmin's token endpoint.
- The archive and FIT files stay on your machine (`~/.local/share/garmin-athlete-mcp`).
- The Personal API is for **your own data, personal use**. Don't host this for other
  people or charge for it; that needs Garmin's commercial developer programme. Garmin's
  terms also forbid training AI models on Garmin data. This server only lets your AI
  assistant read your data when you ask.

## Development

```bash
uv venv && uv pip install -e '.[dev]'
pytest                     # 60+ tests, no Garmin account needed (demo client + synthetic FIT)
```

## Licence

MIT. Garmin's Personal API client is Apache-2.0; the Garmin FIT SDK is under the FIT Protocol License.