Skip to content

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

Merged
snimu merged 7 commits into
mainfrom
fix/acp-mcp-tools-as-native-tools
Sep 3, 2026
Merged

snimu merged 7 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 and runtime rebuild paths for ACP sessions and hard-requires cpython when ACP MCP servers are present; incorrect cleanup or naming could break verifier/ACP integrations.

Overview
ACP-supplied MCP servers from ACP clients are no longer described only in the system prompt as generic mcp.list_tools / mcp.call_tool usage. Each server now gets two native agent toolsmcp_list_tools_{server} and mcp_call_{server}—that run MCP through the session’s cpython kernel.

acp-mcp.ts builds those definitions: validates server names, maps list/call to kernel Python, and surfaces kernel failures as tool errors. agent-session keeps ACP tools in _acpMcpTools, merges them into the tool registry on replace/rebuild, strips them on release, and requires the built-in cpython provisioner; it also rejects name collisions with base, custom, or extension tools.

McpManager splits listing: getAcpServers() for session-scoped ACP configs vs getEnabledPersistentGenericServers() for user-declared servers still documented in the generic MCP section of the prompt. Tests cover argument JSON encoding, release/reload behavior, and the cpython requirement.

Reviewed by Cursor Bugbot for commit 2c006d4. 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

  • Each ACP MCP server now exposes two native tools: a zero-arg list-tools tool and a call-tool that accepts a tool name and JSON arguments, both executed through the built-in cpython kernel (acp-mcp.ts)
  • AgentSession manages the ACP tool lifecycle — building, validating, rebuilding on reload, and removing on release — and rejects ACP servers when the cpython kernel is missing or a generated tool name collides with an existing tool (agent-session.ts)
  • McpManager now separates ACP server configs from persistent user-declared generic servers via getAcpServers and getEnabledPersistentGenericServers, so the system prompt no longer lists ACP servers as generic MCP servers (mcp-manager.ts)
  • Behavioral Change: getEnabledGenericServers is renamed to getEnabledPersistentGenericServers and no longer returns ACP servers; callers must use getAcpServers instead

Macroscope summarized 2c006d4.

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
@snimu
snimu merged commit 7f21fa3 into main Sep 3, 2026
23 checks passed
@snimu
snimu deleted the fix/acp-mcp-tools-as-native-tools branch September 3, 2026 09:35
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.

2 participants