Skip to content

Commit 1b96551

Browse files
authored
fix(filesystem): use fileURLToPath for Windows absolute path parsing (#3205)
1 parent 6a914b9 commit 1b96551

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/filesystem/roots-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path';
33
import os from 'os';
44
import { normalizePath } from './path-utils.js';
55
import type { Root } from '@modelcontextprotocol/sdk/types.js';
6+
import { fileURLToPath } from "url";
67

78
/**
89
* 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';
1112
*/
1213
async function parseRootUri(rootUri: string): Promise<string | null> {
1314
try {
14-
const rawPath = rootUri.startsWith('file://') ? rootUri.slice(7) : rootUri;
15+
const rawPath = rootUri.startsWith('file://') ? fileURLToPath(rootUri) : rootUri;
1516
const expandedPath = rawPath.startsWith('~/') || rawPath === '~'
1617
? path.join(os.homedir(), rawPath.slice(1))
1718
: rawPath;

0 commit comments

Comments
 (0)