Skip to content

edit_file rejects native Windows paths but accepts "/C/... " Unix paths #87

@jamhour1g

Description

@jamhour1g

When using edit_file on Windows, passing a standard absolute Windows path is rejected as being outside the allowed directory, even though the file is located inside the configured project directory.

Changing the same path to a Unix/MSYS-style path allows the operation to proceed.

Example

The following call uses a native Windows path:

edit_file [
  dryRun=false,
  path=C:\Users\<USERNAME>\IdeaProjects\WashlyServer\src\test\kotlin\com\washly\server\integration\support\ApiIntegrationTest.kt,
  replaceAll=false
]

It fails with:

Access denied - path is outside allowed directories:
/C:\Users\<USERNAME>\IdeaProjects\WashlyServer\src\test\kotlin\com\washly\server\integration\support\ApiIntegrationTest.kt
not in /C/Users/<USERNAME>/IdeaProjects

The error appears to prepend / to the Windows path without converting its backslashes or drive-letter syntax. This produces:

/C:\Users\<USERNAME>\...

However, the allowed directory is represented as:

/C/Users/<USERNAME>/IdeaProjects

Calling the tool again with the manually converted path succeeds:

MCP_DOCKER_edit_file [
  dryRun=false,
  path=/C/Users/<USERNAME>/IdeaProjects/WashlyServer/src/test/kotlin/com/washly/server/integration/support/ApiIntegrationTest.kt,
  replaceAll=false
]

The tool then returns the expected diff output.

Expected behavior

The tool should normalize native Windows paths before checking whether they are inside an allowed directory.

For example:

C:\Users\<USERNAME>\IdeaProjects\WashlyServer\...

should be recognized as equivalent to:

/C/Users/<USERNAME>/IdeaProjects/WashlyServer/...

Actual behavior

The native Windows path is converted to an invalid mixed-format path:

/C:\Users\<USERNAME>\...

This causes the allowed-directory validation to fail even though the target file is within the configured project directory.

Environment

  • Host operating system: Windows
  • Tool: edit_file
  • Allowed directory: /C/Users/<USERNAME>/IdeaProjects
  • rust-mcp-filesystem.enable_roots is on, SIDE NOTE: this needs docs on what it does I still don't know what it does

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions