From 99d0471c0c487e70536811c3e5c5238227b403d3 Mon Sep 17 00:00:00 2001 From: Shellishack <40737228+Shellishack@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:15:43 +0800 Subject: [PATCH] Fix windows absolute path parsing bug --- src/filesystem/roots-utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filesystem/roots-utils.ts b/src/filesystem/roots-utils.ts index 8732997757..5e26bb246b 100644 --- a/src/filesystem/roots-utils.ts +++ b/src/filesystem/roots-utils.ts @@ -3,6 +3,7 @@ import path from 'path'; import os from 'os'; import { normalizePath } from './path-utils.js'; import type { Root } from '@modelcontextprotocol/sdk/types.js'; +import { fileURLToPath } from "url"; /** * Converts a root URI to a normalized directory path with basic security validation. @@ -11,7 +12,7 @@ import type { Root } from '@modelcontextprotocol/sdk/types.js'; */ async function parseRootUri(rootUri: string): Promise { try { - const rawPath = rootUri.startsWith('file://') ? rootUri.slice(7) : rootUri; + const rawPath = rootUri.startsWith('file://') ? fileURLToPath(rootUri) : rootUri; const expandedPath = rawPath.startsWith('~/') || rawPath === '~' ? path.join(os.homedir(), rawPath.slice(1)) : rawPath;