fix(mcp): derive a real name from hosts with a multi-part suffix#43
Merged
ralyodio merged 1 commit intoJul 26, 2026
Merged
Conversation
`deriveName` dropped only the final label before picking a name, so on a host like mcp.acme.co.uk the leftover "co" won. Every .co.uk / .com.au / .co.za server therefore registered as "co", and a second one silently overwrote the first in each engine's MCP config. Also drop the generic label of a multi-part suffix when a real name still precedes it, leaving single-label TLDs and bare suffix hosts untouched.
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.
Bug
moshcode mcp install <url>derives the server name from the URL host when no--nameis given (src/integrations.mjs:72).deriveNamedrops only the last label as the TLD, so on a host with a multi-part suffix the genericco/comlabel survives and wins:https://mcp.acme.co.uk/ssecoacmehttps://api.example.com.au/mcpcomexamplehttps://widgets.co.za/mcpcowidgetsImpact
The name is what gets registered with every engine, so two unrelated servers collide:
The second silently overwrites the first in each engine's MCP config, and neither is findable under a useful name.
Fix
src/mcp.mjsonly. After dropping the TLD, also drop a generic second-level label (co,com,net,org,gov,edu,ac) when a real label still precedes it. Deliberately unchanged:mcp.example.co(the .co TLD) still yieldsexampleco.uk, which has no name to offer and keeps itscofallbackmcp.sentry.dev,api.githubcopilot.com,localhost:3000, and non-URL inputTests
Two tests added to
test/mcp.test.mjs: the suffix cases above plus a collision check that two different multi-part-suffix hosts get different names. Verified viagit stash push -- src/that both fail without the fix and pass with it. Full suite:node --test153 pass / 0 fail (main is 151).