Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

v1.7.0 refreshRoots() clears allowedLocalDirs when host advertises roots capability but returns empty list — wipes CLI-arg directories

Đang mở Phù hợp với người mới
#644 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
backend-api-design, cli

Hướng nghiên cứu

Bắt đầu trong dist/server.js tại refreshRoots() và theo dõi cách allowedLocalDirs được điền từ roots và các đối số CLI trong dist/index.js quanh dòng 34372 và 34376. Chạy quá trình tái hiện trên Windows với một positional directory, sau đó gọi list_pdfs và display_pdf; được xem là hoàn tất khi thư mục CLI vẫn nằm trong allowedDirectories sau khi khởi tạo và có thể mở các tệp cục bộ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
2.9k
Fork
387
Merge trung bình
2 giờ 54 phút
Pull request đã merge (30 ngày)
7

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/ext-apps

Tất cả issue của modelcontextprotocol/ext-apps

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.