feat(publisher): copy version from package.json and prefer mcpName in init#1145
Open
JosephDoUrden wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Conversation
… 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)
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
Addresses two related enhancements to
mcp-publisher init:Copy
versionfrompackage.json(Makemcp-publisher initcopyversionfrompackage.json#736): Whenpackage.jsonis present and contains aversionfield, it is now used for both the top-levelversionandpackages[].versionin the generatedserver.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
mcpNameovername(mcp-publisher initshould prefermcpNamefrompackage.json#737): The init command now checks formcpNameinpackage.jsonfirst, falling back tonameifmcpNameis not defined. This ensures the generated server name matches the requiredmcpNameproperty.Closes #736
Closes #737
Changes
cmd/publisher/commands/init.go:getVersionFromPackageJSON()helper to read version frompackage.jsonInitCommand()to use detected version with"1.0.0"fallbackgetNameFromPackageJSON()to prefermcpNameovernameTest plan
go build ./cmd/publisher/...compiles without errorsgo test ./cmd/publisher/commands/...passes all existing testsmcp-publisher initin a directory withpackage.jsoncontainingversionandmcpName— verify both are copied toserver.jsonmcp-publisher initin a directory withpackage.jsonwithoutmcpName— verifynameis used as fallbackmcp-publisher initin a directory withoutpackage.json— verify defaults ("1.0.0", directory name) are usedAI Disclosure
AI assistance (Claude) was used for initial code exploration and issue research. The implementation was written and reviewed by the author.