# shashankswe2020-ux/whoop-mcp architecture

> Architecture diagram of the GitHub repository shashankswe2020-ux/whoop-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shashankswe2020-ux/whoop-mcp
- Repository: https://github.com/shashankswe2020-ux/whoop-mcp

## Overview

whoop-ai-mcp is a local, read-only WHOOP MCP server. An assistant invokes registered tools or reads resources; the server’s tool handlers fetch and analyze WHOOP records through an authenticated API client, then return structured results. OAuth setup and token refresh support that workflow, while stdio and HTTP transports expose it. The README also documents prompt templates, aggregate privacy mode, and optional telemetry. Relationships for unsampled tool modules and some server registrations are supported only by the README or source-index references, so those links are shown at subsystem level.

Main entry points: [`src/tools`](https://github.com/shashankswe2020-ux/whoop-mcp/tree/main/src/tools) (Health data tools), [`src/server.ts`](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/server.ts) (MCP server), [`src/api/client.ts`](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/client.ts) (API client), [`src/index.ts`](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/index.ts) (Runtime entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup_auth["Setup and authorization"]
  node_cli_setup["Setup wizard<br/>[setup.ts]"]
  node_oauth["OAuth flow<br/>[oauth.ts]"]
  node_token_store["Token storage<br/>[token-store.ts]"]
end

subgraph group_mcp_features["MCP capabilities"]
  node_entry["Runtime entry<br/>[index.ts]"]
  node_server["MCP server<br/>[server.ts]"]
  node_tools["Health data tools"]
  node_analytics["Analytics utilities<br/>[analytics-utils.ts]"]
  node_resources["Health resources<br/>[index.ts]"]
  node_prompts["Prompt templates<br/>[index.ts]"]
  node_transports["MCP transports"]
end

subgraph group_data_access["WHOOP data access"]
  node_api_client["API client<br/>[client.ts]"]
  node_pagination["Page fetching<br/>[pagination.ts]"]
  node_api_schema["API schemas<br/>[record-schemas.ts]"]
  node_cache["Response cache<br/>[memory-cache.ts]"]
end

subgraph group_telemetry["Usage telemetry"]
  node_telemetry_runtime["Telemetry controls<br/>[telemetry.ts]"]
  node_collector["Telemetry collector<br/>[collector.ts]"]
  node_collector_store[("Aggregate storage<br/>[storage.ts]")]
  node_collector_worker["Collector worker<br/>[worker.ts]"]
end

node_assistant(("AI assistant"))
node_whoop{{"WHOOP API"}}

node_assistant -->|"connects through"| node_transports
node_transports -->|"serves requests"| node_server
node_entry -->|"creates"| node_server
node_entry -->|"authenticates with"| node_oauth
node_oauth -->|"loads and saves"| node_token_store
node_cli_setup -->|"verifies credentials"| node_oauth
node_server -->|"registers handlers"| node_tools
node_server -->|"registers resources"| node_resources
node_assistant -->|"uses templates"| node_prompts
node_tools -->|"fetches records"| node_api_client
node_tools -->|"computes summaries"| node_analytics
node_tools -->|"fetches pages"| node_pagination
node_tools -->|"validates records"| node_api_schema
node_resources -->|"fetches resource data"| node_api_client
node_api_client -->|"requests records"| node_whoop
node_api_client -->|"uses cache"| node_cache
node_entry -->|"configures telemetry"| node_telemetry_runtime
node_telemetry_runtime -.->|"may report aggregates"| node_collector
node_collector_worker -->|"runs collection"| node_collector
node_collector -->|"writes aggregates"| node_collector_store

click node_cli_setup "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/cli/setup.ts"
click node_oauth "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/auth/oauth.ts"
click node_token_store "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/auth/token-store.ts"
click node_entry "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/index.ts"
click node_server "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/server.ts"
click node_tools "https://github.com/shashankswe2020-ux/whoop-mcp/tree/main/src/tools"
click node_analytics "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/tools/analytics-utils.ts"
click node_resources "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/resources/index.ts"
click node_prompts "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/prompts/index.ts"
click node_transports "https://github.com/shashankswe2020-ux/whoop-mcp/tree/main/src/transport"
click node_api_client "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/client.ts"
click node_pagination "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/pagination.ts"
click node_api_schema "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/record-schemas.ts"
click node_cache "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/cache/memory-cache.ts"
click node_telemetry_runtime "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/telemetry/telemetry.ts"
click node_collector "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/collector/src/collector.ts"
click node_collector_store "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/collector/src/storage.ts"
click node_collector_worker "https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/collector/src/worker.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli_setup,node_oauth,node_token_store toneBlue
class node_entry,node_server,node_tools,node_analytics,node_resources,node_prompts,node_transports toneAmber
class node_api_client,node_pagination,node_api_schema,node_cache,node_whoop toneMint
class node_telemetry_runtime,node_collector,node_collector_store,node_collector_worker toneRose
class node_assistant toneIndigo
```

## Components

### Setup and authorization

- [Setup wizard](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/cli/setup.ts): `src/cli/setup.ts`
- [OAuth flow](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/auth/oauth.ts): `src/auth/oauth.ts`
- [Token storage](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/auth/token-store.ts): `src/auth/token-store.ts`

### MCP capabilities

- [Runtime entry](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/index.ts): `src/index.ts`
- [MCP server](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/server.ts): `src/server.ts`
- [Health data tools](https://github.com/shashankswe2020-ux/whoop-mcp/tree/main/src/tools): `src/tools`
- [Analytics utilities](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/tools/analytics-utils.ts): `src/tools/analytics-utils.ts`
- [Health resources](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/resources/index.ts): `src/resources/index.ts`
- [Prompt templates](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/prompts/index.ts): `src/prompts/index.ts`
- [MCP transports](https://github.com/shashankswe2020-ux/whoop-mcp/tree/main/src/transport): `src/transport`

### WHOOP data access

- [API client](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/client.ts): `src/api/client.ts`
- [Page fetching](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/pagination.ts): `src/api/pagination.ts`
- [API schemas](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/api/record-schemas.ts): `src/api/record-schemas.ts`
- [Response cache](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/cache/memory-cache.ts): `src/cache/memory-cache.ts`

### Usage telemetry

- [Telemetry controls](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/src/telemetry/telemetry.ts): `src/telemetry/telemetry.ts`
- [Telemetry collector](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/collector/src/collector.ts): `collector/src/collector.ts`
- [Aggregate storage](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/collector/src/storage.ts): `collector/src/storage.ts`
- [Collector worker](https://github.com/shashankswe2020-ux/whoop-mcp/blob/main/collector/src/worker.ts): `collector/src/worker.ts`

### Other components

- **AI assistant**
- **WHOOP API**

## Connections

- AI assistant → MCP transports: connects through (evidence: `README.md`)
- MCP transports → MCP server: serves requests (evidence: `src/index.ts`)
- Runtime entry → MCP server: creates (evidence: `src/index.ts`)
- Runtime entry → OAuth flow: authenticates with (evidence: `src/index.ts`)
- OAuth flow → Token storage: loads and saves (evidence: `src/auth/oauth.ts`)
- Setup wizard → OAuth flow: verifies credentials (evidence: `src/cli/setup.ts`)
- MCP server → Health data tools: registers handlers (evidence: `src/server.ts`)
- MCP server → Health resources: registers resources (evidence: `src/resources/index.ts`)
- AI assistant → Prompt templates: uses templates (evidence: `README.md`)
- Health data tools → API client: fetches records (evidence: `src/tools/get-today.ts`)
- Health data tools → Analytics utilities: computes summaries (evidence: `src/tools/get-today.ts`)
- Health data tools → Page fetching: fetches pages (evidence: `src/tools/get-weekly-summary.ts`)
- Health data tools → API schemas: validates records (evidence: `src/tools/get-today.ts`)
- Health resources → API client: fetches resource data (evidence: `src/resources/index.ts`)
- API client → WHOOP API: requests records (evidence: `src/api/client.ts`)
- API client → Response cache: uses cache (evidence: `src/api/client.ts`)
- Runtime entry → Telemetry controls: configures telemetry (evidence: `src/index.ts`)
- Telemetry controls → Telemetry collector: may report aggregates
- Collector worker → Telemetry collector: runs collection (evidence: `collector/src/worker.ts`)
- Telemetry collector → Aggregate storage: writes aggregates (evidence: `collector/src/storage.ts`)
