Skip to content

fix: preserve MCP tool names#2402

Open
LittleChenLiya wants to merge 4 commits into
bytedance:mainfrom
LittleChenLiya:fix-mcp-tool-prefix-alias
Open

fix: preserve MCP tool names#2402
LittleChenLiya wants to merge 4 commits into
bytedance:mainfrom
LittleChenLiya:fix-mcp-tool-prefix-alias

Conversation

@LittleChenLiya
Copy link
Copy Markdown
Collaborator

@LittleChenLiya LittleChenLiya commented Apr 21, 2026

问题原因

DeerFlow 初始化 MCP client 时启用了 server name 前缀,导致外部 MCP 工具名从 click_elementinput_text 变成 server_click_elementserver_input_text。依赖原始工具名的 skill 会认为工具不可用。

修改内容

  • 调整 MCP client 初始化逻辑,在避免多 server 工具名冲突的前提下保留可用的外部工具名。
  • 补充回归断言,覆盖 MCP client 初始化参数和工具名暴露行为。

测试

  • 后端:uvx ruff check .uvx ruff format --check . 通过。
  • 后端聚焦回归:uv run python -m pytest tests/test_mcp_sync_wrapper.py -v 通过。
  • Windows 本地全量 pytest 仍受符号链接/路径相关已知失败影响。

关联 issue

fix #2399


Problem Cause

DeerFlow enabled the server name prefix when initializing the MCP client, changing external MCP tool names from click_element and input_text to server_click_element and server_input_text. Skills that depend on the original tool names would treat those tools as unavailable.

Changes

  • Adjusted MCP client initialization to preserve usable external tool names while still avoiding tool-name conflicts across multiple servers.
  • Added regression assertions covering MCP client initialization parameters and exposed tool names.

Tests

  • Backend: uvx ruff check . and uvx ruff format --check . passed.
  • Focused backend regression: uv run python -m pytest tests/test_mcp_sync_wrapper.py -v passed.
  • Full local Windows pytest is still affected by known symlink/path-related failures.

Related Issue

Fixes #2399

@LittleChenLiya LittleChenLiya marked this pull request as ready for review April 21, 2026 14:47
@WillemJiang WillemJiang requested a review from Copilot April 22, 2026 03:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts MCP tool loading so DeerFlow preserves the original external MCP tool names (e.g., click_element, input_text) rather than prefixing them with the MCP server name, aligning DeerFlow’s exposed tool names with other MCP clients and fixing skills that expect the unprefixed names.

Changes:

  • Disable tool_name_prefix when constructing MultiServerMCPClient so MCP tools keep their original names.
  • Add a regression assertion ensuring MCP client initialization is performed with tool_name_prefix=False.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
backend/packages/harness/deerflow/mcp/tools.py Stops prefixing MCP tool names by passing tool_name_prefix=False to MultiServerMCPClient.
backend/tests/test_mcp_sync_wrapper.py Adds an assertion to lock in the expected MCP client initialization behavior.

Comment thread backend/packages/harness/deerflow/mcp/tools.py Outdated
@LittleChenLiya LittleChenLiya force-pushed the fix-mcp-tool-prefix-alias branch from 1dfa764 to 9755536 Compare May 24, 2026 05:17
@LittleChenLiya
Copy link
Copy Markdown
Collaborator Author

已重新基于最新 main 收窄并解决冲突。

这次保留了主线新增的 persistent MCP session、OAuth/custom interceptor 逻辑,内部仍使用 tool_name_prefix=True 来定位 server;对外暴露工具名时只在原始名称无冲突的情况下去掉 server 前缀,如果多个 server 暴露同名工具则继续保留前缀避免碰撞。

验证:

  • uv run python -m pytest tests/test_mcp_sync_wrapper.py -v
  • uvx ruff check packages/harness/deerflow/mcp/tools.py tests/test_mcp_sync_wrapper.py
  • uvx ruff format --check packages/harness/deerflow/mcp/tools.py tests/test_mcp_sync_wrapper.py

@LittleChenLiya LittleChenLiya requested a review from Copilot May 26, 2026 02:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread backend/tests/test_mcp_sync_wrapper.py Outdated
Comment thread backend/packages/harness/deerflow/mcp/tools.py
Comment thread backend/packages/harness/deerflow/mcp/tools.py Outdated
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.

配置的MCP服务调用不到

2 participants