File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import path from 'path';
33import os from 'os' ;
44import { normalizePath } from './path-utils.js' ;
55import 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 */
1213async 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 ;
You can’t perform that action at this time.
0 commit comments