Skip to main content
Glama
garmin-connect-mcp

garmin-connect-mcp

by knowkhelan
README.md
# garmin-connect-mcp: a Garmin + food-log coach for Claude

A personal [MCP](https://modelcontextprotocol.io) server that turns a Claude Project into a marathon coach and sports dietitian:

- **Live Garmin Connect data**: workouts, laps and HR zones, sleep, HRV, resting HR, training readiness, training status, race predictions, and your Garmin Coach plan.
- **A food log that persists across chats**, with itemised calories, protein, carbs, fat, fiber and sodium. Workout electrolytes are tracked separately from the food sodium cap.
- **Saved foods**: store exact label numbers for foods you eat often, so they're never re-estimated.
- **Calorie targets from your real Garmin burn**: a deficit on normal days, maintenance on long-run days.
- **Treadmill corrections**: enter the real distance once, and pace and weekly totals use it everywhere.
- **A weekly review** in one call: mileage, long run, nutrition averages, days over the sodium cap, recovery trend, weight change.

It runs on **Google Cloud Run + Firestore free tiers, with a $0 billing hard cap**.

```
Claude Project ──HTTPS──▶ Cloud Run (scale-to-zero, max 1 instance) ──▶ Garmin Connect
                                   │
                                   └──▶ Firestore (food log, targets, saved foods, tokens)

Budget $1/mo (credits excluded) ─▶ Pub/Sub ─▶ billing-cap function: unlinks billing if cost > $0
emails at $0.01 and $0.50
```

## Docs

- **[Setup guide](docs/SETUP.md)**: build your own in about 45 minutes, plus day-to-day operations and troubleshooting.
- **[How we built it](docs/HOW_WE_BUILT_IT.md)**: the design decisions, the $0 hard cap, testing, and everything that broke during the real deploy.
- **[Claude Project instructions template](PROJECT_PROMPT.example.md)**

## Quick start

```bash
git clone https://github.com/knowkhelan/garmin-connect-mcp.git && cd garmin-connect-mcp
gcloud auth login                                            # needs a GCP project with an OPEN billing account
uv run --with garminconnect python scripts/garmin_login.py   # one-time Garmin login
cp .deploy.env.example .deploy.env                           # fill in project + billing account
bash scripts/deploy.sh all                                   # billing guard, then Firestore + server
bash scripts/deploy.sh test-cap                              # proves the $0 cap can fire
```

Then add the printed URL as a custom connector at claude.ai/customize/connectors (with **No sign-in**). Details are in the [setup guide](docs/SETUP.md).

## Tools Claude gets

| Tool | What it does |
|---|---|
| `daily_check` | **Start here.** One day's workouts, burn, recovery, day type, targets, food and flags |
| `log_food` / `update_food_entry` / `delete_food_entry` | Itemised meal logging; `meal="workout_fuel"` for electrolytes |
| `get_food_log` | Food history with per-day totals |
| `save_food` / `list_saved_foods` / `delete_saved_food` | Exact label figures for regular foods |
| `get_targets` / `set_targets` | Protein, fiber, sodium cap, deficit, carbs by day type |
| `get_activities` / `get_activity_detail` | Workouts, laps, HR zones |
| `correct_activity_distance` | Fix treadmill distance and pace |
| `get_recovery` | Sleep, HRV, resting HR, readiness trend |
| `get_training_status` / `get_training_plan` | Load, VO2 max, race predictions, Garmin Coach schedule |
| `log_weight` / `get_weight_trend` | Weigh-ins (manual + Garmin scale) |
| `weekly_review` | The weekly check-in in one call |

## Cost

Normal use (a few logs and checks a day) is under 5% of the Cloud Run and Firestore free tiers. The billing guard emails you at $0.01 and $0.50, and unlinks billing as soon as any real charge appears. See [the setup guide](docs/SETUP.md#if-the-cap-trips) for what that means and how to recover.

## Local development

```bash
pip install -r requirements.txt pytest
LOCAL_DEV=1 GARMIN_MOCK=1 python -m app.server               # http://localhost:8080/mcp with fake Garmin + JSON-file storage
python -m pytest tests -q                                    # unit, storage-contract and billing-cap tests
rm -rf data && python tests/smoke_test.py http://localhost:8080/mcp   # 26 end-to-end checks (needs an empty store)
```

## Caveats

- Garmin access uses the **unofficial** [`python-garminconnect`](https://github.com/cyberjunky/python-garminconnect) with your own login. Garmin can change things at any time.
- The connector URL's random path is the only auth. Keep it private and rotate it if it leaks.
- Targets and flags are generic heuristics, **not medical advice**.
- Built for one athlete. It isn't a multi-user service.

## License

[MIT](LICENSE)