Skip to content

[Feature] Honor client-supplied mcpServers in ACP sessions, with a per-session tool registry #1889

Description

@addyCooks

Description

Nanocoder's ACP agent ignores the mcpServers list that clients send on session/new, session/load and session/resume. MCP servers come only from the user's own config, and they are loaded once per process into one ToolManager shared by every session.

I'd like Nanocoder to:

  1. Read and use mcpServers from the client on those three requests.
  2. Give each ACP session its own tool set, so tools from client-supplied servers exist only in the session that supplied them.

Background: Nano-Collective/docs#116. Tracked from Nano-Collective/nanocoder-desktop#12 (item 2).

Status: docs#116 proposed two routes (write the browser server into the user's MCP config, or honor client-supplied mcpServers). The second was suggested in the thread but has not yet been confirmed by a maintainer, so this issue is also a request for that confirmation.

Use Case

Nanocoder Desktop wants to give the agent a browser-control tool (navigate, snapshot, click, type) that talks to the desktop's in-app browser. That tool should exist only in desktop sessions. Today there is no supported way to add it:

  • Writing a server into the user's MCP config conflicts with "Nanocoder owns its configuration" and leaves the server active outside the desktop.
  • Honoring mcpServers from the ACP client keeps the tool scoped to desktop sessions and never touches the user's .mcp.json.

The ACP spec already expects clients to be able to pass MCP servers, so any ACP client (editor extensions, other desktop apps) benefits too. The desktop needs this before its Milestone 3.

Proposed Solution

  1. Accept mcpServers on session/new, session/load and session/resume and map each entry to Nanocoder's MCPServer type. On load and resume, the client's list replaces the session's previous set.
  2. Per-session tool registry. Each session sees the built-in tools and the user-config MCP servers (shared), plus the servers from its own mcpServers (private). Both tool selection and tool execution use the session's view.
  3. Lifecycle. Connect the session's servers on new/load/resume. Disconnect them on session/close, when the same session ID is registered again, and on process shutdown. A server that fails to connect is logged and skipped, and the request still succeeds, as with startup MCP failures today.
  4. Capabilities. Advertise agentCapabilities.mcpCapabilities only for the transports actually supported.

Alternatives Considered

  • Write the browser server into the user's MCP config. Rejected in docs#116: it conflicts with Nanocoder owning its configuration and leaves the server active outside the desktop.
  • Re-run ToolManager.initializeMCP() for each session. This does not work, because it starts with disconnectMCP() and would tear down the connections other sessions are using.
  • Unstable MCP-over-ACP transport (type: "acp"). Out of scope for this issue.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • This feature aligns with the project's goals (local-first AI assistance)

(I searched issues and PRs for mcpServers and ACP and found nothing matching. Tick both boxes when posting.)

Current behavior, checked against main at fc01e23:

  • source/acp/acp-agent.ts: newSession (L136), loadSession (L167) and resumeSession (L674) never read params.mcpServers. registerSession (L870) creates an AcpSession with no tool state.
  • source/acp/acp-types.ts: AcpInitContext holds a single toolManager shared by all sessions. It is used by acp-agent.ts (L408-409, L1043-1077), acp-conversation.ts (tool selection ~L305-309, execution ~L570 and ~L654) and the subagent executor.
  • source/plain/initialize.ts (L181-198): MCP servers are initialized once at startup from the resolved config.
  • source/tools/tool-manager.ts: initializeMCP() calls disconnectMCP() first and registers a shutdown handler on every call.
  • source/acp/acp-capabilities.ts: getAgentCapabilities() advertises no mcpCapabilities.
  • closeSession (L514) has no MCP teardown, since sessions own no MCP connections today.
  • The existing ACP specs only pass mcpServers: [], so nothing covers this today.

Implementation Notes (optional)

puri-adityakumar offered on docs#116 to build this on a separate branch, test it early with the desktop, and open a PR once it works, well ahead of the desktop's browser milestone. I'm happy to implement it or to help with that work. Either way I'll coordinate there first and post a spec in the comments before starting, as CONTRIBUTING suggests.

Mapping. Per the ACP schema (to verify against the SDK version pinned in package.json), stdio entries have name, command, args and env as {name, value} pairs. http entries have type: "http", name, url and headers as {name, value} pairs. Nanocoder's MCPServerConfig uses Record<string,string> for env and headers, so the pairs need converting. Nanocoder has no SSE transport, so either skip SSE entries with a warning or leave them out of the advertised capabilities.

Open design questions for maintainers:

  1. Where does the per-session registry live?
    (a) Make ToolManager instantiable per session, cloning the shared base registry and adding the session's MCP client.
    (b) Keep one ToolManager and add a session-scoped overlay that tool lookup and execution consult first.
    Option (b) is probably a smaller diff, but it touches more call sites.
  2. Shared or isolated connections when two sessions pass an identical server? Isolation is simpler, sharing is cheaper.
  3. Name collisions with user-config servers or built-in tools. Suggested default: the existing entry wins and the client entry is skipped with a warning.
  4. Approval policy. New ACP sessions start in auto-accept. Should client-supplied MCP tools follow the normal approval and alwaysAllow rules, or be treated as pre-approved by the client?
  5. Security validation. Config servers go through validateProjectConfigSecurity. Should client-supplied servers get a similar check, or is the client already trusted because it launched the agent?

Acceptance criteria:

  • session/new, session/load and session/resume read mcpServers and connect the servers.
  • Tools from a client's servers are visible and executable in that session only.
  • Two sessions with different server sets run concurrently without affecting each other.
  • session/close disconnects that session's servers and leaves other sessions' servers connected.
  • Re-sending session/load or session/resume for a live session replaces its server set without leaking connections.
  • A client server that fails to connect is logged and skipped, and the request still succeeds.
  • The user's MCP config files are never read or modified by this feature.
  • Behavior is unchanged when mcpServers is empty or missing.
  • mcpCapabilities matches what is implemented.
  • Subagents started from a session use that session's tools.

Test plan:

  • Unit tests for the ACP-to-MCPServer mapping (stdio, http, unsupported sse, empty list).
  • Unit tests for session-scoped lookup and execution, name collisions, and cleanup on close.
  • Integration test with two sessions and a small stdio MCP fixture server: isolation, close, resume.
  • Regression test: a session with no mcpServers behaves as before.

Out of scope: MCP-over-ACP transport, disabling the built-in browser tool per session (nanocoder-desktop#12 item 4), and changes to how users configure MCP servers.

Activity

  1. added
    enhancement
    help wanted
    architecture
    proposal
    area:mcp
    on Oct 26, 2026
  2. added
    area:agent
    on Oct 26, 2026
  3. self-assigned this
    on Oct 26, 2026
  4. added
    needs-triage
    and removed
    needs-triage
    on Oct 26, 2026
  5. added a commit that references this issue on Oct 29, 2026
    5b0fbf6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

architecturearea:agentarea:mcpenhancementhelp wantedproposal

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions