Files
magpie/docs
yetone 7bcb161938 gateway: the MCP router gives Alma's Node fetch magpie-image: Sec-Fetch-Mode alone is not a web page (chang_lochuan on X)
Alma's MCP client is Node's fetch (undici in alma-server/lib/server.mjs). It
sends Sec-Fetch-Mode: cors on every request, with no Origin, no
Sec-Fetch-Site and no browser agent. hubVisitor used fromBrowser, which counts
Sec-Fetch-Mode, so Alma was an Away visitor and the HereOnly servers
(magpie-image) were neither listed nor run for it, while magpie-vision showed.

hubFromPage judges the hub's visitor by what a page's POST always carries and
its script can't remove: Origin (null under no-referrer too), Sec-Fetch-Site,
a Mozilla/ agent. The hub takes POST only, so the GET-without-Origin rebinding
case fromBrowser covers does not reach it; a rebound name is still refused
first by lanGuard's rebound (an Origin or Mozilla agent) and serveMCP refuses
any Origin that isn't listed in Settings. fromBrowser itself is unchanged for
heap, memory, join, restart and the rest. No per-agent token exists for a local
agent (the hub entry carries a key only from another machine), so the decision
rests on the marks, not on a credential.

Run (mote): TestHub* in internal/gateway; new
TestHubGivesAlmaItsHereOnlyServersNotAPage (Alma's headers are given
magpie-image; Origin null, evil, localhost, evil.localhost, tauri.localhost,
app://obsidian.md, chrome-extension://, Sec-Fetch-Site only, Mozilla/ agent
only, and three rebound-Host shapes get none and run nothing, no key). Red on
the old code ("Alma's fetch is given 200 [magpie-vision]"). Broke by hand:
hubFromPage = fromBrowser(r) goes red; dropping the Origin mark stays green
because serveMCP refuses an unlisted Origin on its own (two layers).
gofmt, vet darwin/linux(nogui)/windows, then go test -tags nogui -count=1
./internal/gateway (ok, 1283s) and ./internal/library (ok, 300s) at the
commit before the rebase onto origin/main.
Not tried: the real Alma app against a real hub (its config is the user's live one).
2026-11-11 19:55:21 +08:00
..