WHOOP MCP
by nikb12e
README.md
# WHOOP MCP
A [Model Context Protocol](https://modelcontextprotocol.io) server that gives AI assistants (Claude, ChatGPT and other MCP clients) read access to your own WHOOP data: recovery, HRV, sleep, strain and workouts.
Single file, zero dependencies, runs on Cloudflare Workers. Tool descriptions are in Slovenian.
## Tools
| Tool | What it returns |
|---|---|
| `get_whoop_summary` | Profile, latest recovery, sleep, cycle and workouts for the last N days (default 3, max 14) |
| `get_profile` | Basic profile and body measurements (cached for 6 h) |
| `get_recoveries` | Recovery score, HRV (rMSSD), resting heart rate, SpO2, skin temperature |
| `get_sleeps` | Sleep performance, stages (light, SWS, REM), disturbances, respiratory rate, sleep need |
| `get_workouts` | Sport, strain, average and max heart rate, kilojoules, heart rate zones |
| `get_cycles` | Daily strain, kilojoules, average and max heart rate |
All list tools accept `limit` (1 to 25), `start`, `end` (ISO 8601) and `nextToken` for paging.
## How it works
* WHOOP OAuth 2.0 with `offline` scope; tokens live in a Cloudflare KV namespace and refresh automatically
* Access token cached in memory per isolate, refresh is single flight so parallel calls never invalidate each other's rotating refresh token
* OAuth `state` is verified, the refresh token is never shown in HTML
* Optional endpoint protection with a secret path (`/mcp/<MCP_PATH_TOKEN>`) or an API key
* Hard timeouts and retries on every WHOOP request
## Setup
1. Create an app in the [WHOOP Developer Dashboard](https://developer.whoop.com) and note the client ID and secret.
2. Install and create the KV namespace:
```bash
npm install
npx wrangler kv namespace create WHOOP_KV
```
Put the returned id into `wrangler.toml`.
3. Add the secrets (never commit them):
```bash
npx wrangler secret put WHOOP_CLIENT_ID
npx wrangler secret put WHOOP_CLIENT_SECRET
npx wrangler secret put MCP_PATH_TOKEN
```
4. Deploy: `npm run deploy`
5. In the WHOOP dashboard set the redirect URI to `https://<your-worker>.workers.dev/callback`.
6. Open `https://<your-worker>.workers.dev/` and click **Poveži Whoop račun** to connect your account.
7. Add the MCP endpoint to your client: `https://<your-worker>.workers.dev/mcp/<MCP_PATH_TOKEN>`
For local development copy `dev.vars.example` to `.dev.vars` and run `npm run dev`.
> Without `MCP_PATH_TOKEN` or `MCP_API_KEY` the endpoint is public and anyone with the URL can read your health data. Always set one of them.
## License
MIT, see [LICENSE](LICENSE). Made by [Nik Bogataj](https://github.com/nikb12e).