diff --git a/src/filesystem/index.ts b/src/filesystem/index.ts index 7b67e63e58..4e9f36bbcd 100644 --- a/src/filesystem/index.ts +++ b/src/filesystem/index.ts @@ -554,7 +554,8 @@ server.registerTool( const result: TreeEntry[] = []; for (const entry of entries) { - const relativePath = path.relative(rootPath, path.join(currentPath, entry.name)); + // Normalize to forward slashes for consistent cross-platform glob matching + const relativePath = path.relative(rootPath, path.join(currentPath, entry.name)).split(path.sep).join('/'); const shouldExclude = excludePatterns.some(pattern => { if (pattern.includes('*')) { return minimatch(relativePath, pattern, { dot: true }); diff --git a/src/filesystem/lib.ts b/src/filesystem/lib.ts index 17e4654cd5..5d6f3eb292 100644 --- a/src/filesystem/lib.ts +++ b/src/filesystem/lib.ts @@ -389,7 +389,8 @@ export async function searchFilesWithValidation( try { await validatePath(fullPath); - const relativePath = path.relative(rootPath, fullPath); + // Normalize to forward slashes for consistent cross-platform glob matching + const relativePath = path.relative(rootPath, fullPath).split(path.sep).join('/'); const shouldExclude = excludePatterns.some(excludePattern => minimatch(relativePath, excludePattern, { dot: true }) );