Skip to content

fix(publisher): honor mcpName as the authoritative server name in init#1195

Merged
rdimitrov merged 2 commits intomainfrom
fix/init-mcpname-no-transform
Apr 25, 2026
Merged

fix(publisher): honor mcpName as the authoritative server name in init#1195
rdimitrov merged 2 commits intomainfrom
fix/init-mcpname-no-transform

Conversation

@rdimitrov
Copy link
Copy Markdown
Member

@rdimitrov rdimitrov commented Apr 24, 2026

Summary

Follow-up to #1145. When mcpName is set in package.json, it should be the server name used by mcp-publisher init. Two issues addressed:

1. getNameFromPackageJSON mangled mcpName through npm-name transformation

mcpName values 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/name transform and its io.github.<your-username>/* fallback, producing a broken double-prefix result.

Example with "mcpName": "io.github.acme/weather":

  • Before: io.github.<your-username>/io.github.acme/weather
  • After: io.github.acme/weather

2. detectServerName consulted git before mcpName

Even with mcpName set in package.json, a github.com git remote (or a repository field) silently won — the function returned io.github.<owner>/<repo> and never looked at mcpName. Per the quickstart docs, "The value of mcpName will be your server's name in the MCP Registry", so mcpName should take precedence.

Changes

  • cmd/publisher/commands/init.go:
    • New getMcpNameFromPackageJSON() helper that returns mcpName or "".
    • detectServerName checks mcpName first, before git remote and the name-based fallback.
    • getNameFromPackageJSON simplified — the now-redundant mcpName branch was removed; it only handles the npm name transformation.
  • cmd/publisher/commands/init_test.go (new): 5 cases through the public InitCommand API covering mcpName as-is, fallback to scoped name, fallback to placeholder, version fallback, and mcpName winning over a GitHub repository URL.

This completes the fix for #737.

Test plan

  • go test ./cmd/publisher/commands/ passes (5 new subtests)
  • golangci-lint run ./cmd/publisher/commands/ clean
  • Manual: mcp-publisher init in a git-tracked directory with package.json containing mcpName produces a server.json whose name matches mcpName, not the repo slug

🤖 Generated with Claude Code

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>
@rdimitrov rdimitrov force-pushed the fix/init-mcpname-no-transform branch from 4549c97 to d87216a Compare April 24, 2026 09:51
@rdimitrov rdimitrov changed the title fix(publisher): return mcpName as-is from package.json in init fix(publisher): honor mcpName as the authoritative server name in init Apr 24, 2026
@rdimitrov rdimitrov enabled auto-merge (squash) April 24, 2026 10:01
@rdimitrov rdimitrov merged commit aaa634e into main Apr 25, 2026
5 checks passed
@rdimitrov rdimitrov deleted the fix/init-mcpname-no-transform branch April 25, 2026 14:14
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