feat: token-protected HTTP transport for the MCP server

wodify mcp --http HOST:PORT serves MCP streamable HTTP at /mcp, stdlib only.
A bearer token of 32+ chars is mandatory and checked before the path; prime is
not offered over HTTP; tool calls are serialized.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
This commit is contained in:
lucioandClaude Mythos 5.2 committed 2026-11-21 15:21:13 -08:00
1 parent 7be931a712
commit 3909c35565
5 files changed
+324 -4

No files matched your search

+30
View File
@@ -130,6 +130,36 @@ fetches on its own; add a CLI command and wrap it.
- While serving, `sys.stdout` is pointed at stderr -- stdout is the protocol channel and a
stray `print` would corrupt it.
### HTTP transport (public: `https://wodify.luci.ooo/mcp`)
`wodify mcp --http HOST:PORT` serves the same handler over MCP streamable HTTP at `/mcp`:
stateless, JSON responses only (GET/DELETE answer 405 -- there is no SSE stream and no
session). Still stdlib (`http.server`).
This is the one part of the project reachable from the internet, fronting a full Wodify
session and other members' names. Rules that must stay:
- **A bearer token is mandatory.** `$WODIFY_MCP_TOKEN`, else `--token-file`, else
`~/.config/wodify/mcp-token`. No token, or one under 32 chars, and it refuses to start.
There is no flag to disable auth; do not add one.
- **Auth is checked before the path**, for every method, with `hmac.compare_digest`. An
unauthenticated caller gets 401 everywhere and cannot tell `/mcp` from `/`.
- **`prime` is not offered over HTTP** (it drives the host's browser) unless
`--allow-prime`. The stdio server keeps it.
- Tool calls run under a lock: `run_cli` redirects the process-wide stdout, so two
overlapping calls would swap output.
- Bodies over 1 MB are refused on the declared length, before reading. Logs carry the
request line and status only -- never headers, so never the token.
Path on the wire: Cloudflare (proxied A record `wodify.luci.ooo`, kept current by
`home-ddns` on luhpe, which follows every A record holding the home IP -- no per-record
config) -> home router :443 -> Caddy on the NAS (`wodify.luci.ooo` block, `/mcp` only)
-> `10.233.33.15:8765` on luhpe (`wodify-mcp.service`, a systemd user unit; ufw admits
only the NAS, 10.233.33.13). The hop from Caddy to luhpe is plain HTTP on the LAN.
To rotate the token: write a new one to `~/.config/wodify/mcp-token` (mode 600) and
`systemctl --user restart wodify-mcp`.
Registered with hermes on luhpe as the `wodify` server (`command:
/home/lucio/.local/bin/wodify`, `args: [mcp]`). From another machine:
`ssh luhpe .local/bin/wodify mcp` is a working stdio command.