Cloudflare Access (Managed OAuth) runs the OAuth flow for clients such as ChatGPT; the origin verifies the signed Cf-Access-Jwt-Assertion itself -- RS256 in stdlib by construct-and-compare, issuer, AUD, expiry. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
214 lines
8.2 KiB
Markdown
214 lines
8.2 KiB
Markdown
# wodify
|
|
|
|
Read-only client for the **Wodify athlete app**. Answers "what's the workout", "what did I
|
|
book", "who's coaching", "who else is going" with a single HTTP POST — no browser at query time.
|
|
|
|
Wodify's athlete app is an OutSystems Reactive SPA. Driving it with a headless browser works but
|
|
is slow and, for an LLM agent, expensive: you render a whole page to read a few lines back out of
|
|
the DOM. Its data actions are plain JSON endpoints, so this talks to them directly.
|
|
|
|
## Read-only, by construction
|
|
|
|
This client cannot reserve, cancel, check in, log results, accept terms, or buy anything.
|
|
|
|
The credential is a full-session login — Wodify issues no read-only token — so enforcement is in
|
|
the code, not the credential:
|
|
|
|
- **Allowlist** (`actions.ACTIONS`): unregistered actions cannot be called.
|
|
- **Write guard** (`actions.assert_read_only`): any path containing `Create`, `Save`, `Reserve`,
|
|
`Cancel`, `SignIn`, `Purchase`, … is refused, *including* allowlisted entries, so a careless
|
|
registry edit still fails closed.
|
|
|
|
If you want to book a class, use the app.
|
|
|
|
## Install
|
|
|
|
```bash
|
|
pip install -e ".[prime,dev]"
|
|
```
|
|
|
|
The **query path is stdlib-only**. The `prime` extra (`websockets`) is needed only for the
|
|
occasional capture step.
|
|
|
|
## Use
|
|
|
|
```bash
|
|
wodify list date 2026-07-25
|
|
```
|
|
|
|
```
|
|
TIME COACH BOOKED CLASS DUR YOU ID
|
|
- ----- ----------- ------ ----------------------- ----- --------- ---------
|
|
07:00 Robin Vance 10/10 CrossFit: 7:00 AM 60min - 192001199
|
|
» 10:00 Pat Doyle 12/12 CrossFit Burn: 10:00 AM 60min signed in 190918189
|
|
```
|
|
|
|
Your own classes are marked `»` with your status in the `YOU` column — `signed in` for
|
|
one you attended, `reserved` for one still upcoming. This costs no extra request: the
|
|
schedule response already reports the account's relationship to each class.
|
|
|
|
(Names above are illustrative — the tool prints whatever your gym returns.)
|
|
|
|
Then feed an ID back in for the workout and the named attendee list:
|
|
|
|
```bash
|
|
wodify list workout 190918189
|
|
```
|
|
|
|
Your own classes for a day — roster and workout included — in one command:
|
|
|
|
```bash
|
|
wodify list mine # today; "No class reserved on …" if there is none
|
|
wodify list mine 2026-07-25 --days 7
|
|
```
|
|
|
|
Other commands:
|
|
|
|
```bash
|
|
wodify doctor # config, session and DB status
|
|
wodify prime # capture session state (needs a logged-in browser)
|
|
wodify bookings --since 2026-07-18 --attended
|
|
wodify schedule --date 2026-07-21
|
|
```
|
|
|
|
`--json` gives raw payloads, `--refresh` bypasses the local cache, and
|
|
`list workout --notes` adds the coach's brief.
|
|
|
|
A class ID carries neither its date nor its program — it is per-occurrence. `list date`
|
|
indexes the day into SQLite; `list workout` resolves the ID from there. Ask for an ID on a day
|
|
you never listed and it says so rather than guessing.
|
|
|
|
## MCP server
|
|
|
|
```bash
|
|
wodify mcp
|
|
```
|
|
|
|
serves the same commands over MCP (stdio), stdlib-only, for one user: whoever is logged
|
|
in. Register it with any MCP client:
|
|
|
|
```json
|
|
{"mcpServers": {"wodify": {"command": "wodify", "args": ["mcp"]}}}
|
|
```
|
|
|
|
| Tool | What it answers |
|
|
|------|-----------------|
|
|
| `my_classes` | your reserved classes with roster + workout, in one call; says so plainly when nothing is reserved |
|
|
| `list_date`, `list_workout` | a day's classes; one class's roster + workout |
|
|
| `bookings`, `schedule`, `workout`, `attendees`, `classdetail`, `coach`, `waitlist`, `wodflags` | the raw read-only actions |
|
|
| `doctor`, `prime` | status; re-capture the session after a Wodify redeploy |
|
|
|
|
To reach it over the network, serve HTTP instead (MCP streamable HTTP at `/mcp`):
|
|
|
|
```bash
|
|
umask 077; python3 -c 'import secrets; print(secrets.token_urlsafe(48))' > ~/.config/wodify/mcp-token
|
|
wodify mcp --http 127.0.0.1:8765
|
|
```
|
|
|
|
A bearer token is mandatory — it will not start without one of at least 32 characters, and
|
|
every request without it gets `401`. `prime` is not offered over HTTP. Put TLS in front
|
|
of it (a reverse proxy); the server itself speaks plain HTTP.
|
|
|
|
For OAuth clients (ChatGPT, Claude connectors), put the hostname behind a Cloudflare
|
|
Access application with Managed OAuth and tell the server to verify what Access forwards:
|
|
|
|
```bash
|
|
wodify mcp --http 127.0.0.1:8765 \
|
|
--access-team yourteam.cloudflareaccess.com --access-aud <application AUD tag>
|
|
```
|
|
|
|
Access runs the OAuth flow; the server checks the signed assertion on every request.
|
|
`--access-email` (repeatable) additionally pins which identities are accepted.
|
|
|
|
Tools run the CLI in-process, so the read-only allowlist and write guard apply unchanged
|
|
and the cache below is shared with the command line.
|
|
|
|
## Local SQLite cache
|
|
|
|
`~/.cache/wodify/wodify.db` (override with `WODIFY_DB`), created mode `600` because it holds
|
|
other members' names. Schedules (including your reservation/sign-in status) and attendee
|
|
rosters expire after **one hour**; the next query automatically fetches fresh data. Workout
|
|
content stays cached for the local calendar day. All payloads expire at midnight.
|
|
Use `--refresh` for immediate updates, especially before deciding attendance for a diary:
|
|
a one-hour cache can still predate a recent sign-in. `bookings` queries already go directly
|
|
to Wodify without this payload cache.
|
|
|
|
Every command states whether the answer came from cache or the network.
|
|
|
|
## How priming works
|
|
|
|
`prime` attaches over CDP to a Chrome that is already logged in, and captures three things that
|
|
cannot be obtained any other way:
|
|
|
|
| Thing | Why it needs a browser |
|
|
|-------|------------------------|
|
|
| `nr1W_Theme_UI` cookie | **HttpOnly** — `document.cookie` cannot read it, so it cannot be copied by hand |
|
|
| `X-CSRFToken` | Not in cookies, `localStorage`, or any JS global; only appears on outbound requests |
|
|
| `apiVersion` | **Per-action**, not global — each endpoint's value must be observed from a real call |
|
|
|
|
Results are cached at `~/.cache/wodify/session.json`, mode `600`. That file holds live
|
|
credentials: never commit it, never log it.
|
|
|
|
`prime` loads the app **from the network**, bypassing the PWA service worker for its own
|
|
tab (nothing in the profile is unregistered or cleared), and closes that tab when it is
|
|
done. After a Wodify redeploy the worker can otherwise keep serving the old runtime to the
|
|
new screens -- an app that throws before it sends a single data request. If a prime
|
|
captures nothing it says why (`page_errors`), refuses to overwrite the existing cache, and
|
|
exits 1.
|
|
|
|
### Priming against a remote profile
|
|
|
|
If the logged-in Chrome is on another host, tunnel first:
|
|
|
|
```bash
|
|
ssh -L 9222:127.0.0.1:9222 your-host
|
|
```
|
|
|
|
A minimal setup on that host: Chrome with `--headless=new --remote-debugging-port=9222
|
|
--remote-debugging-address=127.0.0.1 --user-data-dir=<profile>`, logged in once. Keep the CDP
|
|
port on loopback — it is unauthenticated, and anything that can reach it can read every cookie
|
|
in that profile.
|
|
|
|
## Staleness is explicit
|
|
|
|
Every Wodify response reports `hasModuleVersionChanged` / `hasApiVersionChanged`. When Wodify
|
|
redeploys, or the session dies, the client raises rather than returning a plausible-looking empty
|
|
result:
|
|
|
|
| Exception | Exit | Meaning |
|
|
|-----------|------|---------|
|
|
| `NotPrimedError` | 4 | No cache, or this action was never observed |
|
|
| `SessionExpiredError` | 2 | Session dead — a human must log in again, then re-prime |
|
|
| `VersionStaleError` | 3 | Wodify redeployed — re-prime |
|
|
|
|
Those exit codes are for the action commands (`bookings`, `schedule`, `workout`, …). The
|
|
`list` commands use a different set, because 2 is taken by argument errors there:
|
|
|
|
| `list date` / `list workout` | Exit |
|
|
|------------------------------|------|
|
|
| bad date or class id | 2 |
|
|
| session expired | 3 |
|
|
| Wodify redeployed — re-prime | 4 |
|
|
| not primed | 5 |
|
|
| class id not in the local index — run `list date` for its day first | 6 |
|
|
|
|
A silently wrong "no workout today" is worse than an error, so there is no fallback path that
|
|
guesses.
|
|
|
|
## Configuration
|
|
|
|
| Var | Default |
|
|
|-----|---------|
|
|
| `WODIFY_HOST` | `claycrossfit.wodify.com` |
|
|
| `WODIFY_CDP_URL` | `http://127.0.0.1:9222` |
|
|
| `WODIFY_CACHE` | `~/.cache/wodify/session.json` |
|
|
| `WODIFY_LOCATION_ID` | `11644` |
|
|
|
|
## Tests
|
|
|
|
```bash
|
|
python -m pytest -q
|
|
```
|
|
|
|
No network required. The write-guard tests assert that real mutating endpoint names are refused.
|