Skip to content

fix: report package version in MCP serverInfo instead of hardcoded 1.0.0#322

Open
jakerated-r wants to merge 1 commit into
makenotion:mainfrom
jakerated-r:fix/serverinfo-version-from-package
Open

fix: report package version in MCP serverInfo instead of hardcoded 1.0.0#322
jakerated-r wants to merge 1 commit into
makenotion:mainfrom
jakerated-r:fix/serverinfo-version-from-package

Conversation

@jakerated-r

Copy link
Copy Markdown

What & why

MCPProxy constructed the MCP Server with a hardcoded version: '1.0.0', so every connecting client received serverInfo.version = "1.0.0" no matter the actual published version (currently 2.4.0). This is misleading for clients that surface or gate on the server version.

Fixes #310.

The fix

  • New src/version.ts exports getPackageVersion(), which resolves the version from the nearest package.json by walking up from import.meta.url. This is robust in every runtime the package runs in:

    • source / tsx / vitest (src/...)
    • the compiled build/ output (which nests one level deeper than source)
    • installed under node_modules/@notionhq/notion-mcp-server/...

    A depth-independent walk avoids the source-vs-build relative-path mismatch a fixed ../package.json import would hit, and a bare ESM import pkg from './package.json' would need a runtime import attribute. The result is cached.

  • proxy.ts now passes getPackageVersion() instead of the literal '1.0.0'. One line changed; constructor signature untouched, so all existing call sites are unaffected.

Verification

  • npm test106 passed (12 files), including a new test asserting serverInfo.version equals the package version and is no longer 1.0.0.
  • tsc --noEmit -p tsconfig.json → clean.

If package.json somehow can't be resolved, the helper falls back to '0.0.0' (still distinguishable from a real release) rather than throwing.

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
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 serverInfo.version is hardcoded to 1.0.0 in package 2.2.1

1 participant