Skip to content

fix(mcp): prefix mcp tool names with server name to avoid collisions#2282

Open
salmandeniz wants to merge 2 commits into
MoonshotAI:mainfrom
salmandeniz:fix/mcp-tool-name-collision
Open

fix(mcp): prefix mcp tool names with server name to avoid collisions#2282
salmandeniz wants to merge 2 commits into
MoonshotAI:mainfrom
salmandeniz:fix/mcp-tool-name-collision

Conversation

@salmandeniz
Copy link
Copy Markdown

@salmandeniz salmandeniz commented May 14, 2026

Multiple MCP servers exposing tools with the same name (e.g., 'query' from multiple postgres servers) overwrite each other in _tool_dict.\n\nPrefix tool names with the server name so each tool remains unique and accessible.


Open in Devin Review

Multiple MCP servers exposing tools with the same name (e.g., 'query'
from multiple postgres servers) overwrite each other in _tool_dict.
Prefix tool names with the server name so each tool remains unique
and accessible.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MCP tool approval action_name not namespaced by server, causing cross-server auto-approval

The PR prefixes tool names with server_name to avoid collisions (f"{server_name}_{mcp_tool.name}"), but _action_name at line 715 is still f"mcp:{mcp_tool.name}" without the server prefix. When two MCP servers expose a tool with the same name (e.g. read_file), both MCPTool instances share the same _action_name = "mcp:read_file". If the user selects "approve for session" for one server's tool, the action is added to auto_approve_actions (src/kimi_cli/soul/approval.py:248), which then auto-approves the identically-named tool from the other server (src/kimi_cli/soul/approval.py:195). Additionally, all pending approvals with the same action are batch-resolved (src/kimi_cli/soul/approval.py:250-252). Before this PR, this couldn't happen because only one tool with a given name existed in _tool_dict (the second overwrote the first). Now that both tools coexist with distinct names, the shared _action_name creates an unintended cross-server approval bypass.

(Refers to line 715)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

…erver auto-approval

When multiple MCP servers expose tools with the same name (e.g. read_file),
the shared _action_name = 'mcp:read_file' caused auto-approval on one server
to bypass approval on another. Prefix _action_name with the server-scoped
tool name so each server's tool has a distinct approval identity.
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