Garmin MCP for Claude
README.md
# Garmin MCP for Claude
A small, **read-only** [MCP](https://modelcontextprotocol.io) server that lets Claude read **your own** Garmin Connect data (activities, sleep, HRV, heart rate, body battery, stress, weight…) through Garmin's official **Personal API**.
- Runs on **your own** Cloudflare account, on the free Workers plan
- Works as a **remote custom connector** on claude.ai, so it is available on web, desktop and mobile
- Protected by **OAuth** and a password that only you know
- Your health data is **not stored**: the server fetches it from Garmin and passes it to Claude
> 🇮🇹 Guida in italiano: [LEGGIMI.md](LEGGIMI.md)
> **Unofficial project.** It is not affiliated with, endorsed by or supported by Garmin or Anthropic. "Garmin" and "Claude" are trademarks of their respective owners.
## One copy per person
Garmin's Personal API gives each user access to **their own data** with a key they generate themselves. This project follows that model: **each person deploys their own copy**, with their own Cloudflare account, Garmin key and password.
Please don't run one shared instance for other people. It would go against the intended use of the Personal API, and you would end up holding other people's health data.
## Tools
| Tool | What it returns |
|---|---|
| `garmin_list_activities` | Activities (newest first) with km, duration, pace, HR, cadence, elevation, training effect, load, VO2max, time in HR zones |
| `garmin_get_activity` | One activity in detail, optionally with the structured workout it followed |
| `garmin_daily_health` | One day: summary, sleep, heart rate, HRV, SpO2, fitness age |
| `garmin_health_trend` | A metric over a date range: daily summaries, sleep, HRV, body battery, steps, stress, weight |
| `garmin_profile_and_zones` | Profile settings and heart-rate zones |
| `garmin_raw_get` | Any other read-only GET path of the Personal API (e.g. VO2max history) |
## What you need
- A Garmin account with a device syncing to Garmin Connect
- A free [Cloudflare](https://dash.cloudflare.com/sign-up) account
- A Claude account that supports custom connectors
- [Node.js](https://nodejs.org) 20 or newer, only for option B below
## 1. Create your Garmin Personal API key
1. Sign in to **Garmin Connect Web** and open the **Personal API Key** page ([Garmin's guide](https://developer.garmin.com/gc-developer-program/personal/personal-api)).
2. Select **Create Key**, accept the terms and choose an expiration (30 days to 1 year).
3. Copy the key now, because Garmin shows it only once. Treat it like a password.
Also pick a **long random password** (20+ characters) for the connector. A password manager is the easiest way to generate one.
## 2. Deploy
### Option A: Deploy button
[](https://deploy.workers.cloudflare.com/?url=https://github.com/YOUR-USER/garmin-mcp)
1. Sign in to Cloudflare. The page creates a copy of this repository in your GitHub account and sets up the Worker.
2. When asked for the secrets, paste your `GARMIN_API_KEY` and your `ACCESS_PASSWORD`.
3. If you are asked about a KV namespace, let Cloudflare create a new one.
4. When it finishes, write down your Worker URL (`https://garmin-mcp.<your-subdomain>.workers.dev`).
### Option B: Command line
```sh
git clone https://github.com/YOUR-USER/garmin-mcp.git
cd garmin-mcp
npm install
npx wrangler login # opens the browser: sign in to Cloudflare and allow
npx wrangler deploy # creates the Worker and its KV namespace; note the *.workers.dev URL
npx wrangler secret put GARMIN_API_KEY # paste your Garmin key, press Enter
npx wrangler secret put ACCESS_PASSWORD # type your connector password, press Enter
```
On the first deploy, Wrangler may ask you to choose a `workers.dev` subdomain. Any name works.
Open your Worker URL in a browser. If you see **"Server attivo"**, it is running.
## 3. Connect it to Claude
1. In Claude, open **Settings → Connectors → Add custom connector**.
2. Name: `Garmin`. URL: `https://garmin-mcp.<your-subdomain>.workers.dev/mcp` (don't forget `/mcp`).
3. Select **Connect**. Your server's page opens: type your `ACCESS_PASSWORD` and select **Consenti** (Allow).
Then try asking: *"Summarise my training over the last two weeks"* or *"How did I sleep last night?"*
## How it works
```
Claude ──► /mcp ──► OAuth check ──► MCP tools ──► Garmin Personal API
```
- `src/index.ts` is the entry point. It handles the OAuth flow and the password-protected consent page, then forwards authorised requests to the MCP server (stateless Streamable HTTP).
- `src/tools.ts` holds the MCP tools. Parameters are defined with Zod, and activities are summarised into readable units (km, min/km, minutes).
- `src/garmin.ts` is the Garmin client. It exchanges your API key for a 24-hour token and caches it in KV.
The KV namespace holds only OAuth clients, grants and tokens, plus the cached Garmin token. No health data is stored.
## Security notes
- **The password is the only gate.** Use a long random one. Wrong attempts are limited to 10 per hour.
- **Changing the password does not disconnect clients that are already connected.** To revoke every connection:
1. Delete all entries in the Worker's KV namespace (Cloudflare dashboard → Storage & Databases → KV).
2. Set a new password with `npx wrangler secret put ACCESS_PASSWORD`.
3. Reconnect Claude.
- The tools are read-only, and the Personal API cannot write to your Garmin account anyway.
- Keep dependencies up to date: run `npm audit`, then `npm update`, then `npx wrangler deploy`.
- Never commit secrets. Use `npx wrangler secret put`. For local testing, copy `.dev.vars.example` to `.dev.vars`, which is git-ignored.
## Maintenance
- **Your Garmin key expires** (one year at most). Create a new one and run `npx wrangler secret put GARMIN_API_KEY`.
- **To remove everything**, run `npx wrangler delete` and delete the key in Garmin Connect.
## Troubleshooting
| Message | Fix |
|---|---|
| "Garmin rejected the Personal API key" | The key expired, was deleted or was mistyped. Create a new one and update `GARMIN_API_KEY`. |
| "Garmin is rate limiting requests" | Wait a minute and try again. |
| "Password sbagliata" / "Troppi tentativi" | Wrong password. After 10 failures, wait one hour. |
| Claude cannot connect | Check that the URL ends with `/mcp` and that the Worker page shows "Server attivo". |
## Limits
On the free Workers plan, requests and CPU time per day are limited across your account. For personal use with Claude this is normally more than enough.
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues