Skip to content

fix(mcp): read server version from package.json, rename to lens-mcp-server - #540

Merged
Miracle656 merged 1 commit into
Divinity-Labs:mainfrom
sparkysolutions10-pixel:fix/mcp-server-version-420
Oct 19, 2026
Merged

Miracle656 merged 1 commit into
Divinity-Labs:mainfrom
sparkysolutions10-pixel:fix/mcp-server-version-420

Conversation

@sparkysolutions10-pixel

Copy link
Copy Markdown
Contributor

Summary

Closes #420

The MCP server was advertising version: '1.0.0' (hard-coded) and name: 'bazaar-mcp-server' regardless of the actual package version or project name.

Changes

  • Read version from package.json at module load time using readFileSync + fileURLToPath (works for both ts-node / tsx and compiled dist/).
  • Exported two new constants: SERVER_VERSION (sourced from package.json) and SERVER_NAME ('lens-mcp-server').
  • Replaced the hard-coded literals in the Server constructor with those constants.

Client-affecting rename: bazaar-mcp-server → lens-mcp-server. Any MCP client that identified the server by name must be updated.

Tests

  • Added BazaarMcpServer — server identity describe block in tests/mcp.test.ts.
  • advertises the version from package.json — asserts SERVER_VERSION === pkg.version read fresh from the file system, proving it can never drift.
  • uses the canonical server name lens-mcp-server — guards the rename against accidental revert.
  • All 11 tests pass (npx vitest run tests/mcp.test.ts).

@Miracle656

Copy link
Copy Markdown
Collaborator

Merged. Real bug worth fixing: the server advertised version: '1.0.0' while the package sat at 0.2.0, so every MCP client was told something untrue about what it had connected to. And a hard-coded version string is guaranteed to drift — the only question is when.

Two fixes while merging.

1. It didn't compile. The version read used fileURLToPath(import.meta.url), and this project is module: commonjs, where that's a hard TypeScript error:

src/mcp/server.ts(16,45): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', ...

I ran tsc --noEmit on your branch on its own to be sure it wasn't something my merge introduced — it fails there too.

The interesting part: your own new test in this PR already used __dirname:

const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'))

So the source file was the odd one out. I switched it to __dirname, which has precedent in three existing files under src/__tests__ and resolves under vitest as well as commonjs. ../../package.json reaches the repo root from both src/mcp/ and dist/mcp/, since rootDir is src and outDir is dist — I checked that rather than assuming it.

Worth running npm run typecheck before pushing; this one was a single command away.

2. The read is now non-fatal. It executes at module load, so an unreadable or unparseable package.json would have thrown there and stopped the server booting — over a version string. It now falls back to 0.0.0-unknown, which is both a better failure than no server and self-describing if it ever shows up in a client's logs.

Merge note: tests/mcp.test.ts conflicted with #555, which landed earlier today. Kept both sides — that PR's ListToolsRequestSchema and PAID_CALL_HTTP_METHODS imports, plus your new server-identity block.

Also: this PR names no issue, which is correct — it's a chore, and I'd rather have it as one than see it bundled into something else.

Verified on the merge result: tsc --noEmit silent, 889 tests across 82 suites, nothing red.

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.

The server version is a hard-coded string

2 participants