Skip to content

mcp: accept Windows drive letter file roots - #1443

Open
akshita317 wants to merge 2 commits into
modelcontextprotocol:mainfrom
akshita317:mcp-file-roots-windows
Open

akshita317 wants to merge 2 commits into
modelcontextprotocol:mainfrom
akshita317:mcp-file-roots-windows

Conversation

@akshita317

Copy link
Copy Markdown
Contributor

fileRoot turns the client's roots into absolute file paths for FileResourceHandler. On Windows, a root for a drive letter path is a URI such as file:///C:/Users/me/project (RFC 8089, Appendix E.2), whose path is /C:/Users/me/project. fileRoot converted that to \C:\Users\me\project, which is not an absolute path on Windows, so every such root failed with not an absolute path, and with it every read through FileResourceHandler as soon as the client reported any roots. TestFileRoot was skipped on Windows with a "TODO: fix for Windows".

This drops the slash before a drive letter on Windows (fileURIPath). VS Code's form, file:///c%3A/..., decodes to the same path. Nothing changes on other systems.

Tests:

  • TestFileRoot is no longer skipped on Windows and has drive letter cases there (upper and lower case, .., file:/C:/…, c%3A, and file:///foo still rejected). They fail without the change; the existing cases run unchanged elsewhere.
  • TestFileURIPath covers the conversion for windows and linux on any platform, so CI on Linux checks it too.

The other Windows-skipped tests in resource_test.go (TestComputeURIFilepath, TestReadFileResource, …) use POSIX paths in their expectations; I left them for a separate change.

AI assistance: prepared with Claude Code.

akshita317 and others added 2 commits October 24, 2026 01:27
fileRoot turns the client's roots into absolute file paths for
FileResourceHandler. On Windows a root for a drive letter path is a URI
such as file:///C:/Users/me/project (RFC 8089, Appendix E.2), whose path
is /C:/Users/me/project. fileRoot converted that to
\C:\Users\me\project, which is not an absolute path on Windows, so every
such root failed with "not an absolute path", and with it every read
through FileResourceHandler once the client had any roots.

Drop the slash before a drive letter on Windows. VS Code's form,
file:///c%3A/..., decodes to the same path.

TestFileRoot is no longer skipped on Windows and gets drive letter
cases there; they fail without the change. TestFileURIPath covers the
conversion for both Windows and other systems on any platform.

This branch has not been deployed

No deployments
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.

2 participants