Skip to content

fix: register ACP MCP tools as native callable tools via cpython proxy - #2002

Open
sethkarten wants to merge 6 commits into
mainfrom
fix/acp-mcp-tools-as-native-tools
Open

fix: register ACP MCP tools as native callable tools via cpython proxy#2002
sethkarten wants to merge 6 commits into
mainfrom
fix/acp-mcp-tools-as-native-tools

Conversation

@sethkarten

@sethkarten sethkarten commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

No-Ticket: Evaluation-driven ACP compatibility fix; no Linear ticket was created.

Problem

When verifiers sends MCP tool servers through the ACP session/new(mcp_servers=...) protocol, prime-agent stores them correctly but only adds prose guidance to the system prompt. The model must infer the correct await mcp.call_tool(...) incantation — a reasoning step that often fails, causing fallback to website scraping via cpython.

Solution

Register native ToolDefinition entries for each ACP MCP server. The model sees typed, callable tool entries in its tool list. Execution routes through the IPython kernel via await mcp.call_tool(...) — consistent with prime-agent's cpython-first architecture.

Each server gets two tools:

  • mcp_list_tools_{server} — discover tool names and schemas
  • mcp_call_{server} — call a tool with JSON arguments

Changes

File Change
tools/acp-mcp.ts NEW — proxy ToolDefinitions that route through mcp.call_tool() in the kernel
tools/index.ts Export createAcpMcpToolDefinitions
agent-session.ts Wire tools into _rebuildRuntimeForAcpMcpServers
mcp-manager.ts Add getAcpServers() public getter

Note

Medium Risk
Changes tool registration, active tool sets, and system prompts for ACP sessions; incorrect teardown or naming could break MCP access or hide tools from the model, but behavior is covered by new regression tests.

Overview
ACP-supplied MCP servers are no longer only documented in the system prompt as generic mcp.list_tools / mcp.call_tool examples. Each ACP server now gets two first-class agent tools—mcp_list_tools_{server} and mcp_call_{server}—implemented in acp-mcp.ts and executed through the IPython kernel’s MCP API.

agent-session builds and registers these definitions when ACP servers are set or the runtime is rebuilt, adds them to the active tool set, and tears them out of the registry, allowed names, and prompt on releaseAcpMcpServers. Registration fails without the built-in cpython provisioner or if generated tool names collide with base, custom, or extension tools.

mcp-manager splits listing: getAcpServers() for session-scoped ACP configs and getEnabledPersistentGenericServers() for user-declared servers, so ACP servers are excluded from generic MCP prose in the system prompt while persistent servers still are.

Reviewed by Cursor Bugbot for commit 36de03e. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Register ACP MCP tools as native callable tools via cpython proxy

  • ACP MCP servers now expose two native agent tools per server (list-tools and call-tools) that execute MCP operations through the session's cpython IPython kernel instead of being treated as generic MCP servers.
  • acp-mcp.ts generates deterministic tool names, validates server names against an identifier pattern, rejects duplicates, and passes call arguments into the kernel as JSON-decoded Python data.
  • agent-session.ts tracks ACP tool definitions separately, validates tool-name conflicts against base/custom/extension tools, rebuilds the runtime and tool registry on ACP server changes, and cleans up names and definitions on release.
  • mcp-manager.ts splits ACP servers from persistent generic servers via getAcpServers and getEnabledPersistentGenericServers.
  • Behavioral Change: ACP MCP registration now requires the built-in cpython provisioner and rejects tool-name conflicts; the system prompt no longer emits generic MCP-server instructions for ACP-supplied servers.

Macroscope summarized 36de03e.

Comment thread packages/coding-agent/src/core/tools/acp-mcp.ts Outdated
Comment thread packages/coding-agent/src/core/tools/acp-mcp.ts Outdated
Comment thread packages/coding-agent/src/core/agent-session.ts Outdated
Comment thread packages/coding-agent/src/core/agent-session.ts Outdated
Comment thread packages/coding-agent/src/core/agent-session.ts Outdated
Comment thread packages/coding-agent/src/core/tools/acp-mcp.ts Outdated
Comment thread packages/coding-agent/src/core/agent-session.ts
Comment thread packages/coding-agent/src/core/tools/acp-mcp.ts Outdated
Comment thread packages/coding-agent/src/core/agent-session.ts
Comment thread packages/coding-agent/src/core/tools/acp-mcp.ts Outdated
Comment thread packages/coding-agent/src/core/tools/acp-mcp.ts Outdated
Comment thread packages/coding-agent/src/core/agent-session.ts

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 41985b9. Configure here.

Comment thread packages/coding-agent/src/core/mcp/mcp-manager.ts Outdated
Comment thread packages/coding-agent/src/core/mcp/mcp-manager.ts
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.

1 participant