Skip to content

PIGS-864: Add render_pdf_page tool for inline page image rendering#86

Merged
rpalekar merged 2 commits into
mainfrom
pigs-864-render-pdf-page
Jun 16, 2026
Merged

PIGS-864: Add render_pdf_page tool for inline page image rendering#86
rpalekar merged 2 commits into
mainfrom
pigs-864-render-pdf-page

Conversation

@rpalekar

@rpalekar rpalekar commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

https://gonitro.atlassian.net/browse/PIGS-864

Summary

  • New MCP tool render_pdf_page(inputPath, pageIndex, dpi, clipBox?) returning the rendered page as an inline base64 PNG content block — no disk writes.
  • Built by composing existing endpoints (splitPdfconvertFile → in-memory unzip + crop + resize via fflate/jimp) to avoid cross-repo work. See the Jira comment for the two approaches considered.
  • clipBox is in 72-dpi PDF points (top-left origin) so detection boxes from extract_pii / search_text_in_pdf / redact_pdf round-trip directly into close-up inspection.
  • DPI range 50–300 (default 150); the platform always rasterises at 300 DPI, so we downscale client-side and can't go sharper than 300.
  • Unlocks the PwC Demo 3 use case (visual verification of policy-driven redactions).

Trade-offs

  • Two backend round-trips per render (split + convert). A future follow-up will replace the pipeline with a single platform render-page method and keep the public tool surface unchanged.
  • Always renders at 300 DPI server-side then scales down — wasted backend work for low-DPI full-page renders.

Test plan

  • task n:check — format, types, lint all clean
  • task n:test — 168 tests pass (1 skipped), rendering.ts at 100% statement coverage
  • Manual smoke test in Claude Desktop: full page, low-DPI thumbnail, clipped region, and the PII-verification end-to-end flow all return an inline image that the model can describe visually.

🤖 Generated with Claude Code

rpalekar and others added 2 commits June 16, 2026 11:31
New MCP tool that renders a single PDF page (or clipped region) as an
inline base64 PNG content block, with no disk writes. Enables agent
workflows (e.g. PII redaction verification) where the model needs
visual access to a specific page.

Implementation composes existing platform endpoints: splitPdf isolates
the target page, convertFile rasterises it to PNG at the platform's
fixed 300 DPI, then fflate/jimp are used in-memory to unpack the ZIPs,
crop to clipBox (in 72-dpi PDF points, top-left origin to match
extract_pii/search_text_in_pdf/redact_pdf), and downscale to the
requested DPI (50-300, default 150).

Co-Authored-By: Claude Code <noreply@anthropic.com>
@rpalekar rpalekar merged commit ce916a4 into main Jun 16, 2026
6 checks passed
@rpalekar rpalekar deleted the pigs-864-render-pdf-page branch June 16, 2026 12:18
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.

2 participants