Skip to content

refactor(mcp): serve stdio memory tools through the SDK, drop the SSE bridge - #920

Closed
ducnmm wants to merge 2 commits into
devfrom
henrynguyen/walm-629-local-memwal-mcp-implements-tools-via-sdk-rest-deprecate-sse
Closed

ducnmm wants to merge 2 commits into
devfrom
henrynguyen/walm-629-local-memwal-mcp-implements-tools-via-sdk-rest-deprecate-sse

Conversation

@ducnmm

@ducnmm ducnmm commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

stdio @mysten-incubation/memwal-mcp already holds the delegate key, then used to open a long-lived SSE session to /api/mcp/sse and forward tools/call to the sidecar. That session is a second protocol, a second occupancy slot, and a second auth story next to the SDK — which is why Teo hits ip_active_cap, handshake 429/503, 240s “connection dropped” on a healthy /health, and bulk saves that store nothing.

This PR cuts that layer. Login/logout stay local (credentials.json, dashboard loopback). Memory tools call MemWal.create({ key, accountId, serverUrl }) the same way researcher and noter already do.

MCP client  --stdio-->  memwal-mcp
                            |
                            +-- memwal_login / logout (local)
                            +-- remember / recall / bulk / analyze / restore / health
                                    --> MemWal.create(...) --> signed REST
  • No GET /api/mcp/sse, no POST /api/mcp/messages, no occupancy slot on this path.
  • Relayer 401 is a retryable error. It does not wipe credentials.json.
  • memwal_logout deletes the file and destroys the in-process client.
  • Claude.ai Streamable HTTP /api/mcp (OAuth) is unchanged.
  • Follow-up: 410 /api/mcp/sse once plugin traffic is off it.

Linear: WALM-629

Why SSE is the wrong layer here

SDK clients POST /api/remember per call. They do not have this class of bug. Community feedback on #walrus-memwal-build was the same: REST was fine; the Claude Code plugin orphaned tool calls after ~240s. Harry’s investigation of Dio’s 3–8 min saves found no slow request on the relayer — the wait was client-side handshake backoff.

Live check against relayer.memory.walrus.xyz with this branch (stdio MCP, no SSE mock):

Call Result Time
initialize local 103 ms
memwal_health ok, write_ready=true 562 ms
memwal_remember blob on mainnet 28 s
memwal_recall score=1.000 of that write 2.5 s
/api/mcp/sse not opened 0

28 s remember is the write pipeline (embed / SEAL / Walrus), not the transport. That stays WALM-621. This PR only removes the session.

Test plan

  • pnpm --filter @mysten-incubation/memwal-mcp test (90 pass)
  • remember/recall unit tests with an SDK stub, no SSE mock
  • spawn: memwal_health hits GET /health only
  • live prod stdio remember → recall
  • CI MCP integration job
  • Do not 410 /api/mcp/sse in this PR

… bridge

The local stdio process already holds the delegate key. Forwarding every
tools/call over a long-lived GET /api/mcp/sse session added a second
protocol, a second occupancy slot, and a class of failures SDK clients
never see (ip_active_cap 429, handshake 503, idle stream, 240s orphan).

stdio MCP now answers initialize/tools/list locally, keeps memwal_login
and memwal_logout on this machine, and implements remember/recall/bulk/
analyze/restore/health as MemWal.create({ key, accountId, serverUrl })
signed REST. Relayer 401 is a retryable error and does not wipe
credentials.json. Logout still drops the in-process client. The Claude.ai
Streamable HTTP /api/mcp path is unchanged.

Tests cover remember/recall with an SDK stub (no SSE mock) and a spawn
path that hits GET /health without opening /api/mcp/*. Follow-up: 410
/api/mcp/sse once plugin traffic is off it.
…ials

The CLI still cloned credentials when --relayer/--dev disagreed with the
file, but the clone never reached MemWal.create. Memory tools always
dialled credentials.json, so a prod file plus --local still signed
against prod. Pass the flag through as an in-memory override, same as
the old bridge, and keep the saved URL untouched.
@nikola0x0

Copy link
Copy Markdown
Collaborator

Parking note — this one isn't waiting on review.

Per the internal discussion on Sep 18: we're keeping the SSE bridge for now, so the "drop the SSE bridge" half of this PR is on hold. It's backlogged together with WALM-652 (memwal_namespaces MCP tool), which is blocked on it.

@ducnmm flagging so it stops sitting in the review queue — feel free to convert it to draft whenever convenient. The SDK-backed stdio tools can come back up for review once we actually schedule the SSE cutover.

@ducnmm

ducnmm commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @nikola0x0 — parking this.

Keeping the SSE bridge for now; the drop-SSE half of this PR is on hold with WALM-652. I'll convert to draft so it drops out of the review queue.

SDK-backed stdio tools can come back as a smaller PR once we schedule the SSE cutover.

@ducnmm

ducnmm commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this parked draft.

We are keeping the SSE bridge; the drop-SSE half of this change stays on hold with WALM-652. The branch was conflicting with dev and Compile & CLI Smoke was failing, so it should not sit in the open queue.

The two commits remain on this closed PR if we pick the work back up:

  • 79b81a0a refactor(mcp): serve stdio memory tools through the SDK, drop the SSE bridge
  • 20279829 fix(mcp): honour --relayer for this process without rewriting credentials

@ducnmm ducnmm closed this Sep 24, 2026
@ducnmm
ducnmm deleted the henrynguyen/walm-629-local-memwal-mcp-implements-tools-via-sdk-rest-deprecate-sse branch September 24, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants