server-filesystem: MCP roots protocol overwrites CLI-provided allowed directories
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Bắt đầu trong dist/index.js quanh dòng 564, sau đó kiểm tra updateAllowedDirectoriesFromRoots và handler RootsListChangedNotificationSchema. Tái hiện với nhiều thư mục CLI và một root của client, gọi list_allowed_directories và xác minh rằng tất cả các thư mục CLI và client hiện có vẫn được liệt kê sau cả khi khởi tạo lẫn khi danh sách root thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
When the MCP client supports the roots protocol, the filesystem server's oninitialized handler replaces all command-line allowed directories with only the roots provided by the client. This means any additional directories passed via CLI args are silently discarded.
Steps to Reproduce
- Configure the filesystem MCP server with multiple allowed directories via CLI args:
npx @modelcontextprotocol/server-filesystem /home/user /mnt/Storage /mnt/Games /mnt/Emulators - Connect from a client that supports the MCP roots protocol (e.g., Claude Code) where the working directory is
/home/user - Call
list_allowed_directories
Expected Behavior
All four directories should be listed as allowed:
/home/user
/mnt/Storage
/mnt/Games
/mnt/Emulators
Actual Behavior
Only the client-provided root is listed:
/home/user
The other three directories are silently dropped and become inaccessible.
Root Cause
In dist/index.js, the oninitialized handler (around line 564) unconditionally replaces allowedDirectories with the client roots when the client supports the roots protocol:
server.server.oninitialized = async () => {
const clientCapabilities = server.server.getClientCapabilities();
if (clientCapabilities?.roots) {
const response = await server.server.listRoots();
if (response && 'roots' in response) {
await updateAllowedDirectoriesFromRoots(response.roots);
}
}
};
And updateAllowedDirectoriesFromRoots does a full replacement:
allowedDirectories = [...validatedRootDirs];
Suggested Fix
CLI-provided directories should be preserved and merged with client roots, not replaced. For example:
async function updateAllowedDirectoriesFromRoots(requestedRoots) {
const validatedRootDirs = await getValidRootDirectories(requestedRoots);
if (validatedRootDirs.length > 0) {
// Merge with existing CLI-provided directories instead of replacing
const merged = new Set([...allowedDirectories, ...validatedRootDirs]);
allowedDirectories = [...merged];
setAllowedDirectories(allowedDirectories);
}
}
The same fix should apply to the RootsListChangedNotificationSchema handler.
Environment
@modelcontextprotocol/server-filesystemversion: 2026.1.14- Client: Claude Code (supports MCP roots protocol)
- OS: Linux (openSUSE Tumbleweed)
- All directories exist and are mounted ext4 partitions
- Ngôn ngữ chính
- TypeScript
- Star
- 90.5k
- Fork
- 11.7k
- Merge trung bình
- 5 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 6
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/servers
-
Docs: `fetch` installs npm packages during a tool call, which is worth stating for deployments Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/servers#4830 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/servers#4829 ·
-
Add ContHunt remote MCP server Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
modelcontextprotocol/servers#4812 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
modelcontextprotocol/servers#4804 · 1 bình luận ·
-
README gate confirmation command can be used by any commenter, bypassing the "readme: pending" gate Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/servers#4796 ·
Tất cả issue của modelcontextprotocol/servers
Issue tương tự
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Crush Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
ElementsProject/cln-application#167 · 1 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Quantco/pnpm-licenses#17 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100