fix(filesystem): preserve root aliases from MCP roots#4145
Conversation
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.
|
Quick update: I rebased this PR onto the current Locally re-ran the touched package gates before pushing:
GitHub CI is now re-running on the rebased head. If there’s any maintainer preference on shape/scope, I can adjust it quickly. |
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