Skip to content

fix(acp): scope MCP servers by session - #40979

Draft
vanzue wants to merge 4 commits into
anomalyco:devfrom
vanzue:acp-mcp-isolation
Draft

fix(acp): scope MCP servers by session#40979
vanzue wants to merge 4 commits into
anomalyco:devfrom
vanzue:acp-mcp-isolation

Conversation

@vanzue

@vanzue vanzue commented Aug 7, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40978

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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)
  • Affected server/session tests (45 passed, 14 pre-existing skips)
  • bun typecheck from packages/opencode
  • bun typecheck from packages/sdk/js
  • Live opencode acp process 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 endpoint

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ed7b8fd5-dea4-4d5f-931c-77223bdcb408
@vanzue
vanzue marked this pull request as draft August 7, 2026 03:07
vanzue and others added 3 commits August 7, 2026 11:08
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
@vanzue vanzue changed the title fix(acp): isolate session MCP tools fix(acp): scope MCP servers by session Aug 7, 2026
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 sessions can access MCP tools supplied by other sessions

1 participant