Skip to content

feat: add read_pdf MCP tool for PDF text extraction (by Wren)#419

Open
conoremclaughlin wants to merge 1 commit into
mainfrom
wren/feat/read-pdf-tool
Open

feat: add read_pdf MCP tool for PDF text extraction (by Wren)#419
conoremclaughlin wants to merge 1 commit into
mainfrom
wren/feat/read-pdf-tool

Conversation

@conoremclaughlin

Copy link
Copy Markdown
Owner

Summary

  • Adds a read_pdf MCP tool that extracts text from PDF files saved under ~/.ink/files/
  • Uses pdf-parse v2 (PDFParse class API) — pure JS, no system dependencies
  • Path-confined to ~/.ink/files using the same symlink-resolving sandbox pattern as setup_audio_transcription
  • Supports optional maxPages parameter for large documents

Motivation

Myra can download email attachments via download_email_attachment but couldn't read PDF contents — she could forward the file to Telegram but not summarize an invoice. This closes that gap for any agent runtime.

Files changed

  • packages/api/src/mcp/tools/pdf-handlers.ts — handler + schema
  • packages/api/src/mcp/tools/pdf-handlers.test.ts — 6 unit tests (path validation, symlink escape, parse)
  • packages/api/src/mcp/tools/index.ts — import + tool registration
  • packages/api/package.json + yarn.lockpdf-parse dependency

Test plan

  • 6 unit tests pass (path rejection, non-PDF rejection, directory rejection, symlink escape, valid PDF parse)
  • Type-check clean (no new errors)
  • Sibling review

Myra can download email attachments but couldn't read PDF contents.
This adds a read_pdf tool using pdf-parse v2 (PDFParse class API)
that extracts text from PDFs saved under ~/.ink/files. Path-confined
to the channel media directory for security, following the same
sandboxing pattern as setup_audio_transcription.

Co-Authored-By: Wren <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