Skip to content

fix(mcp): derive a real name from hosts with a multi-part suffix#43

Merged
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/derive-name-multipart-suffix
Jul 26, 2026
Merged

fix(mcp): derive a real name from hosts with a multi-part suffix#43
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/derive-name-multipart-suffix

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

Bug

moshcode mcp install <url> derives the server name from the URL host when no --name is given (src/integrations.mjs:72). deriveName drops only the last label as the TLD, so on a host with a multi-part suffix the generic co/com label survives and wins:

URL name before expected
https://mcp.acme.co.uk/sse co acme
https://api.example.com.au/mcp com example
https://widgets.co.za/mcp co widgets

Impact

The name is what gets registered with every engine, so two unrelated servers collide:

mcp install https://mcp.acme.co.uk/sse     -> mcp add -s user -t http co https://mcp.acme.co.uk/sse
mcp install https://mcp.widgets.co.za/sse  -> mcp add -s user -t http co https://mcp.widgets.co.za/sse

The second silently overwrites the first in each engine's MCP config, and neither is findable under a useful name.

Fix

src/mcp.mjs only. 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:

  • single-label TLDs, so mcp.example.co (the .co TLD) still yields example
  • a bare suffix host like co.uk, which has no name to offer and keeps its co fallback
  • mcp.sentry.dev, api.githubcopilot.com, localhost:3000, and non-URL input

Tests

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 via git stash push -- src/ that both fail without the fix and pass with it. Full suite: node --test 153 pass / 0 fail (main is 151).

`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.
@ralyodio
ralyodio merged commit 171f7bd into moshcoder:main Jul 26, 2026
3 checks passed
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.

2 participants