ww serve starts a local HTTP server with the same tools as the MCP server, as
REST/JSON with an OpenAPI 3.1 description. Use it from scripts, n8n, Home Assistant, Apple Shortcuts,
or from your own backend in any language. The same server speaks MCP over HTTP at /mcp.
It is generated from the same tool definitions as the MCP server, so the tool reference
describes every endpoint's arguments. It runs on your machine, with your WW session, and listens on
127.0.0.1 unless you say otherwise.
Start it
ww login # once: the server uses the stored session
ww serve # http://127.0.0.1:8787
ww serve --read-only # only read toolsww-api is the same server as a standalone command. It renews the token like the CLI does.
| Flag | Meaning | Default |
|---|---|---|
--host <addr> | Address to bind. Non-loopback only when given explicitly, with a warning. | 127.0.0.1 |
--port <n> | Port. 0 picks a free one. | 8787 |
--read-only | Only tools annotated read-only. | off |
--allow-raw | Also expose the raw ww_api_call tool (GET only, unless WW_ALLOW_RAW_WRITES=1 is set). Never combined with --read-only. | off |
--no-mcp | Do not serve MCP at /mcp. | MCP on |
--rate-limit <n> | Requests per minute and client address; 0 = off. | 120 |
--quiet | No request log on stderr. | log on |
--show-key | Print the API key (creating it if needed) and exit. |
ww_login is never exposed: it opens a page on the machine that runs the server.
API key
Every route except /healthz and /docs needs Authorization: Bearer <key>.
- On the first start a key (
wwk_...) is generated, stored in$WW_HOME/api-key(mode 600) and printed once. Show it again withww serve --show-key. WW_API_KEY(at least 16 characters) overrides the file and is never written to disk.- Rotate by deleting the file and restarting.
- The key is compared in constant time and never returned or logged. The WW token and password never leave the server.
The API key only protects this server. It is not the WW session.
Endpoints
| Method and path | Key | Description |
|---|---|---|
GET /healthz | no | { ok, version, tools, readOnly }. No account access. |
GET /docs | no | Static page rendering the OpenAPI document; asks for the key in the browser. |
GET /openapi.json | yes | OpenAPI 3.1, one operation per tool plus the read routes below. |
GET /v1/tools, GET /v1/tools/{name} | yes | Tools with annotations, JSON input schema and example. |
POST /v1/tools/{name} | yes | Call a tool; the JSON body is its arguments. |
POST /mcp | yes | MCP over Streamable HTTP, stateless. |
Read routes (GET, arguments as path and query):
| Route | Tool |
|---|---|
/v1/status | ww_status |
/v1/day, /v1/day/{date} | ww_day |
/v1/tracked[/{date}] | ww_tracked |
/v1/water[/{date}] | ww_get_water |
/v1/activity[/{date}] | ww_activity_week (seven days from the date) |
/v1/weight, /v1/weight/status | ww_weight_entries (?limit=), ww_weight_status |
/v1/search?q=banana&limit=10 | ww_search_food |
/v1/recipes/search?q=pasta | ww_search_recipes |
/v1/recipes, /v1/foods, /v1/meals, /v1/favorites | ww_list_my_*, ww_list_favorite_foods (?limit=&offset=) |
/v1/frequent | ww_frequent_and_recent |
Everything that writes goes through POST /v1/tools/{name}, so every write is an explicit,
annotated call. With --read-only those tools answer 404 unknown_tool.
Responses
{ "ok": true, "data": { "...": "structured result" }, "text": "the same as pretty JSON" }data is the tool's structured result (arrays and scalars are wrapped as { "result": ... }).
text is cut at 40000 characters with "truncated": true; data stays complete. Errors:
{ "ok": false, "error": { "code": "validation_error", "message": "...", "issues": [{ "path": "date", "message": "..." }] } }| Status | code | Meaning |
|---|---|---|
| 400 | validation_error, invalid_json | Bad arguments or body. |
| 401 | unauthorized | Missing or wrong API key. |
| 401 | ww_login_required, ww_auth_failed | The server has no usable WW session: run ww login. |
| 403 | raw_writes_disabled | Raw POST/PUT/DELETE without WW_ALLOW_RAW_WRITES=1. |
| 403 | upstream_forbidden | WW refused. |
| 404 | unknown_tool, not_found, upstream_not_found | Unknown or hidden tool, route, or ID. |
| 405 | method_not_allowed | Wrong HTTP method. |
| 409 | upstream_rejected | WW rejected the request. |
| 413 / 415 | payload_too_large, unsupported_media_type | Body over 1 MB; not application/json. |
| 429 | rate_limited, upstream_rate_limited | This server's limit (with Retry-After) or WW's. |
| 502 / 504 | upstream_error, upstream_unreachable, upstream_timeout, timeout | WW failed or is unreachable; a tool call over 120 s. |
For write tools a 504 can mean the change was applied anyway: read it back before repeating.
Examples
export WW_KEY="$(ww serve --show-key)"
curl -s http://127.0.0.1:8787/healthz
curl -s -H "Authorization: Bearer $WW_KEY" http://127.0.0.1:8787/v1/day/2026-12-03
curl -s -H "Authorization: Bearer $WW_KEY" "http://127.0.0.1:8787/v1/search?q=banana&limit=5"
curl -s -X POST http://127.0.0.1:8787/v1/tools/ww_track \
-H "Authorization: Bearer $WW_KEY" -H "Content-Type: application/json" \
-d '{"date":"2026-12-03","items":[{"name":"Snack","points":3,"timeOfDay":"anytime"}]}'The argument shapes of write tools are in the tool reference; the example field of
GET /v1/tools/{name} has a valid sample for each.
From Node (a backend that talks to ww serve):
const res = await fetch('http://127.0.0.1:8787/v1/day', { headers: { authorization: `Bearer ${process.env.WW_KEY}` } });
const { data } = await res.json();MCP over HTTP
POST /mcp speaks the Model Context Protocol (Streamable HTTP, stateless JSON responses) with the
same tool selection and the same API key. For clients that support custom headers:
{ "mcpServers": { "ww": { "type": "http", "url": "http://127.0.0.1:8787/mcp", "headers": { "Authorization": "Bearer <key>" } } } }Clients that only offer OAuth (for example the ChatGPT connector UI) cannot use it: there is no
OAuth here. --no-mcp switches it off.
Security
- Binds to
127.0.0.1. Another address needs--hostand prints a warning. Without TLS an exposed server sends the key and your health data in clear text: put a TLS reverse proxy and a firewall in front. - Key in constant time, rate limit per client address, 1 MB body limit, request timeout 30 s, tool timeout 120 s.
- No request bodies, query strings or keys in the log (path and status only).
no-storeandnosniffon every response;/docsis a static shell with a strict Content-Security-Policy.- Rate limiting uses the socket address. Behind a reverse proxy every request looks like the proxy: rate-limit there as well.
--read-onlyis enforced on the server, not just hidden: write tools do not exist for REST and MCP.- Raw access:
ww_api_callis off unless--allow-raw, host allowlist applies, and writes needWW_ALLOW_RAW_WRITES=1in the server's environment.
Docker
docker run -d --name ww-api -p 127.0.0.1:8787:8787 \
-e WW_EMAIL -e WW_PASSWORD -e WW_API_KEY -v ww-data:/data \
--entrypoint node unofficial-weightwatchers-mcp src/http/main.js --host 0.0.0.0 --read-onlyInside the container the server must bind 0.0.0.0; publish the port on loopback only (-p 127.0.0.1:...).
WW_EMAIL and WW_PASSWORD let it sign in again when the WW session expires; the /data volume keeps
the session and the generated API key. Use --entrypoint with the image's default node src/index.js
for the stdio MCP server instead.