fix: preserve triple underscores in MCP tool names #10967
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #10858
Roo Code Task Context (Optional)
This PR was created by Roomote in response to the approved implementation plan.
Description
This PR attempts to address Issue #10858 where MCP aggregators (like 1mcp) use triple underscores (
___) in tool names (e.g.,playwright___browser_navigate) but Roo Code was incorrectly converting them to hyphens.Root Cause:
The
normalizeMcpToolName()function insrc/utils/mcp-name.tsused the regex/__|--/to split tool names. This regex matched double underscores anywhere, including within triple underscore sequences.Solution:
Changed the regex to
/(?<!_)__(?!_)|--/which uses negative lookbehind/lookahead to match exactly two underscores that are NOT part of a longer underscore sequence. This preserves triple underscores while still correctly identifying MCP tool separators.Key changes:
normalizeMcpToolName()to preserve___Test Procedure
cd src && npx vitest run utils/__tests__/mcp-name.spec.tsshould preserve triple underscores in tool names (MCP aggregator format)should preserve triple underscores when model converts separatorsshould handle MCP aggregator tool names with triple underscores (Issue #10858)Pre-Submission Checklist
Screenshots / Videos
N/A - This is a backend logic fix with no UI changes.
Documentation Updates
Additional Notes
Feedback and guidance are welcome!
Get in Touch
Roomote Bot