Skip to content

PWC-8: Inline Nitro PDF viewer in Claude#84

Open
SudNitro23 wants to merge 2 commits into
mainfrom
PWC-8-inline-pdf-viewer
Open

PWC-8: Inline Nitro PDF viewer in Claude#84
SudNitro23 wants to merge 2 commits into
mainfrom
PWC-8-inline-pdf-viewer

Conversation

@SudNitro23

Copy link
Copy Markdown

What

Adds view_pdf — renders a PDF in Nitro's reader inline inside the Claude conversation (MCP-App iframe). No browser popup, no network, no second login.

Jira: PWC-8

How it works

The viewer is Nitro's nitro-pdf-reader Angular web component (apps/public-reader). The MCP-App sandbox has no origin and blocks all outbound network, so the multi-file build is folded into one self-contained HTML:

  • scripts/inline-viewer.mjs — collapses app chunks + dynamic imports into one ESM bundle (esbuild), embeds the worker as a Blob URL, injects the Pdfium WASM via emscripten wasmBinary (the sandbox CSP blocks fetch() of even data: URLs), and inlines the Kendo theme + IBM Plex fonts as data: URLs.
  • scripts/viewer-bridge.js — connects via @modelcontextprotocol/ext-apps, receives { filePath } from the tool result, calls get_pdf_for_viewer over the MCP transport, and assigns the bytes to the component's file property. Also reroutes the reader's Download through the host (ui/download-file) and adds a widescreen toggle (ui/request-display-mode).
  • src/tools/viewer.ts — registers view_pdf, the get_pdf_for_viewer byte provider, and a save_pdf_edits stub.

Tools

  • view_pdf — mount the viewer for a given PDF path (preferred way to show a PDF to the user).
  • get_pdf_for_viewer (internal) — streams PDF bytes to the viewer.
  • save_pdf_edits (internal, stub) — round-trip pending a component save event.

Notes for reviewers

  • src/assets/mcp-app.html is a generated ~25 MB single-file bundle (built by inline-viewer.mjs from the frontend's nx build public-reader output). It's committed so the release workflow (task build) produces a working extension without the frontend repo. It's excluded from lint/format via .prettierignore and eslint.config.ts.
  • Removes the legacy popup/companion editor and its express/open dependencies.
  • manifest.json version is unchanged (0.22.0) — the Publish Release workflow owns version bumps.

🤖 Generated with Claude Code

SudNitro23 and others added 2 commits June 16, 2026 10:36
Render PDFs inside the Claude conversation using Nitro's nitro-pdf-reader
web component, folded into one self-contained MCP-App HTML — no browser
popup, no network, no second login.

- view_pdf tool mounts the viewer as an MCP-App resource; PDF bytes stream
  over the MCP transport via get_pdf_for_viewer (the sandbox CSP blocks all
  outbound network).
- scripts/inline-viewer.mjs bundles the multi-file public-reader build into
  one HTML: app chunks + worker inlined, Pdfium WASM fed via emscripten
  wasmBinary, Kendo CSS + IBM Plex fonts inlined as data: URLs.
- scripts/viewer-bridge.js connects via @modelcontextprotocol/ext-apps,
  loads the file, reroutes Download through the host, and adds a widescreen
  toggle.
- save_pdf_edits is a stub pending a component save event.
- Remove the legacy popup/companion editor and its express/open deps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant