Conversation
parseMcpToolWireName splits at the first '__' after the 'mcp__' prefix, but buildMcpToolWireName allowed server IDs containing '__' (directly or via sanitization, e.g. 'a..b' -> 'a__b') or ending in '_'. Such wire names parsed back to a different server/tool pair. Collapse underscore runs and trim edge underscores in the server segment, mirroring normalizeMcpName in tool/builtin/mcpTool.ts, so every built wire name parses back to a stable server/tool identity. Tool names keep '__' as before since parsing splits at the first separator only. Fixes OpenBMB#424
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
buildMcpToolWireNamenow normalizes the server segment so it can never contain__or edge underscores: underscore runs are collapsed and leading/trailing underscores trimmed, mirroringnormalizeMcpNameinsrc/tool/builtin/mcpTool.ts. Tool names keep__as before, since parsing splits at the first separator only.Why
parseMcpToolWireNamesplits at the first__after themcp__prefix, but the builder accepted server IDs containing__— directly, via sanitization (a..b→a__b), or ending in_. Such wire names parsed back to a different server/tool pair. Reproduced onmain:With this change every built wire name parses back to a stable server/tool identity, and wire names for ordinary server IDs (including single underscores) are unchanged.
How verified
tests/mcp/wire-name.spec.ts(6 cases: plain round-trip,__in server ID, trailing underscore, sanitization-induced__,__in tool name preserved, single underscore preserved) — all pass viatsx --test.tests/mcp/client/McpClient.spec.ts(3 cases) still passes.tsc --noEmit -p tsconfig.jsonpasses.Fixes #424