Skip to main content
Glama
WHOOP Connect for Grok Bot

WHOOP Connect for Grok Bot

by Edvin-Kjall

WHOOP Connect for Grok Bot (Remote MCP on Cloudflare Workers)

Zero-database, $0 Cloudflare Workers remote MCP server connecting WHOOP API v2 to Grok Bot via Streamable HTTP (POST /mcp) + OAuth 2.1 — complete with an automated Grok Bot setup routine and one-click Cloudflare deploy.

Deploy to Cloudflare License: MIT

Connect your personal WHOOP recovery, sleep, HRV, strain, and workout metrics directly to Grok Bot (or any remote MCP OAuth 2.1 client like Claude or ChatGPT) using your own free WHOOP Developer Sandbox app—no multi-user approval queue, no database, and no paid hosting required.


Why This Exists

  • Survives Grok Bot VM updates & resets: Your custom connector lives on your Grok account and your WHOOP tokens live inside Cloudflare's SQLite Durable Object—not on an ephemeral VM disk.

  • Hands-free setup via Grok Bot (Path 1): Includes a ready-to-import onboarding routine (grokbot/ROUTINE_SETUP.md) where Grok Bot creates your free WHOOP Sandbox app, deploys the Worker to your free Cloudflare account, wires the Redirect URI, and hands you your /mcp URL.

  • Atomic WHOOP v2 refresh token rotation: WHOOP invalidates the old refresh_token immediately on every refresh. A per-user TokenManager SQLite Durable Object (new_sqlite_classes — runs on the $0 Cloudflare Free Plan) serializes refreshes with a single-flight mutex and compare-and-swap retry so parallel tool calls never race.

  • Only 2 secrets required: Just WHOOP_CLIENT_ID and WHOOP_CLIENT_SECRET. AES-256-GCM token encryption and session signing keys are derived automatically via Web Crypto HKDF-SHA256 (no openssl commands needed).

  • Zero health data storage: Stateless live pass-through to WHOOP API v2—no health payloads ever touch KV, D1, R2, or logs.

  • Zero Auto Review popups: Every read tool is annotated { readOnlyHint: true, destructiveHint: false, idempotentHint: true }.


Related MCP server: WHOOP MCP Server

Architecture

Grok Bot (or Claude / ChatGPT)
   │  Streamable HTTP (POST /mcp) + OAuth 2.1 (CIMD / DCR + PKCE S256)
   ▼
Cloudflare Worker ($0 Free Plan)
   ├── @cloudflare/workers-oauth-provider ──► OAUTH_KV (MCP grants & single-use state)
   ├── TokenManager SQLite Durable Object ──► AES-256-GCM sealed WHOOP tokens (atomic refresh lock)
   └── Stateless MCP v2 Server (6 read-only tools)
          │  Live HTTPS pass-through (zero health payloads stored)
          ▼
     WHOOP Developer API v2 (https://api.prod.whoop.com/developer/v2)

Quickstart — Path 1: Automated via Grok Bot Template (Recommended, ~2 min)

Turn this repo into a shareable Grok Bot template so any new user sets everything up in ~2 minutes with zero CLI commands:

  1. Create your Grok Bot and paste:

  2. Type "Set up my WHOOP" in chat. Grok Bot will:

    • Open developer.whoop.com and hand browser control to you to sign into WHOOP safely (passwords never enter chat), then create your free Sandbox app automatically.

    • Clone this repo into its VM, open Cloudflare's 1-click login approval, deploy the Worker (OAUTH_KV + SQLite TokenManager auto-provisioned), upload WHOOP_CLIENT_ID & WHOOP_CLIENT_SECRET, and update your WHOOP app's Redirect URI to https://<worker>.workers.dev/callback.

    • Reply with your live MCP URL: https://<worker>.workers.dev/mcp.

  3. Add the Custom Connector in Grok Bot:

    • Open Connect apps → Add a custom connector → Remote HTTPS

    • Paste https://<worker>.workers.dev/mcp and save

    • Click Sign in with WHOOP → Grant

  4. Done! Ask "How am I doing today?"


Quickstart — Path 2: One-Click "Deploy to Cloudflare" Button (~3 min)

Prefer deploying directly from GitHub without the Grok Bot setup routine?

  1. Create a free WHOOP Sandbox app:

    • Sign in at developer.whoop.com/dashboard → Create App (free Sandbox tier allows up to 10 users immediately).

    • Enter a temporary Redirect URI (e.g. https://example.com/callback) and copy your Client ID and Client Secret.

  2. Click the Deploy to Cloudflare button at the top of this README:

    • Paste WHOOP_CLIENT_ID and WHOOP_CLIENT_SECRET into the two secret fields and click Deploy.

  3. Wire the Redirect URI & connect Grok Bot:

    • Open your deployed Worker URL (https://whoop-mcp.<your-subdomain>.workers.dev).

    • Click Copy next to the Redirect URI (.../callback), paste it into your WHOOP Developer App settings, and click Save.

    • Click Copy next to the MCP URL (.../mcp), paste it into Grok Bot → Connect apps → Add a custom connector → Remote HTTPS, and click Sign in with WHOOP → Grant.


Authentication Modes

Mode A — OAuth 2.1 Broker (Default, Recommended)

Powered by @cloudflare/workers-oauth-provider:

  • Automatic RFC 9728 (/.well-known/oauth-protected-resource/mcp) and RFC 8414 (/.well-known/oauth-authorization-server) discovery

  • Supports Client ID Metadata Documents (CIMD) and Dynamic Client Registration (POST /register) with mandatory PKCE S256

  • Single-use KV OAuth state bound to an HttpOnly; SameSite=Lax browser cookie to block login-CSRF and callback replay

  • Unauthenticated POST /mcp returns HTTP 401 with WWW-Authenticate: Bearer resource_metadata="..." so Grok Bot auto-triggers its sign-in card

Mode B — Static Bearer Token Fallback (Optional)

For Grok CLI, xAI Responses API, or custom header connector setups:

  1. Add an optional Worker secret named MCP_BEARER_TOKEN in Cloudflare Dashboard → Workers → Settings → Variables and Secrets (or npx wrangler secret put MCP_BEARER_TOKEN).

  2. Visit https://<your-worker>.workers.dev/setup once and click Connect WHOOP.

  3. Send Authorization: Bearer <your MCP_BEARER_TOKEN> to https://<your-worker>.workers.dev/mcp.


MCP Tools (POST /mcp)

All 6 tools are stateless live pass-throughs annotated { readOnlyHint: true, destructiveHint: false, idempotentHint: true }. Bare dates (YYYY-MM-DD) passed for start/end are automatically normalized to ISO-8601 UTC bounds.

Tool

WHOOP API v2 Endpoint(s)

Description

whoop_get_today

/recovery, /activity/sleep, /cycle, /activity/workout

Single-call daily snapshot (latest recovery, sleep, cycle strain, and recent workouts in parallel)

whoop_get_profile

/user/profile/basic, /user/measurement/body

Basic profile and body measurements (height, weight, max HR)

whoop_get_recovery

/recovery

Recovery scores (0–100), HRV RMSSD (ms), RHR, SpO2, skin temp (start, end, limit, nextToken)

whoop_get_sleep

/activity/sleep

Sleep & nap sessions, stages, efficiency, performance %, sleep debt (start, end, limit, nextToken)

whoop_get_cycles

/cycle

Physiological cycles / day strain (0–21), kJ, avg/max HR (start, end, limit, nextToken)

whoop_get_workouts

/activity/workout

Workouts, sport, strain, kJ, HR zones (start, end, limit, nextToken)


Local Development & Testing

npm install
cp .dev.vars.example .dev.vars
# Add WHOOP_CLIENT_ID and WHOOP_CLIENT_SECRET to .dev.vars

npm run typecheck
npm test
npm run dev

For local OAuth testing, add http://localhost:8787/callback as a Redirect URI in your WHOOP Developer App.


Privacy & Instant Disconnect

  • Use https://<your-worker>.workers.dev/privacy as your WHOOP Developer App's Privacy Policy URL.

  • Zero health data is stored on Cloudflare; only AES-256-GCM encrypted OAuth tokens live inside your private TokenManager Durable Object.

  • Revoke access anytime via Disconnect & Wipe Tokens on / (after signing in via /setup) or directly inside the WHOOP mobile app under Connected Apps.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables LLMs to retrieve and analyze sleep, recovery, and physiological cycle data from the WHOOP API. It provides tools for accessing detailed metrics such as strain, HRV, and readiness scores through secure OAuth 2.0 authentication.
      4
      14 npm
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables Claude, Cursor, or any MCP client to query your own recovery scores, sleep, strain cycles, workouts, profile, and body measurements through every WHOOP API v2 read endpoint. Tools return records exactly as WHOOP sends them, with paging and date-range filtering, and refresh tokens automatically after a one-time login.
      11
      11 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables read-only access to WHOOP health data through MCP clients, including recovery, HRV, sleep, strain, workouts, cycles, trends, and period comparisons, with resilient handling of outages, token refresh, and natural-language dates.
      MIT