Skip to content

Conversation

olaservo
Copy link
Member

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

  • Server: filesystem
  • Changes to: Path normalization utilities (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:

  • Input: /mnt/c/Users/username/folder
  • Broken behavior: Converted to C:\Users\username\folder
  • Result: ENOENT: no such file or directory because Windows paths don't work inside WSL

This regression broke existing Claude Desktop configurations that rely on running the filesystem server through WSL.

Changes Made

src/filesystem/path-utils.ts:

  1. convertToWindowsPath() function:

    • WSL paths (/mnt/...) are now never converted regardless of platform
    • Unix-style Windows paths (/c/...) are only converted when running on Windows (process.platform === 'win32')
  2. normalizePath() function:

    • Updated path detection logic to always preserve WSL paths
    • On non-Windows platforms, all absolute paths starting with / are treated as Unix paths
    • Forward slash to backslash conversion only happens on Windows platform

src/filesystem/__tests__/path-utils.test.ts:

How Has This Been Tested?

  • All 133 unit tests pass (added 1 new test)
  • Platform-specific tests verify behavior on both Windows (win32) and Linux platforms

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally (all 133 tests passing)
  • I have added appropriate error handling (No new error handling needed - paths are now correctly preserved)
  • I have documented all environment variables and configuration options (No new env vars/config)

Additional context

This fix assumes that WSL paths (/mnt/...) should never be converted because:

  1. Inside WSL: They work correctly with Node.js fs operations
  2. On Windows: They don't exist anyway, so preserving them doesn't cause harm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WSL path conversion bug in v2025.8.18+ causes ENOENT errors

1 participant