PDF preview broken in file viewer after 2.1.165 — local PDFs blocked by pdf-server roots gating

Resolved 💬 1 comment Opened Jun 8, 2026 by jorgeven98 Closed Jul 15, 2026

Summary

Clicking a local PDF in the Claude Code file viewer used to render it. After updating to 2.1.165 it falls back to the text previewer:

This file appears to contain binary data and cannot be previewed as text.

Worked in 2.1.161. Regression in 2.1.165.

Environment

  • Claude Code (desktop "code" mode), Windows
  • claude-code: 2.1.165 (regression vs 2.1.161)
  • Bundled plugin pdf-viewer@inline → PDF Server v1.7.2 (ext ant.dir.gh.anthropic.pdf-server-mcp)

Root cause (verified from logs + bundled dist/server.js)

PDF Server v1.7.2 only allows local files inside a directory present in allowedLocalDirs. That set is populated only from:
(a) CLI path args at launch, or
(b) MCP client roots via refreshRoots(), which is gated by clientCapabilities.roots.

In 2.1.165:

  • The pdf-viewer MCP launches with args ["dist/index.js", "--stdio"] — no directory arg.
  • The client initializes with capabilities: {}no roots capability — so refreshRoots() returns early and never populates allowedLocalDirs.

Result: allowedLocalDirs stays empty and validateUrl() rejects every local PDF:

[pdf-server] Local file not in allowed list: <path>\<file>.pdf
  Allowed dirs:

Steps to reproduce

  1. Open a project folder in Claude Code 2.1.165 (Windows).
  2. Click any local .pdf in the file viewer.
  3. "binary data" message appears instead of the rendered PDF.

Expected

File viewer exposes the open workspace folder to the pdf-server (as a launch arg or via MCP roots) so clicked local PDFs render.

Actual

Empty allowed list → all local PDFs rejected → text-preview fallback.

Notes / workaround attempted

Adding the workspace dir as a launch arg to the Desktop extension manifest registers it ([pdf-server] Registered local directory: ...) and fixes the Desktop-chat side. But the file viewer uses the built-in pdf-viewer@inline plugin baked into claude.exe, which is not user-editable — so the file-viewer path cannot be fixed from user config.

Suggested fix

Have claude-code declare the roots capability and send the workspace folder(s) as MCP roots to the bundled pdf-server, or pass the workspace path as a launch arg.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗