Skip to content

feat(publisher): copy version from package.json and prefer mcpName in init#1145

Open
JosephDoUrden wants to merge 1 commit intomodelcontextprotocol:mainfrom
JosephDoUrden:fix/init-copy-version-and-mcpname
Open

feat(publisher): copy version from package.json and prefer mcpName in init#1145
JosephDoUrden wants to merge 1 commit intomodelcontextprotocol:mainfrom
JosephDoUrden:fix/init-copy-version-and-mcpname

Conversation

@JosephDoUrden
Copy link
Copy Markdown

Summary

Addresses two related enhancements to mcp-publisher init:

  • Copy version from package.json (Make mcp-publisher init copy version from package.json #736): When package.json is present and contains a version field, it is now used for both the top-level version and packages[].version in the generated server.json. Falls back to "1.0.0" when unavailable. This aligns with the recommended best practice of keeping server version in sync with package version.

  • Prefer mcpName over name (mcp-publisher init should prefer mcpName from package.json #737): The init command now checks for mcpName in package.json first, falling back to name if mcpName is not defined. This ensures the generated server name matches the required mcpName property.

Closes #736
Closes #737

Changes

  • cmd/publisher/commands/init.go:
    • Added getVersionFromPackageJSON() helper to read version from package.json
    • Modified InitCommand() to use detected version with "1.0.0" fallback
    • Modified getNameFromPackageJSON() to prefer mcpName over name

Test plan

  • go build ./cmd/publisher/... compiles without errors
  • go test ./cmd/publisher/commands/... passes all existing tests
  • Manual: run mcp-publisher init in a directory with package.json containing version and mcpName — verify both are copied to server.json
  • Manual: run mcp-publisher init in a directory with package.json without mcpName — verify name is used as fallback
  • Manual: run mcp-publisher init in a directory without package.json — verify defaults ("1.0.0", directory name) are used

AI Disclosure

AI assistance (Claude) was used for initial code exploration and issue research. The implementation was written and reviewed by the author.

… init

- Copy `version` from package.json to both top-level and package version
  fields, falling back to "1.0.0" when unavailable (modelcontextprotocol#736)
- Prefer `mcpName` over `name` from package.json when detecting server
  name, as the server name must match mcpName (modelcontextprotocol#737)
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.

mcp-publisher init should prefer mcpName from package.json Make mcp-publisher init copy version from package.json

1 participant