fix(acp): scope MCP servers by session - #40979
Draft
vanzue wants to merge 4 commits into
Draft
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ed7b8fd5-dea4-4d5f-931c-77223bdcb408
vanzue
marked this pull request as draft
August 7, 2026 03:07
Preserve ACP session identity through the MCP API and registry, expose only global and owning-session capabilities, and remove scoped clients when sessions close. This replaces permission-based filtering and allows same-name MCP servers to coexist safely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ed7b8fd5-dea4-4d5f-931c-77223bdcb408
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #40978
Type of change
What does this PR do?
Preserves the backing OpenCode session ID when ACP registers an MCP server, through the generated SDK and HTTP API into the MCP registry. Dynamic registrations are keyed by logical name plus owner session, while static configuration remains global.
MCP clients, tools, resources, resource templates, resource reads, and server instructions now expose only global registrations plus registrations owned by the requesting session. A session-owned registration overrides a same-name global registration only for that session, so different ACP sessions can safely use same-name servers with different endpoints and credentials.
Closing an ACP session removes and closes only its owned MCP registrations. This replaces the previous permission-based filtering workaround: isolation no longer depends on permission requests or persistent deny rules.
How did you verify your code works?
bun test --timeout 30000 test/mcp/lifecycle.test.ts test/acp/service-session.test.ts(56 passed)bun test --timeout 30000 test/acp(129 passed)bun typecheckfrompackages/opencodebun typecheckfrompackages/sdk/jsopencode acpprocess with a local streaming model and distinct HTTP MCP endpoints: each session received and called only its own tool/header; a new session could not see a closed session's tools; two same-name registrations both called their owning session's endpointScreenshots / recordings
N/A
Checklist