v1.7.0 refreshRoots() clears allowedLocalDirs when host advertises roots capability but returns empty list — wipes CLI-arg directories
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- typescript
調査の方向性
dist/server.js の refreshRoots() から始め、dist/index.js の 34372 行目と 34376 行目付近で、roots と CLI 引数から allowedLocalDirs がどのように設定されるかを追跡します。positional directory を指定して Windows で再現手順を実行し、その後 list_pdfs と display_pdf を呼び出します。初期化後も CLI ディレクトリが allowedDirectories に残り、ローカルファイルを開けることが完了条件です。
索引モデルが issue の本文から書いたものです。
説明
Version: 1.7.0 (pdf-server-mcp via Claude Desktop extension manager)
OS: Windows 11 / Claude Desktop 1.4758.0
Severity: Functional regression — local PDFs cannot be opened via display_pdf
What happens
list_pdfs returns:
{"localFiles": [], "allowedDirectories": [], "truncated": false}
Even when:
Directories are passed as positional args via the manifest's mcp_config.args
(which parseArgs() should register at line ~34372 in dist/index.js)
A cowork directory mount has been approved by the user
display_pdf against any local file path is rejected with "Local file not in allowed list".
Root cause
In dist/server.js refreshRoots():
async function refreshRoots(server) {
if (!server.getClientCapabilities()?.roots)
return;
try {
const { roots } = await server.listRoots();
allowedLocalDirs.clear(); // <-- this line
for (const root of roots) { ... }
}
}
When --stdio mode runs, useClientRoots: true is hardcoded, so
refreshRoots() always fires on init via oninitialized. Claude Desktop
1.4758.0 advertises the roots capability but server.listRoots() returns
an empty array (cowork mounts not propagating as MCP roots). The
unconditional clear() then wipes any directories registered via CLI args
in main() lines 34372/34376.
Reproduction
Install pdf-server-mcp 1.7.0 in Claude Desktop on Windows.
In manifest.json (or via a launch wrapper) add positional directory
paths to mcp_config.args after --stdio, e.g.
["${__dirname}/dist/index.js", "--stdio", "C:\\some\\dir"].
Restart Claude Desktop.
Call list_pdfs. Expected: allowedDirectories includes C:\some\dir.
Actual: allowedDirectories: [].
Suggested fix
In refreshRoots(), either (a) only clear when the new roots list is
non-empty, or (b) drop the clear entirely and rely on Set.add()'s dedup
behavior. Option (b) is safer because cowork-side root removals would
still need a separate mechanism (e.g., a roots/list_changed notification
that explicitly signals removal, not the current implicit
clear-and-replace).
Workaround applied locally
Commented out the allowedLocalDirs.clear() line. CLI-arg directories
now survive the refresh and display_pdf works on local paths again.
This loses the ability for the host to revoke a previously-granted root
via the empty-list path, but in practice cowork mounts are additive in
our usage pattern.
- 主要言語
- TypeScript
- スター
- 2.9k
- フォーク
- 387
- 平均マージ
- 2時間 54分
- マージ済み PR(30日)
- 7
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/ext-apps のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
modelcontextprotocol/ext-apps#786 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/ext-apps#767 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/ext-apps#742 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
modelcontextprotocol/ext-apps#711 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
modelcontextprotocol/ext-apps#706 ·
modelcontextprotocol/ext-apps の issue をすべて見る
似ている issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100