Resolve filesystem issue where WSL paths are incorrectly converted to Windows format #2851
+238
−45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2795
Description
This PR fixes a bug introduced in v2025.8.18 where WSL paths (
/mnt/c/...
) were being incorrectly converted to Windows format (C:\...
), causing ENOENT errors when running the filesystem server inside WSL.The root cause was in the path normalization logic that assumed WSL paths should be converted to Windows format. However, when Node.js runs inside WSL (via
wsl npx ...
), it uses Linux filesystem APIs that require Linux-style paths. Windows-style paths don't work with Node.js fs operations inside WSL.Server Details
path-utils.ts
)Motivation and Context
When users run Claude Desktop on Windows and configure it to use the filesystem server via WSL (e.g.,
wsl npx @modelcontextprotocol/server-filesystem /mnt/c/Users/...
), the server was converting the WSL paths to Windows format, causing them to become inaccessible:/mnt/c/Users/username/folder
C:\Users\username\folder
ENOENT: no such file or directory
because Windows paths don't work inside WSLThis regression broke existing Claude Desktop configurations that rely on running the filesystem server through WSL.
Changes Made
src/filesystem/path-utils.ts
:convertToWindowsPath()
function:/mnt/...
) are now never converted regardless of platform/c/...
) are only converted when running on Windows (process.platform === 'win32'
)normalizePath()
function:/
are treated as Unix pathssrc/filesystem/__tests__/path-utils.test.ts
:How Has This Been Tested?
win32
) and Linux platformsBreaking Changes
No
Types of changes
Checklist
Additional context
This fix assumes that WSL paths (
/mnt/...
) should never be converted because: