fix(publisher): honor mcpName as the authoritative server name in init#1195
Merged
fix(publisher): honor mcpName as the authoritative server name in init#1195
Conversation
When `mcpName` is set in `package.json`, it should be the server name used by `mcp-publisher init`. Two issues addressed: 1. `getNameFromPackageJSON` was running `mcpName` through the npm-name transformation intended for the `name` field, producing a broken double-prefix result like "io.github.<your-username>/io.github.foo/bar". 2. `detectServerName` consulted the git remote before package.json, so a github.com remote or `repository` field silently overrode `mcpName`. Both now return `mcpName` as-is when set. The npm-name transformation is preserved for the `name`-only fallback path. Follow-up to #1145, completes the fix for #737. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4549c97 to
d87216a
Compare
tadasant
approved these changes
Apr 25, 2026
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.
Summary
Follow-up to #1145. When
mcpNameis set inpackage.json, it should be the server name used bymcp-publisher init. Two issues addressed:1.
getNameFromPackageJSONmangledmcpNamethrough npm-name transformationmcpNamevalues are already in MCP server name format (e.g.io.github.foo/bar). The existing code ran them through the@scope/name → io.github.scope/nametransform and itsio.github.<your-username>/*fallback, producing a broken double-prefix result.Example with
"mcpName": "io.github.acme/weather":io.github.<your-username>/io.github.acme/weather❌io.github.acme/weather✅2.
detectServerNameconsulted git beforemcpNameEven with
mcpNameset inpackage.json, a github.com git remote (or arepositoryfield) silently won — the function returnedio.github.<owner>/<repo>and never looked atmcpName. Per the quickstart docs, "The value ofmcpNamewill be your server's name in the MCP Registry", somcpNameshould take precedence.Changes
cmd/publisher/commands/init.go:getMcpNameFromPackageJSON()helper that returnsmcpNameor"".detectServerNamechecksmcpNamefirst, before git remote and thename-based fallback.getNameFromPackageJSONsimplified — the now-redundantmcpNamebranch was removed; it only handles the npmnametransformation.cmd/publisher/commands/init_test.go(new): 5 cases through the publicInitCommandAPI coveringmcpNameas-is, fallback to scopedname, fallback to placeholder, version fallback, andmcpNamewinning over a GitHubrepositoryURL.This completes the fix for #737.
Test plan
go test ./cmd/publisher/commands/passes (5 new subtests)golangci-lint run ./cmd/publisher/commands/cleanmcp-publisher initin a git-tracked directory withpackage.jsoncontainingmcpNameproduces aserver.jsonwhosenamematchesmcpName, not the repo slug🤖 Generated with Claude Code