mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-02 01:20:23 +08:00
fix(mcp): report package.json version in the MCP handshake
The McpServer metadata version was a separate hardcoded string that never matched the published version (stuck at 0.1.2, then 0.3.0 while npm shipped 0.2.x). Read it from package.json at startup instead — works from both src/ (tsx) and dist/ (published build).
This commit is contained in:
@@ -36,6 +36,7 @@ class XMLSerializerPolyfill {
|
||||
}
|
||||
;(globalThis as any).XMLSerializer = XMLSerializerPolyfill
|
||||
|
||||
import { createRequire } from "node:module"
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
||||
import open from "open"
|
||||
@@ -89,10 +90,17 @@ let currentSession: {
|
||||
lastSeenXml: string
|
||||
} | null = null
|
||||
|
||||
// Create MCP server
|
||||
// Create MCP server. The version reported in the MCP handshake is read from
|
||||
// package.json so it can never drift from the published npm version again
|
||||
// (it sat hardcoded at stale values for most of this package's history).
|
||||
// Both src/ (tsx dev) and dist/ (published build) live one level below the
|
||||
// package root, so the relative path works in either runtime.
|
||||
const require = createRequire(import.meta.url)
|
||||
const packageVersion: string = require("../package.json").version
|
||||
|
||||
const server = new McpServer({
|
||||
name: "next-ai-drawio",
|
||||
version: "0.3.0",
|
||||
version: packageVersion,
|
||||
})
|
||||
|
||||
// Shared Zod schema fragment for page-targeting parameters.
|
||||
|
||||
Reference in New Issue
Block a user