registry/cmd/publisher
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Radoslav Dimitrov aaa634ebb6
fix(publisher): honor mcpName as the authoritative server name in init (#1195)
## 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](https://github.com/modelcontextprotocol/registry/blob/main/docs/modelcontextprotocol-io/quickstart.mdx),
*"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

- [x] `go test ./cmd/publisher/commands/` passes (5 new subtests)
- [x] `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](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 07:14:11 -07:00
..
auth fix: store tokens in ~/.config/mcp-publisher/ instead of cwd (#1166) 2026-04-15 03:23:07 -04:00
commands fix(publisher): honor mcpName as the authoritative server name in init (#1195) 2026-04-25 07:14:11 -07:00
main.go Publisher-managed "deleted" support (#893) 2026-02-27 09:00:07 -08:00
README.md Publisher-managed "deleted" support (#893) 2026-02-27 09:00:07 -08:00

MCP Publisher Tool - Development

CLI tool for publishing MCP servers to the registry.

These docs are for contributors. See the Publisher User Guide for end-user documentation.

Quick Development Setup

# Build the tool
make publisher

# Test locally 
make dev-compose  # Start local registry
./bin/mcp-publisher init
./bin/mcp-publisher login none --registry=http://localhost:8080
./bin/mcp-publisher publish --registry=http://localhost:8080

Architecture

Commands

  • init - Generate server.json templates with auto-detection
  • login - Handle authentication (github, dns, http, none)
  • publish - Validate and upload servers to registry
  • status - Update server lifecycle status (active, deprecated, deleted)
  • logout - Clear stored credentials

Authentication Providers

  • github - Interactive OAuth flow
  • github-oidc - CI/CD with GitHub Actions
  • dns - Domain verification via DNS TXT records
  • http - Domain verification via HTTPS endpoints
  • none - No auth (testing only)

Signing Providers

Optional: enables dns and http methods to sign out-of-process without direct access to the private key.

  • google-kms - Google KMS signing
  • azure-key-vault - Azure Key Vault signing

Key Files

  • main.go - CLI setup and command routing
  • commands/ - Command implementations with auto-detection logic
  • auth/ - Authentication provider implementations
  • build.sh - Cross-platform build script