fix(memory): read version dynamically from package.json (Fixes #4406)#4427
Open
TomrroW007 wants to merge 1 commit into
Open
fix(memory): read version dynamically from package.json (Fixes #4406)#4427TomrroW007 wants to merge 1 commit into
TomrroW007 wants to merge 1 commit into
Conversation
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.
Description
This pull request updates the
@modelcontextprotocol/server-memoryserver to dynamically read its version frompackage.jsoninstead of using a hardcoded string ("0.6.3").Improvements:
fs.readFileSynccombined with robust path resolution to read the package version at runtime.package.jsonpath resolution works correctly across both pre-compiled (.tsvia Vitest) and post-compiled (.jsindist/) execution contexts without triggering TypeScriptNode16import assertion errors.Server Details
src/memory/index.ts(McpServer initialization)Motivation and Context
Fixes #4406.
Previously,
serverInfo.versionin the memory server was hardcoded to"0.6.3". When new versions were published, the server instance would still report"0.6.3", leading to mismatched version semantics. This PR ensures the reported server version dynamically stays in sync with the package version.How Has This Been Tested?
Tested locally by building the workspace and running the existing memory server tests via Vitest:
npm run build --workspace=@modelcontextprotocol/server-memorynpm run test --workspace=@modelcontextprotocol/server-memoryAll unit tests successfully passed using the new runtime path logic.
Breaking Changes
None.
Types of changes
Checklist
Additional context
The
package.jsonfile is read using a synchronousfs.readFileSyncat the top level instead ofimport packageJson from "./package.json" assert { type: "json" }. This maintains compatibility with the repository'sNode16module resolution configuration (which restricts modern import assertions/attributes) while remaining 100% robust.