server-filesystem: MCP roots protocol overwrites CLI-provided allowed directories
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- backend
調査の方向性
dist/index.js の 564 行目付近から始め、続いて updateAllowedDirectoriesFromRoots と RootsListChangedNotificationSchema handler を調べます。複数の CLI ディレクトリと 1 つのクライアント root を使って再現し、list_allowed_directories を呼び出して、初期化後と root-list の変更後の両方で、既存の CLI ディレクトリとクライアントディレクトリがすべて引き続き一覧に残ることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 90.5k
- フォーク
- 11.7k
- 平均マージ
- 5日 19時間
- マージ済み PR(30日)
- 6
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/servers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/servers#4830 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/servers#4829 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
modelcontextprotocol/servers#4812 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
modelcontextprotocol/servers#4804 · コメント 1 件 ·
-
README gate confirmation command can be used by any commenter, bypassing the "readme: pending" gate オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
modelcontextprotocol/servers#4796 ·
modelcontextprotocol/servers の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
bcgov/bc-wallet-mobile#4761 · コメント 1 件 ·
-
external-issue to-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100