PWC-8: Inline Nitro PDF viewer in Claude#84
Open
SudNitro23 wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-readerAngular 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 emscriptenwasmBinary(the sandbox CSP blocksfetch()of evendata:URLs), and inlines the Kendo theme + IBM Plex fonts asdata:URLs.scripts/viewer-bridge.js— connects via@modelcontextprotocol/ext-apps, receives{ filePath }from the tool result, callsget_pdf_for_viewerover the MCP transport, and assigns the bytes to the component'sfileproperty. 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— registersview_pdf, theget_pdf_for_viewerbyte provider, and asave_pdf_editsstub.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.htmlis a generated ~25 MB single-file bundle (built byinline-viewer.mjsfrom the frontend'snx build public-readeroutput). It's committed so the release workflow (task build) produces a working extension without the frontend repo. It's excluded from lint/format via.prettierignoreandeslint.config.ts.express/opendependencies.manifest.jsonversion is unchanged (0.22.0) — the Publish Release workflow owns version bumps.🤖 Generated with Claude Code