Repository navigation
mcp: accept Windows drive letter file roots - #1443
Open
akshita317 wants to merge 2 commits into
Open
akshita317 wants to merge 2 commits into
akshita317 wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fileRootturns the client's roots into absolute file paths forFileResourceHandler. On Windows, a root for a drive letter path is a URI such asfile:///C:/Users/me/project(RFC 8089, Appendix E.2), whose path is/C:/Users/me/project.fileRootconverted that to\C:\Users\me\project, which is not an absolute path on Windows, so every such root failed withnot an absolute path, and with it every read throughFileResourceHandleras soon as the client reported any roots.TestFileRootwas 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:
TestFileRootis no longer skipped on Windows and has drive letter cases there (upper and lower case,..,file:/C:/…,c%3A, andfile:///foostill rejected). They fail without the change; the existing cases run unchanged elsewhere.TestFileURIPathcovers the conversion forwindowsandlinuxon 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.