`magpie tool memory_search --scope project --json` exited 1 with "isn't
JSON-RPC: is it magpie? (invalid character 'e' ...)", and memory_save said
the same after it had saved. The CLI sent no X-Magpie-Cwd, so the memory
server asked it roots/list on the call's own event stream (it accepts
text/event-stream), waited 3s for an answer that never came, and sent the
result as a second SSE event; rpc() then read the whole stream as one JSON
body.
Now magpie tool sends the folder it runs in (X-Magpie-Cwd), as `magpie mcp
memory` does, so --scope project is that folder's project and no roots are
asked. rpc() also reads a text/event-stream answer: it takes the data event
whose id is the call's, answers a server's roots/list with its folder and
refuses any other ask at once, so no server's question breaks the CLI or
makes it wait.
Run (mote, -tags nogui):
- TestToolMemoryThroughTheGateway (real gateway, sandbox HOME, a git repo
as cwd): red on the old code with the reporter's exact error; green now,
both calls under 2.5s.
- TestToolReadsAnEventStreamAndAnswersTheServer: red on the old code.
- go test ./internal/cli: ok.
Broken by hand: without the header, the event-stream test is red (no
folder named); with stream reading off, it is red with the reporter's
error.
Not tried: the reporter's macOS app build itself; Windows.