Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix: sync mcp server runtime version

nash_su73a13c2a614c
diff --git a/mcp-server/src/index.ts b/mcp-server/src/index.ts
index 349b7f62..10cb65b3 100644
--- a/mcp-server/src/index.ts
+++ b/mcp-server/src/index.ts
@@ -15,8 +15,8 @@ import {
type ApiReviewsResponse,
type ApiSearchResult,
} from "./api-client.js"
+import { VERSION } from "./version.js"
-const VERSION = "0.4.20"
const DEFAULT_PROJECT_ID = "current"
const MAX_TEXT_BYTES = 120_000
diff --git a/mcp-server/src/version.ts b/mcp-server/src/version.ts
new file mode 100644
index 00000000..a4c21ec5
--- /dev/null
+++ b/mcp-server/src/version.ts
@@ -0,0 +1,25 @@
+import { readFileSync } from "node:fs"
+
+export const FALLBACK_VERSION = "0.0.0"
+
+export function loadMcpServerVersion(metaUrl: string = import.meta.url): string {
+ // These layouts are mutually exclusive: source/dev execution resolves via
+ // ../package.json, while compiled dist/src execution resolves via
+ // ../../package.json.
+ for (const relativePackageJson of ["../package.json", "../../package.json"]) {
+ try {
+ const candidate = new URL(relativePackageJson, metaUrl)
+ const parsed = JSON.parse(readFileSync(candidate, "utf8")) as { version?: unknown }
+ if (typeof parsed.version === "string" && parsed.version.trim()) {
+ return parsed.version
+ }
+ } catch {
+ // Try the next layout.
+ }
+ }
+
+ process.stderr.write("[llm-wiki-mcp] package.json version not found; using fallback 0.0.0\n")
+ return FALLBACK_VERSION
+}
+
+export const VERSION = loadMcpServerVersion()
diff --git a/mcp-server/test/version.test.ts b/mcp-server/test/version.test.ts
new file mode 100644
index 00000000..43b00a95
--- /dev/null
+++ b/mcp-server/test/version.test.ts
@@ -0,0 +1,27 @@
+import assert from "node:assert/strict"
+import { readFileSync } from "node:fs"
+import { test } from "node:test"
+import { FALLBACK_VERSION, VERSION, loadMcpServerVersion } from "../src/version.js"
+
+const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")) as {
+ version: string
+}
+
+test("MCP server version is read from package.json", () => {
+ assert.equal(VERSION, pkg.version)
+})
+
+test("MCP server version supports source-layout execution", () => {
+ assert.equal(
+ loadMcpServerVersion(new URL("../../src/version.ts", import.meta.url).href),
+ pkg.version,
+ )
+})
+
+test("MCP server version falls back when package.json cannot be found", () => {
+ assert.equal(loadMcpServerVersion("file:///tmp/llm-wiki-missing/dist/src/version.js"), FALLBACK_VERSION)
+})
+
+test("MCP server version falls back for invalid meta URLs", () => {
+ assert.equal(loadMcpServerVersion("not a url"), FALLBACK_VERSION)
+})