Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 26, 2026

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 in src/utils/mcp-name.ts used 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:

  • Modified split regex in normalizeMcpToolName() to preserve ___
  • Added comprehensive tests for triple underscore tool names
  • Added full flow test for MCP aggregator scenario

Test Procedure

  1. Run the unit tests: cd src && npx vitest run utils/__tests__/mcp-name.spec.ts
  2. All 66 tests pass, including the new tests specifically for Issue [BUG] MCP tool names with triple underscores (___) are incorrectly converted to hyphens (-) #10858:
    • should preserve triple underscores in tool names (MCP aggregator format)
    • should preserve triple underscores when model converts separators
    • should handle MCP aggregator tool names with triple underscores (Issue #10858)

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on the linked issue
  • Self-Review: Code has been self-reviewed
  • Testing: New tests have been added to cover the changes
  • Documentation Impact: No documentation updates required
  • Contribution Guidelines: Followed contributor guidelines

Screenshots / Videos

N/A - This is a backend logic fix with no UI changes.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome!

Get in Touch

Roomote Bot

This fix addresses 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.

The issue was in normalizeMcpToolName() which used the regex /__|--/ to
split tool names. This regex matched double underscores anywhere, including
within triple underscore sequences.

The fix changes the regex to /(?<!_)__(?!_)|--/ which uses negative
lookbehind/lookahead to match exactly two underscores that are not part
of a longer underscore sequence.

Changes:
- Modified split regex in normalizeMcpToolName() to preserve ___
- Added comprehensive tests for triple underscore tool names
- Added full flow test for MCP aggregator scenario
@roomote
Copy link
Contributor Author

roomote bot commented Jan 26, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The regex change from /__|--/ to /(?<!_)__(?!_)|--/ correctly preserves triple underscores in MCP aggregator tool names while still splitting on double underscores. The implementation is well-tested with comprehensive coverage for edge cases including quadruple underscores and multiple triple underscore segments.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] MCP tool names with triple underscores (___) are incorrectly converted to hyphens (-)

2 participants