fix: report package version in MCP serverInfo instead of hardcoded 1.0.0#322
Open
jakerated-r wants to merge 1 commit into
Open
fix: report package version in MCP serverInfo instead of hardcoded 1.0.0#322jakerated-r wants to merge 1 commit into
jakerated-r wants to merge 1 commit into
Conversation
MCPProxy constructed the MCP Server with a hardcoded version of '1.0.0', so every client saw serverInfo.version = 1.0.0 regardless of the actual published version (currently 2.4.0). Resolve the version from the nearest package.json via a small helper that works from source (tsx/vitest), the compiled build/ output, and when installed under node_modules. Fixes makenotion#310
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.
What & why
MCPProxyconstructed the MCPServerwith a hardcodedversion: '1.0.0', so every connecting client receivedserverInfo.version = "1.0.0"no matter the actual published version (currently2.4.0). This is misleading for clients that surface or gate on the server version.Fixes #310.
The fix
New
src/version.tsexportsgetPackageVersion(), which resolves the version from the nearestpackage.jsonby walking up fromimport.meta.url. This is robust in every runtime the package runs in:tsx/vitest(src/...)build/output (which nests one level deeper than source)node_modules/@notionhq/notion-mcp-server/...A depth-independent walk avoids the source-vs-build relative-path mismatch a fixed
../package.jsonimport would hit, and a bare ESMimport pkg from './package.json'would need a runtime import attribute. The result is cached.proxy.tsnow passesgetPackageVersion()instead of the literal'1.0.0'. One line changed; constructor signature untouched, so all existing call sites are unaffected.Verification
npm test→ 106 passed (12 files), including a new test assertingserverInfo.versionequals the package version and is no longer1.0.0.tsc --noEmit -p tsconfig.json→ clean.If
package.jsonsomehow can't be resolved, the helper falls back to'0.0.0'(still distinguishable from a real release) rather than throwing.