whoop-mcp
CLAUDE.md165 starsChanged 8 months agoMITView on GitHub
An MCP (Model Context Protocol) server that wraps the WHOOP REST API, enabling AI assistants to query health and fitness data through natural conversation.
- Installs packages
In this repository22 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- api-and-interface-designSkill
- browser-testing-with-devtoolsSkill
- ci-cd-and-automationSkill
- code-review-and-qualitySkill
- code-simplificationSkill
- context-engineeringSkill
- debugging-and-error-recoverySkill
- deprecation-and-migrationSkill
- documentation-and-adrsSkill
- frontend-ui-engineeringSkill
- git-workflow-and-versioningSkill
- idea-refineSkill
- incremental-implementationSkill
- performance-optimizationSkill
- planning-and-task-breakdownSkill
- security-and-hardeningSkill
- shipping-and-launchSkill
- source-driven-developmentSkill
- spec-driven-developmentSkill
- test-driven-developmentSkill
- using-agent-skillsSkill
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 16
No other runtime dependencies: Keep the dependency tree minimal.
- Distinctive: line 112
TDD: Write tests before code (Prove-It pattern for bugs)
- Very specific: line 113
Mock the WHOOP API: Never hit the real API in tests.
- Very specific: line 138
Run npm test before every commit
- Very specific: line 152
Commit WHOOP_CLIENT_ID, WHOOP_CLIENT_SECRET, or tokens
- Very specific: line 155
Use any — strict TypeScript throughout
- Distinctive: line 156
Remove or skip failing tests without discussion
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Project: whoop-mcp
An MCP (Model Context Protocol) server that wraps the WHOOP REST API, enabling AI assistants to query health and fitness data through natural conversation.
Tech Stack
- Language: TypeScript ~5.x (strict mode, no
any) - Runtime: Node.js >= 18 (native
fetch) - MCP SDK:
@modelcontextprotocol/sdk(latest) - Validation: Zod (for MCP tool input schemas)
- Test Framework: Vitest
- Lint: ESLint +
@typescript-eslint - Formatter: Prettier
- Build:
tsc(no bundler) - Package Manager: npm
- No other runtime dependencies. Keep the dependency tree minimal.
Commands
npm install # Install dependencies
npm run build # Build TypeScript
npm run dev # Run in development (tsx)
npm test # Run tests
npm test -- --coverage # Tests with coverage
npm run lint # Lint
npm run lint:fix # Lint + fix
npm run format # Format with Prettier
npm run typecheck # Type check (no emit)
node dist/index.js # Run MCP server (production)Project Structure
src/
├── index.ts # Entry point — creates MCP server, authenticates, starts stdio
├── server.ts # MCP server setup and tool registration
├── auth/
│ ├── oauth.ts # OAuth2 Authorization Code flow
│ ├── token-store.ts # Read/write/refresh tokens (~/.whoop-mcp/tokens.json)
│ └── callback-server.ts # Temporary local HTTP server for OAuth callback
├── api/
│ ├── client.ts # WHOOP API HTTP client (fetch + auth headers + retry)
│ ├── types.ts # TypeScript types for all WHOOP API responses
│ └── endpoints.ts # Endpoint URL constants
└── tools/
├── get-profile.ts # Tool: get_profile
├── get-recovery.ts # Tool: get_recovery_collection
├── get-sleep.ts # Tool: get_sleep_collection
├── get-workout.ts # Tool: get_workout_collection
├── get-cycle.ts # Tool: get_cycle_collection
└── get-body-measurement.ts # Tool: get_body_measurement
tests/ # Mirrors src/ structure
├── auth/
├── api/
└── tools/Code Conventions
Naming
- Files:
kebab-case.ts - Types/Interfaces:
PascalCase(e.g.,RecoveryRecord,SleepCollection) - Functions:
camelCase(e.g.,getRecoveryCollection) - Constants:
SCREAMING_SNAKE_CASE(e.g.,WHOOP_API_BASE_URL) - MCP tool names:
snake_case(MCP convention, e.g.,get_recovery_collection)
Patterns
- Explicit return types on all exported functions
- Zod for tool input validation (MCP SDK convention)
- One tool per file — handler + schema co-located
- Functional style — no classes except where SDK requires
- Named exports (no default exports)
- Errors throw typed errors, never return error codes
- Tests co-located in
tests/directory mirroringsrc/
Example — Tool Implementation Pattern
// src/tools/get-recovery.ts
import { z } from "zod";
import { WhoopClient } from "../api/client.js";
import type { RecoveryCollection } from "../api/types.js";
export const getRecoveryCollectionSchema = {
name: "get_recovery_collection",
description:
"Get recovery scores for a date range. Returns HRV, resting heart rate, SpO2, and skin temp.",
inputSchema: z.object({
start: z.string().optional().describe("ISO 8601 start time (inclusive)"),
end: z.string().optional().describe("ISO 8601 end time (exclusive)"),
limit: z.number().optional().describe("Max records (1-25). Default 10."),
}),
};
export async function getRecoveryCollection(
client: WhoopClient,
params: { start?: string; end?: string; limit?: number }
): Promise<RecoveryCollection> {
const searchParams = new URLSearchParams();
if (params.start) searchParams.set("start", params.start);
if (params.end) searchParams.set("end", params.end);
if (params.limit) searchParams.set("limit", String(params.limit));
return client.get<RecoveryCollection>(`/v2/recovery?${searchParams.toString()}`);
}Testing
- TDD: Write tests before code (Prove-It pattern for bugs)
- Mock the WHOOP API: Never hit the real API in tests. Use
vi.fn()to mockfetch. - Test hierarchy: unit > integration > e2e (use the lowest level that captures the behavior)
- Coverage target: >80% on
src/auth/andsrc/api/, >70% overall - Run
npm testafter every change
WHOOP API Reference
- Base URL:
https://api.prod.whoop.com/developer - OAuth Auth URL:
https://api.prod.whoop.com/oauth/oauth2/auth - OAuth Token URL:
https://api.prod.whoop.com/oauth/oauth2/token - Required Scopes:
read:recovery read:cycles read:workout read:sleep read:profile read:body_measurement - All endpoints use v2. Date params use ISO 8601. Collections default
limit=10(max 25).
| MCP Tool | Endpoint | Method |
get_profile | /v2/user/profile/basic | GET |
get_recovery_collection | /v2/recovery | GET |
get_sleep_collection | /v2/activity/sleep | GET |
get_workout_collection | /v2/activity/workout | GET |
get_cycle_collection | /v2/cycle | GET |
get_body_measurement | /v2/user/measurement/body | GET |
Boundaries
Always
- Run
npm testbefore every commit - Validate all tool input with Zod schemas
- Store tokens in
~/.whoop-mcp/with0600permissions - Return helpful error messages (Claude needs to understand failures)
- Build in small, verifiable increments: implement → test → verify → commit
Ask First
- Adding any runtime dependency beyond
@modelcontextprotocol/sdkandzod - Changing the token storage location or format
- Adding WHOOP API endpoints not in the MVP 6 tools
- Changing the OAuth flow
- Database schema changes
Never
- Commit
WHOOP_CLIENT_ID,WHOOP_CLIENT_SECRET, or tokens - Store tokens in a world-readable location
- Make real WHOOP API calls in automated tests
- Use
any— strict TypeScript throughout - Remove or skip failing tests without discussion
- Mix formatting changes with behavior changes
Implementation Status
Current phase: Shipped. All 10 tasks complete. 212 tests passing, typecheck clean, build clean, lint clean. ✅ MCP Inspector tested (2026-04-12) — OAuth grant flow +
get_profilereturning real data. ✅ Claude Desktop tested (2026-04-12) — server connected, OAuth completed, tools accessible from chat. ✅ Published to npm (2026-04-12) —whoop-ai-mcp@0.1.0at https://www.npmjs.com/package/whoop-ai-mcp Plan:docs/specs/implementation-plan.mdSpec:docs/specs/whoop-mcp-server.mdCode review:docs/reviews/code-review-checkpoint-1.md(Tasks 1–5 approved)
Implementation Order
- ✅ Project scaffold (package.json, tsconfig, eslint, vitest)
- ✅ WHOOP API types (
src/api/types.ts,src/api/endpoints.ts) - ✅ Token store (
src/auth/token-store.ts) — 18 tests - ✅ API client (
src/api/client.ts) — 16 tests - ✅ OAuth flow (
src/auth/oauth.ts,src/auth/callback-server.ts) — 41 tests - ✅ MCP server shell (
src/server.ts) — 16 tests - ✅ Tool implementations (
src/tools/*.ts) — 33 tool tests + 16 server integration tests - ✅ Error handling — WhoopNetworkError, 429 retry w/ backoff, 401 token refresh, safeTool wrapper — 17 new tests
- ✅ Entry point + CLI (
src/index.ts) — env var validation, auth wiring, client w/ token refresh, stdio transport — 14 tests - ✅ Docs + publish prep — README, LICENSE, CHANGELOG, CONTRIBUTING, package.json metadata
Known Issues from Code Review
- Callback server tests use random port range (flaky in CI) — use port
0instead - Refresh failure silently swallowed in
authenticate()— should log/differentiate errors openBrowserhas shell injection vector — should usespawnwith arg arrays
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

