Skip to content

fix(acp-server): restore stdio MCP server support in ACP session methods - #3168

Open
kimi-agent-bot wants to merge 3 commits into
MoonshotAI:mainfrom
kimi-agent-bot:fix/acp-stdio-mcp-regression
Open

fix(acp-server): restore stdio MCP server support in ACP session methods#3168
kimi-agent-bot wants to merge 3 commits into
MoonshotAI:mainfrom
kimi-agent-bot:fix/acp-stdio-mcp-regression

Conversation

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator

Related Issue

Resolve #3167

Problem

Since v0.37.0, every ACP session/new, session/load, and session/resume request carrying a stdio MCP server declaration fails with -32603 Internal error: ACP stdio MCP server <name> does not declare a runtime identity. Stdio is the implied baseline transport in ACP, so this breaks all ACP clients that forward stdio MCP servers — including Zed, whose context servers are stdio by default. Full analysis in the linked issue.

What changed

The regression came in with #2961 (84da662), which (a) replaced the stdio branch of acpMcpServersToConfigRecord with a hard error and (b) made the session-overlay McpConnectionManager require an explicit runtime_id for stdio configs — a value the ACP wire protocol cannot express. This PR reverts both enforcement points and fixes a second latent bug from the same refactor that the restored lifecycle test exposed:

  • packages/acp-server/src/convert.ts — restore the pre-refactor(agent-core-v2): decouple workspace from session DI via runtime binding #2961 stdio branch: map entries without a type discriminator to { transport: 'stdio', command, args, env }.
  • packages/agent-core-v2/src/workspace/workspaceMcp/workspaceMcpService.ts — drop requireStdioRuntimeId: true from the session-overlay manager only; like the baseline manager it now falls back to the workspace 'local' runtime. (Fixing only convert.ts would just move the failure to engine connect time: "MCP stdio requires runtime_id and runtime binding".)
  • packages/agent-core-v2/src/runtime/runtimeUnitHost.tsregisterRuntime no longer counts staged entries that were already removed (removeRuntime marks them inactive but keeps them in the transaction). Previously, unbinding and re-binding the same runtime id in one transaction threw "registered twice in one transaction", so session/closesession/load of the same session in one process always failed — regardless of MCP servers. commit() runs exactly once per transaction before any removal can happen, so skipping inactive entries in the duplicate check is safe.
  • Tests — restore the pre-refactor(agent-core-v2): decouple workspace from session DI via runtime binding #2961 positive assertions: convert.test.ts maps stdio servers again; lifecycle.test.ts asserts session/new and session/load actually connect an ACP-provided stdio MCP server; new runtimeUnitHost.test.ts case covers remove-then-re-register of the same runtime id.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification: @moonshot-ai/acp-server full suite 146/146 passed; @moonshot-ai/agent-core-v2 full suite 5522 passed / 1 skipped; typecheck of both packages clean; repo oxlint --type-aware 0 errors.

…al in one transaction

RuntimeUnitHost.registerRuntime counted staged entries that had already
been removed (removeRuntime marks them inactive but keeps them in the
transaction), so unbinding and re-binding the same runtime id in one
transaction failed with 'registered twice in one transaction'. ACP
session/close unbinds the session runtime and session/load re-binds it,
so close -> load of the same session in one process always failed.
84da662 (MoonshotAI#2961) replaced the stdio branch of acpMcpServersToConfigRecord
with a hard 'does not declare a runtime identity' error and made the
session-overlay McpConnectionManager require an explicit runtime_id for
stdio configs. The ACP wire protocol cannot express a runtime_id, so
every session/new, session/load, and session/resume carrying a stdio
MCP server (the ACP baseline transport, sent by default by clients such
as Zed) has failed with -32603 since v0.37.0.

Restore the pre-MoonshotAI#2961 stdio mapping and drop requireStdioRuntimeId from
the session-overlay manager; like the baseline manager it falls back to
the workspace 'local' runtime. The restored session/load lifecycle test
depends on the runtimeUnitHost rebind fix in the previous commit.
@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d794ca8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kimi-agent-bot

Copy link
Copy Markdown
Collaborator Author

@codex review

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@d794ca8
npx https://pkg.pr.new/@moonshot-ai/kimi-code@d794ca8

commit: d794ca8

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28350884b7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .changeset/acp-stdio-mcp-regression.md Outdated
@kimi-agent-bot

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: d794ca8013

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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.

ACP: stdio MCP servers rejected in session/new, session/load, session/resume since v0.37.0 (regression from #2961)

1 participant