Skip to content

fix(filesystem): preserve root aliases from MCP roots#4145

Open
nnish16 wants to merge 1 commit into
modelcontextprotocol:mainfrom
nnish16:fix/issue-4129
Open

fix(filesystem): preserve root aliases from MCP roots#4145
nnish16 wants to merge 1 commit into
modelcontextprotocol:mainfrom
nnish16:fix/issue-4129

Conversation

@nnish16
Copy link
Copy Markdown

@nnish16 nnish16 commented May 12, 2026

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

  • return both original and resolved root paths from getValidRootDirectories() when they differ
  • dedupe validated root entries while preserving order
  • add a regression test covering roots that resolve through an alias/symlink

Testing

  • cd src/filesystem && npx vitest run
  • npm run build --workspace @modelcontextprotocol/server-filesystem

Fixes #4129

Copilot AI review requested due to automatic review settings May 12, 2026 13:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/filesystem/__tests__/roots-utils.test.ts
Comment thread src/filesystem/__tests__/roots-utils.test.ts
@nnish16
Copy link
Copy Markdown
Author

nnish16 commented May 25, 2026

Quick update: I rebased this PR onto the current main and force-pushed the refreshed branch head: a5ce2d6c9ef907781c82c41bd2e7d27746383369.

Locally re-ran the touched package gates before pushing:

  • npm run test --workspace @modelcontextprotocol/server-filesystem
  • npm run build --workspace @modelcontextprotocol/server-filesystem

GitHub CI is now re-running on the rebased head. If there’s any maintainer preference on shape/scope, I can adjust it quickly.

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.

Filesystem server canonicalizes configured Windows mapped-drive paths to UNC at startup, then rejects identical-target Y:\ inputs

2 participants