WHOOP MCP

io.github.cunicopia-dev由 GitHub 账号 cunicopia-dev 发布v0.1.0更新于 Oct 24, 2026

Sync WHOOP recovery, sleep, strain, and workouts into Postgres and query them from any MCP client.

概览

AI 生成的概览

把 WHOOP 的恢复、睡眠、负荷与训练数据同步到你自己的 Postgres 数据库,并让助手通过只读 MCP 工具离线查询。

可以做什么
  • 完成授权与连接:获取 OAuth 授权链接,并用回调中的 code 换取并保存令牌
  • 同步 WHOOP 数据到 Postgres:按指定天数或全量拉取周期、恢复、睡眠、训练与身体测量,并返回各集合的条数与错误
  • 查看同步状态:每个集合的最后同步时间、水位线、行数与最近错误
  • 读取恢复与生命体征:近期恢复评分、静息心率、HRV、血氧与皮肤温度,以及 30 天均值与标准差基线
  • 读取睡眠、训练与周期:睡眠阶段、睡眠需求与效率,训练负荷、心率、能量、距离与心率区间分钟数,以及每日负荷
适用场景
适合希望助手回答个人 WHOOP 历史数据问题(例如本周 HRV 与基线相比如何)且不想受 WHOOP API 限流影响的场景。前提是你已有 Postgres,并愿意注册 WHOOP 开发者应用、完成 OAuth 授权流程。
运行要求
以本地 stdio 方式运行的 Python 包(Python 3.12+),通常通过 uvx 或 uv tool install 启动。需要一个 Postgres 数据库(14+ 即可)和一个 WHOOP 开发者应用。必需的环境变量为 WHOOP_CLIENT_ID、WHOOP_CLIENT_SECRET、WHOOP_REDIRECT_URI 和 WHOOP_DB_URL。需先初始化数据库 schema,同步时需能访问 WHOOP 网络。
安装前请注意
WHOOP OAuth 令牌以明文存放在 whoop_tokens 表中,任何能读取该表的人都能以你的身份调用 WHOOP API;应限制数据库权限并把 WHOOP_DB_URL 视为机密。WHOOP_CLIENT_SECRET 同样是凭据。同步会写入你的数据库,全量选项会遍历整个账号历史。授权范围为只读,不会修改 WHOOP 账号中的任何内容。

安装

在 SourceWeft 中

  1. 打开 控制台中的 WHOOP MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

whoop-mcp

[Python] [License: MIT] [storage: Postgres] [MCP]

An MCP server that syncs your WHOOP data into Postgres and lets AI agents query it.

WHOOP's public API is rate-limited, cursor-paginated, and returns one record at a time. That is fine for a sync job and terrible for an agent that wants to answer "how does my HRV this week compare to my baseline?". So this server splits the job in two:

  • a sync path that pulls cycles, recovery, sleep, workouts, and body measurements from the WHOOP API into a documented Postgres schema, keeping the raw JSON of every record alongside the typed columns;
  • a query path of MCP tools that read Postgres only. They are fast, never hit WHOOP's rate limits, and keep working offline once data is synced.

Your data lands in a database you own, in a schema you can read with any SQL client, and nothing leaves your machine except calls to WHOOP itself.

Python 3.12+ · MIT · stdio MCP server + CLI · Postgres storage


Contents


Tools

Two write-side tools talk to the WHOOP API; everything else reads Postgres only.

ToolArgsWhat it does
whoop_auth_urlnoneReturns the OAuth authorization URL to open in a browser.
whoop_connectcodeExchanges the OAuth code for tokens, stores them, returns the connected user.
whoop_syncdays=7, full=falsePulls data from WHOOP into Postgres. Returns per-collection counts and errors.
whoop_statusnonePer-collection sync health: last sync, watermark, row count, last error.
whoop_overviewdays=7Latest recovery and vitals vs. 30-day baseline, last night's sleep, recent workouts and strain.
whoop_recoverydays=7, limit=50Recent recovery scores, resting HR, HRV, SpO2, skin temperature.
whoop_sleepdays=7, limit=50Recent sleeps and naps with stage breakdown, need, performance, efficiency.
whoop_workoutsdays=14, limit=50Recent workouts with strain, HR, energy, distance, and zone minutes.
whoop_cyclesdays=7, limit=50Recent physiological cycles (WHOOP days) with day strain and HR.
whoop_baselinenone30-day mean and standard deviation per vital.

days is capped at 365 and limit at 200. All tools return JSON text.

Install

bash
uv tool install whoop-postgres-mcp      # or: pipx install whoop-postgres-mcp

Or run it without installing:

bash
uvx whoop-postgres-mcp --help

You also need a Postgres database (any recent version; 14+ is fine) and a WHOOP developer app. docs/SETUP.md walks through both.

Quickstart

bash
export WHOOP_CLIENT_ID=...export WHOOP_CLIENT_SECRET=...export WHOOP_REDIRECT_URI=http://localhost:8765/callbackexport WHOOP_DB_URL=postgresql://whoop:whoop@localhost:5432/whoop
whoop-mcp init-db          # create the `whoop` schema (idempotent)whoop-mcp auth-url         # print the URL to visit; approve access in a browserwhoop-mcp connect <code>   # paste the `code` from the redirect URLwhoop-mcp sync --all       # first backfill; later runs: whoop-mcp sync --days 7whoop-mcp                  # serve MCP over stdio

The same flow is available as MCP tools (whoop_auth_url, whoop_connect, whoop_sync) so an agent can drive the whole setup.

Configuration

All configuration is by environment variable. The server validates every variable at startup and exits with a message naming each missing one.

VariableRequiredMeaning
WHOOP_CLIENT_IDyesClient ID of your WHOOP developer app.
WHOOP_CLIENT_SECRETyesClient secret of your WHOOP developer app.
WHOOP_REDIRECT_URIyesRedirect URI, exactly as registered on the app. Any URL works; the server does not listen on it. You copy the code from the address bar.
WHOOP_DB_URLyesPostgres DSN, e.g. postgresql://user:pass@host:5432/db. Tokens and data live here.

Register with an MCP client

Claude Code:

bash
claude mcp add whoop -e WHOOP_CLIENT_ID=... -e WHOOP_CLIENT_SECRET=... \  -e WHOOP_REDIRECT_URI=http://localhost:8765/callback \  -e WHOOP_DB_URL=postgresql://whoop:whoop@localhost:5432/whoop \  -- uvx whoop-postgres-mcp

Claude Desktop (claude_desktop_config.json) or any client that takes a stdio command:

json
{  "mcpServers": {    "whoop": {      "command": "uvx",      "args": ["whoop-postgres-mcp"],      "env": {        "WHOOP_CLIENT_ID": "...",        "WHOOP_CLIENT_SECRET": "...",        "WHOOP_REDIRECT_URI": "http://localhost:8765/callback",        "WHOOP_DB_URL": "postgresql://whoop:whoop@localhost:5432/whoop"      }    }  }}

How sync works

WHOOP's collection endpoints filter on when a record occurred, not when it was last modified, and records change after creation (a sleep is created as PENDING_SCORE and scored later). The sync therefore:

  1. always re-fetches the last days days, which catches late re-scores;
  2. tracks a per-collection watermark (newest_updated_at in whoop_sync_state). If the last sync is older than days, the window is stretched back to the watermark minus a two-day lookback so a gap never leaves a hole;
  3. upserts every record on its natural key (id, or cycle_id for recovery), so overlapping windows are harmless and re-running is safe;
  4. records per-collection errors in whoop_sync_state and carries on with the other collections rather than aborting the run.

full=true (or whoop-mcp sync --all) drops the lower bound and walks the account's entire history. Body measurements are a single current record and are refreshed on every sync.

Token refresh is proactive (five minutes before expiry) and serialized through a Postgres advisory lock, so the MCP server and a cron-driven whoop-mcp sync can share one token row without racing.

The full data model is documented in docs/SCHEMA.md.

Security model

  • Database access is token access. OAuth tokens are stored in plaintext in whoop.whoop_tokens. Anyone who can read that table can call the WHOOP API as you until the refresh token is revoked. Restrict database grants accordingly and treat WHOOP_DB_URL as a secret.
  • Read tools never reach the network. Only whoop_connect and whoop_sync talk to WHOOP. Everything else is a SQL query against your database.
  • Nothing is written outside Postgres. No files, no caches, no telemetry.
  • Scopes are read-only. The app requests read:* scopes plus offline for refresh tokens. It cannot modify anything in your WHOOP account.
  • To revoke access, delete the row from whoop_tokens and remove the app from your WHOOP account settings.

Development

bash
git clone https://github.com/cunicopia-dev/whoop-mcpcd whoop-mcpuv venv && source .venv/bin/activateuv pip install -e ".[dev]"
ruff check .mypy srcpytest                       # pure-logic testsWHOOP_TEST_DB_URL=postgresql://whoop:whoop@localhost:5432/whoop pytest   # + live DB tests

The live tests apply the schema and truncate every table in the target database before each test. Point them at a scratch database.

A throwaway Postgres for local testing:

bash
docker run -d --rm --name whoop-pg -e POSTGRES_USER=whoop -e POSTGRES_PASSWORD=whoop \  -e POSTGRES_DB=whoop -p 5432:5432 postgres:16-alpine

Project layout

src/whoop_mcp/  config.py     environment variables, validated at startup  auth.py       OAuth2 flow, token persistence, locked refresh  client.py     httpx client: pagination, backoff, Retry-After  schema.sql    the Postgres DDL (applied by `whoop-mcp init-db`)  db.py         connection + schema helpers  sync.py       incremental sync with per-collection watermarks  queries.py    read-side SQL behind the MCP tools  server.py     MCP server over stdio + CLI entry pointdocs/  SETUP.md      WHOOP app registration, OAuth walkthrough, DB init, first sync  SCHEMA.md     column-by-column data modeltests/          config, schema, client, auth, sync, and stdio protocol tests

License

MIT. See LICENSE.

来源:README.md,提交 328722c

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分