From 05a8b151582f29808fb714c4c81779cbb125e3f5 Mon Sep 17 00:00:00 2001 From: Vilius Vystartas Date: Fri, 26 Jun 2026 00:37:54 +0100 Subject: [PATCH 1/2] fix(memory): read server version from package.json at runtime The serverInfo.version field was hardcoded as '0.6.3' in the McpServer constructor, causing it to drift from the actual package version when publishing. The compiled dist/index.js always reported '0.6.3' regardless of the package version set in package.json. Fix by reading the version from package.json at startup via a fallback path lookup that works in both source (dev/test) and compiled (production) contexts. Fixes #4406 --- src/memory/index.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/memory/index.ts b/src/memory/index.ts index 9865c5318e..fd4d18760b 100644 --- a/src/memory/index.ts +++ b/src/memory/index.ts @@ -4,7 +4,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { SubscribeRequestSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js"; import { z } from "zod"; -import { promises as fs } from 'fs'; +import { promises as fs, readFileSync } from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; @@ -253,10 +253,27 @@ const RelationSchema = z.object({ relationType: z.string().describe("The type of the relation") }); +// Read version from package.json at runtime to stay in sync with the published release. +// Works from both source (src/memory/index.ts → ./package.json) and +// compiled (dist/index.js → ../package.json). +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +function loadPackageJson(): { version: string } { + const candidates = [ + path.join(__dirname, 'package.json'), + path.join(__dirname, '..', 'package.json'), + ]; + for (const c of candidates) { + try { return JSON.parse(readFileSync(c, 'utf-8')); } catch { /* try next */ } + } + return { version: '0.0.0' }; +} +const { version: SERVER_VERSION } = loadPackageJson(); + // The server instance and tools exposed to Claude const server = new McpServer({ name: "memory-server", - version: "0.6.3", + version: SERVER_VERSION, }); const RESOURCE_URI = "memory://knowledge-graph"; From 1f505030681421b019e1d7ca4b9b5fd3350a2011 Mon Sep 17 00:00:00 2001 From: Vilius Vystartas Date: Fri, 26 Jun 2026 00:44:45 +0100 Subject: [PATCH 2/2] fix(filesystem): case-insensitive path comparison on Windows On Windows, file paths are case-insensitive (C:\source and c:\Source refer to the same location). The path validation was comparing paths case-sensitively, causing 'Access denied' errors when the allowed directories were configured with a different casing than the actual filesystem paths. Fix by lowercasing both paths before the startsWith comparison on Windows. Non-Windows platforms remain case-sensitive. Fixes #470 --- src/filesystem/path-validation.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/filesystem/path-validation.ts b/src/filesystem/path-validation.ts index 972e9c49d0..007da41519 100644 --- a/src/filesystem/path-validation.ts +++ b/src/filesystem/path-validation.ts @@ -81,6 +81,11 @@ export function isPathWithinAllowedDirectories(absolutePath: string, allowedDire return pathDrive === dirDrive && normalizedPath.startsWith(normalizedDir.replace(/\\?$/, '\\')); } + // On Windows, file paths are case-insensitive — compare lowercased + // so C:\source matches c:\Source\file.txt + if (process.platform === 'win32') { + return normalizedPath.toLowerCase().startsWith((normalizedDir + path.sep).toLowerCase()); + } return normalizedPath.startsWith(normalizedDir + path.sep); }); }