Skip to content

fix(filesystem): merge MCP roots with CLI-provided directories instead of replacing them#3616

Open
flobo3 wants to merge 1 commit intomodelcontextprotocol:mainfrom
flobo3:fix/filesystem-roots-merge
Open

fix(filesystem): merge MCP roots with CLI-provided directories instead of replacing them#3616
flobo3 wants to merge 1 commit intomodelcontextprotocol:mainfrom
flobo3:fix/filesystem-roots-merge

Conversation

@flobo3
Copy link

@flobo3 flobo3 commented Mar 17, 2026

Fixes #3602

Problem

When an MCP client supports the roots protocol, the filesystem server's oninitialized handler unconditionally replaces all command-line allowed directories with only the roots provided by the client. This causes any additional directories passed via CLI arguments to be silently discarded and become inaccessible.

Solution

Modified updateAllowedDirectoriesFromRoots in src/filesystem/index.ts to merge the client-provided roots with the existing allowedDirectories (which contains the CLI-provided directories) using a Set to ensure uniqueness, instead of completely replacing them.

This ensures that both CLI-provided directories and client-provided roots are accessible to the server.

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.

server-filesystem: MCP roots protocol overwrites CLI-provided allowed directories

1 participant