Skip to content

fix: forward ACP session mcpServers to the backend's session create/resume - #43

Merged
william0wang merged 3 commits into
william0wang:mainfrom
lianxin255:fix/mcp-servers-forwarding
Aug 16, 2026
Merged

fix: forward ACP session mcpServers to the backend's session create/resume#43
william0wang merged 3 commits into
william0wang:mainfrom
lianxin255:fix/mcp-servers-forwarding

Conversation

@lianxin255

Copy link
Copy Markdown
Contributor

Closes #42 (option 1 from there).

What

session/new and session/resume accepted an mcpServers parameter but never read it, so client-provided stdio servers were silently dropped — a session only ever saw the local ~/.zcode-configured servers.

This PR:

  • stores params.mcpServers on the lazy pending session in session/new and replays it into session/create when the session materializes,
  • forwards params.mcpServers on session/resume.

Entries are passed through verbatim: the backend's schema accepts the ACP mcpServers array shape as-is (stdio entries carry command/args/env as [{name,value}] pairs; remote entries carry type/url). One subtlety found while probing: the stdio union branch rejects a type key, so no field renaming or type: "stdio" injection is done anywhere.

The session/resume schema was verified to accept the key (an unknown key is rejected by zod before the session lookup, and mcpServers is not).

Verification

  • vitest run: 461/461 green.
  • End-to-end through Multica (daemon → bridge → ZCode CLI 0.16.3, real GLM turn): an agent configured with a trivial stdio echo server (node mcp-echo.mjs, one mcp_echo tool) now reports:
    • the injected tool working: mcp_echo called with message=fixed-via-forwarding returned MCP-ECHO-SAID: fixed-via-forwarding;
    • the merge is additive: the session lists echo alongside the runtime's own local servers (4_5v_mcp, node_repl, web_reader, …) — local config untouched.

Context: this unblocks Multica-side agent MCP configuration for the ZCode runtime family (the integration I mentioned in #41/#42).

…esume

session/new and session/resume accepted an mcpServers parameter but never
read it, so client-provided stdio servers were silently dropped — the
session only ever saw the local ~/.zcode-configured servers (verified with
a trivial stdio echo server: the tool never appeared, while local servers
loaded fine).

The backend's session/create and session/resume schemas accept the ACP
mcpServers array shape verbatim (stdio entries carry command/args/env as
[{name,value}] pairs; remote entries carry type/url; the stdio branch
rejects a "type" key, so entries are passed through unchanged). This change

- stores params.mcpServers on the lazy pending session in session/new and
  replays it into session/create when the session materializes,
- forwards params.mcpServers on session/resume (schema-verified: an unknown
  key is rejected before the session lookup, and mcpServers is not),

Verified end-to-end through Multica (daemon -> bridge -> zcode 0.16.3):
an agent-configured echo server now appears as mcp__echo__mcp_echo next to
the runtime's own local servers (context7, web_reader, ...), i.e. the merge
is additive and the local config is untouched.

Closes william0wang#42
- mcpServers on the pending session is acp.McpServer[] (the SDK's own
  union) instead of unknown[]
- the create-path comment asserted "client entries winning on name clash
  is the backend's rule" — only the additive merge was verified, so the
  comment now says exactly that and leaves clash behaviour unasserted
Three tests per the contributing guide's fail-before/pass-after rule:
- client mcpServers from session/new are replayed verbatim into the
  backend's session/create when the lazy placeholder materializes
- session/create omits the key entirely when none were provided (no
  empty-array noise for the backend's strict schema)
- resume-provided mcpServers reach the backend's session/resume

461 → 464 tests, all green.
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.

session/new ignores the ACP mcpServers parameter — consider forwarding to the backend's session/create

2 participants