Skip to content

fix(memory): read version dynamically from package.json (Fixes #4406)#4427

Open
TomrroW007 wants to merge 1 commit into
modelcontextprotocol:mainfrom
TomrroW007:fix-4406-memory-version
Open

fix(memory): read version dynamically from package.json (Fixes #4406)#4427
TomrroW007 wants to merge 1 commit into
modelcontextprotocol:mainfrom
TomrroW007:fix-4406-memory-version

Conversation

@TomrroW007

Copy link
Copy Markdown

Description

This pull request updates the @modelcontextprotocol/server-memory server to dynamically read its version from package.json instead of using a hardcoded string ("0.6.3").

Improvements:

  • Uses fs.readFileSync combined with robust path resolution to read the package version at runtime.
  • Ensures package.json path resolution works correctly across both pre-compiled (.ts via Vitest) and post-compiled (.js in dist/) execution contexts without triggering TypeScript Node16 import assertion errors.

Server Details

  • Server: memory
  • Changes to: src/memory/index.ts (McpServer initialization)

Motivation and Context

Fixes #4406.

Previously, serverInfo.version in 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-memory
npm run test --workspace=@modelcontextprotocol/server-memory
All unit tests successfully passed using the new runtime path logic.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

The package.json file is read using a synchronous fs.readFileSync at the top level instead of import packageJson from "./package.json" assert { type: "json" }. This maintains compatibility with the repository's Node16 module resolution configuration (which restricts modern import assertions/attributes) while remaining 100% robust.

Copilot AI review requested due to automatic review settings June 28, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

serverInfo.version hardcoded as "0.6.3" in @modelcontextprotocol/server-memory@2026.1.26

2 participants