Files
magpie/internal/browsermcp
yetone a28744c325 gateway: memory is an MCP server every agent can mount
memory_search, memory_save and memory_forget at /mcp/magpie/memory,
served and guarded as the search server is (serveMCP): another computer
reaches it only while magpie is shared, with a gateway key. A save
through it is active at once, origin agent, kept everywhere, for the
project (the git repository the agent works in, by its remote) or for
the agent alone; without a folder or a client name it says it can't
know rather than guess.

- The Library's market offers it as magpie-memory, run as
  `magpie mcp memory` (browsermcp.RunMemory): stdio relayed to the
  gateway with the folder it was started in (X-Magpie-Cwd) and the
  client name from initialize (X-Magpie-Mcp-Client).
- Behind the MCP router the hub keeps it on this computer (hereOnly)
  and passes the caller's roots and client in _meta (wantsCaller), as
  it does for magpie's own server.
- OwnMCPPath lists it among magpie's own servers.
- Judged as its sibling servers are: a gateway key's MaxConcurrency
  doesn't hold it (a tool call of a turn already held), and a read-only
  key is refused (memory_save writes). The first full gateway run was
  red on TestKeySlotEveryRoute and TestReadOnlyKeyEveryRoute until the
  route was listed.

Run (mote-run):
- go test -tags nogui ./internal/gateway: ok (881.5s)
- go test ./internal/browsermcp ./internal/cli ./internal/memory: ok
- go test ./internal/library: ok (130.9s)
- go vet, GOOS darwin, linux, windows: ok; gofmt -l clean
Broken by hand, each red, then green restored:
- the hub not sending memory its caller (wantsCaller without isMemory):
  TestHubTellsMagpieMemoryItsCaller "roots asked false"
- the relay not setting X-Magpie-Cwd: TestMemoryBridgeSendsFolderAndClient
- the gateway ignoring X-Magpie-Cwd: TestMemoryMCPSharedAcrossAgents
  (a project fact kept everywhere)
Not tried: a real Claude Code or Codex mounting magpie-memory.
2026-11-10 03:25:44 +08:00
..