fix(filesystem): preserve root aliases from MCP roots#4145
Open
nnish16 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the filesystem server’s MCP-roots handling to preserve both the original root path and its realpath()-resolved target when they differ, aligning runtime allow-list checks with startup CLI behavior so alias/symlink/mapped-drive paths continue to validate correctly.
Changes:
- Update root URI parsing to return both normalized original and normalized resolved paths when they differ.
- Dedupe validated root directory entries while preserving insertion order.
- Add a regression test covering a root directory that resolves through a symlink/alias.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/filesystem/roots-utils.ts |
Return both original and resolved root paths (when different) and dedupe validated directories. |
src/filesystem/__tests__/roots-utils.test.ts |
Add regression coverage for symlink/alias roots returned via MCP roots. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Preserve both the original root path and its resolved target when filesystem roots come from the MCP roots protocol. This keeps runtime allow-list checks symmetric with startup args, so mapped-drive or symlink-style paths keep working even when
realpath()rewrites them.Changes
getValidRootDirectories()when they differTesting
cd src/filesystem && npx vitest runnpm run build --workspace @modelcontextprotocol/server-filesystemFixes #4129