pdf-toolbox-mcp
This server is a local-first PDF processing toolbox for AI agents, letting you read, transform, secure, and publish PDFs entirely on your machine—from OCR and encryption handling to splitting, compressing, and redaction.
Inspect & diagnose:
pdf_info,is_searchable,list_fonts,check_repair,dependency_status,doctorExtract content:
extract_text,extract_images,extract_attachments,render_pages(as PNG/image blocks for vision)OCR scanned PDFs:
ocr_pdfwrites a searchable text layer back into the file;batch_ocrhandles directoriesUnlock & protect:
unlock_pdfdecrypts with user password;protect_pdfapplies AES-256 encryption with granular permissionsManipulate pages:
split_pdf,merge_pdfs,rotate_pagesPublish & optimize:
linearize,sanitize,edit_metadata,compress_pdf(optionally to a target size)Redact securely:
redactandredact_textphysically remove content by rasterizing affected pages;locate_textfinds text coordinatesFill forms:
fill_formpopulates AcroForm fieldsSelf-routing errors guide agents (e.g.,
encrypted_pdf→ callunlock_pdf;missing_dependency→ see install command)
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pdf-toolbox-mcp OCR this scanned PDF and make it searchable"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pdf-toolbox-mcp
中文文档 | Local-first PDF processing for AI agents.
Built for people already using Claude Desktop, Claude Code, Cursor, or another MCP client who want local PDF OCR, unlock, split/merge, render, and compress without uploading files.
Others help AI read PDFs. This one helps AI process them — OCR a scan into a truly searchable file, unlock encrypted PDFs, split/merge/rotate, re-encrypt for sharing. 100% on your machine: no cloud calls, no file uploads, no per-page fees.
Quick start
Add to any MCP client:
{
"mcpServers": {
"pdf-toolbox": {
"command": "uvx",
"args": ["--from", "pdf-toolbox-mcp", "pdftoolbox"]
}
}
}PyPI project page: pdf-toolbox-mcp
Need a paste-ready setup for a specific client?
List clients:
uv run pdftoolbox client listClaude Desktop:
uv run pdftoolbox client show claude-desktopCursor:
uv run pdftoolbox client show cursorUniversal project
.mcp.json:uv run pdftoolbox client show universalExport all client files:
uv run pdftoolbox client exportDetect the current client surface:
uv run pdftoolbox client detectSemi-auto install:
uv run pdftoolbox client installoruv run pdftoolbox client install --scope autoImport an existing Claude Desktop setup into Claude Code:
uv run pdftoolbox client import-claude-desktopAdd
--allonly if you want every supported client bundle
Need a one-shot diagnosis and dependency snapshot before your first task? Run uv run pdftoolbox doctor or uv run pdftoolbox doctor --json. It prints available_now, starter_action, starter_cli, and starter_tool so you can jump straight to the first supported move.
First task:
OCR a scan:
uv run pdftoolbox ocr scan.pdf --lang chi_sim+engUnlock a file:
uv run pdftoolbox unlock locked.pdf --password 'xxx'
MCP first task:
Ask
tool_doctorThen call
tool_ocr_pdf
Python dependencies resolve automatically. System tools are capability-leveled — missing ones never crash the server; the tool returns a structured error with the exact install command:
Need the full stack in one shot?
macOS:
brew install qpdf poppler tesseract tesseract-lang ghostscriptDebian/Ubuntu:
sudo apt install qpdf poppler-utils tesseract-ocr tesseract-ocr-chi-sim ghostscriptWindows: use the per-package commands in the table below
Level | Binary | Unlocks | macOS | Debian/Ubuntu | Windows |
L0 | qpdf | split / merge / rotate / unlock |
|
|
|
L1 | poppler | extract_text / render / info |
|
|
|
L2 | tesseract | ocr_pdf (write-back) |
|
|
|
L3 | ghostscript | compress |
|
|
|
Windows note: Ghostscript's binary is
gswin64c.exethere — the probe detects it automatically, socompress_pdfworks out of the box. Tesseract language packs (e.g.chi_sim) must be downloaded to itstessdatafolder separately.
Upstream / reference:
Every successful response carries a _deps summary ({"level": 2, "missing": ["gs"]}) so the agent always knows what's available.
In an MCP session, use tool_doctor.
Related MCP server: tooldash-mcp
Why another PDF MCP?
The PDF MCP space is crowded — but only on the reading side. Based on a hands-on survey of the ecosystem (2026-09):
Capability | pdf-toolbox | Citra (916★) | ODA PDF-Tools (153★) | jztan/pdf-mcp (130★) | Cloud SaaS MCPs |
OCR write-back → searchable PDF file | ✅ | ❌ read-out only | ❌ (no OCR) | ❌ read-out only | ☁️ paid |
Unlock encrypted (user password) | ✅ | ❌ hard fail | ⚠️ owner-pw only | ❌ hard fail | ☁️ paid |
Split / merge / rotate | ✅ | ❌ | ✅ | ❌ | ☁️ paid |
Compress to target size | ✅ | ❌ | ❌ | ❌ | ☁️ paid |
Render pages for vision | ✅ | ✅ | ✅ | ✅ | ☁️ |
100% local & private | ✅ | ✅ | ✅ | ✅ | ❌ |
Pain points this addresses directly:
Claude natively refuses encrypted PDFs; ChatGPT reports "No text could be extracted" on scans — here, OCR writes a real text layer back into the file, and
unlock_pdfdecrypts with just the user password (sent to qpdf via stdin, never exposed in process arguments).Claude Code burns ~30× more tokens reading a PDF page-as-image than extracting text locally.
Tools (25)
Tool | What it does | Engine |
| Pages, encryption status, metadata — always call first | pdfinfo |
| Smart routing: text density check → recommends | pdftotext |
| Layout-aware text, exact page ranges | pdftotext |
| OCR write-back: scan → searchable PDF (deskew, skip/redo, lang fallback) | OCRmyPDF |
| Whole-directory OCR with per-file results, retries, timeouts | OCRmyPDF |
| PNG per page, | pdftoppm |
| Pull embedded images (inventory or PNG files) | pdfimages |
| Pull embedded attachment files | pdfdetach |
| Font audit — non-embedded fonts risk missing glyphs on other machines | pdffonts |
| Decrypt with user password, output a clean decrypted file; password sent via stdin | qpdf |
| AES-256 + granular permissions (print/extract/modify/…) | pikepdf |
| By ranges or every N pages | qpdf |
| Ordered merge | qpdf |
| 90/180/270 on selected pages | qpdf |
| Structural check; | qpdf |
| Web-optimized progressive-loading output | qpdf |
| Publishing hygiene: strip JS/OpenAction/metadata/attachments | pikepdf |
| True redaction: affected pages rasterized + opaque boxes — redacted text physically unrecoverable, other pages keep their text layer ( | pdftoppm + PIL |
| Redact by content: locate every occurrence of the given keywords and black them out — no manual coordinates needed | pdftotext -bbox |
| Find where text occurs: page + bounding boxes (PDF points, top-left origin) — the foundation for redaction & highlighting | pdftotext -bbox |
| Fill AcroForm fields (missing fields reported) | pikepdf |
| Set/clear Title/Author/… (docinfo + XMP) | pikepdf |
| Compress, optionally down a quality ladder until hitting | ghostscript |
| Probe system tools + install commands | — |
| One-shot onboarding check: imports, dependency probe, README paths | — |
Error contract (agents self-route): failures return {"ok": false, "error": "<code>"} — missing_dependency (with install per platform), encrypted_pdf (hint: call unlock_pdf first), wrong_password, output_exists (explicit overwrite required), invalid_page_range, …
Output safety
Single-file outputs are written to a same-directory temporary file and atomically replaced only after the operation succeeds.
render_pages,extract_images, andextract_attachmentsstage multi-file exports in a temporary directory and publish them only after all files are ready.overwritedefaults tofalse; passoverwrite=true(or the CLI--overwrite) to replace an existing output. Failed runs leave the previous output untouched.Unlock passwords are passed to qpdf over stdin, and protect passwords stay inside the Python/pikepdf process rather than command-line arguments.
Examples
In an MCP client, just describe the outcome — the agent chains the tools itself, and the error contract makes it self-routing (an encrypted_pdf error tells it to call unlock_pdf first, and so on). For headless use, define once:
PTX="uvx --from pdf-toolbox-mcp pdftoolbox"
# PyPI form: uvx --from pdf-toolbox-mcp pdftoolbox1 · Scan → searchable PDF (the flagship)
“
contract-scan.pdfis a scanned contract I can't search. Make it searchable — mostly Chinese with some English.”
Agent: pdf_info → is_searchable reports low text density → ocr_pdf(path, lang="chi_sim+eng") writes contract-scan_ocr.pdf. Text extraction and Ctrl+F now work on the output.
$PTX ocr contract-scan.pdf --lang chi_sim+eng
$PTX text contract-scan_ocr.pdf --pages 1-32 · Encrypted PDF → readable
“
locked.pdfis password-protected; the password ishunter2. Unlock it and summarize page 3.”
Agent: unlock_pdf(path, password="hunter2") → locked_unlocked.pdf → extract_text(pages="3").
$PTX unlock locked.pdf --password 'hunter2'
$PTX text locked_unlocked.pdf --pages 33 · Redact secrets before sharing
“Black out every occurrence of
张三andHT-2026-088indraft.pdf— it must be physically unrecoverable.”
Agent: redact_text(queries=["张三", "HT-2026-088"]) → draft_redacted.pdf. Pages containing hits are rasterized, so the strings vanish from the pixels and the text layer; other pages keep their selectable text. Verify by running extract_text on the output: zero hits expected.
$PTX redact-text draft.pdf --query 张三 --query HT-2026-088More recipes — merge & protect, compress-to-target, batch OCR, the publish-hygiene chain (sanitize → edit_metadata → linearize), vision rendering, locate-and-redact, form filling, damaged-file rescue — in the cookbook.
Configuration
Env | Default | Meaning |
|
| Default OCR languages; missing packs auto-fallback (flagged via |
| unset | If set, all writes are confined to this directory; system dirs are always denied |
CLI
Everything is also available headless (great for scripts and CI):
uvx --from pdf-toolbox-mcp pdftoolbox ocr scan.pdf --lang chi_sim+eng
uvx --from pdf-toolbox-mcp pdftoolbox unlock locked.pdf --password 'xxx'
uvx --from pdf-toolbox-mcp pdftoolbox split big.pdf --every-n 10
uvx --from pdf-toolbox-mcp pdftoolbox probe all(Use uvx --from pdf-toolbox-mcp … when installing from PyPI.)
Security & privacy
No network calls. Files never leave the machine.
All subprocess calls use argument lists (no shell interpolation); page-range parsing is shared and validated.
Outputs never silently overwrite:
overwrite=truemust be passed explicitly.Writes honor
PDF_TOOLBOX_WORKSPACE; system directories are denied, and staged outputs are published atomically.Passwords are never logged in error payloads.
Untrusted PDF content is flagged in tool descriptions (prompt-injection awareness).
License compliance
MIT. System tools are invoked as independent processes (aggregation): poppler (GPL-2.0), qpdf (Apache-2.0), tesseract (Apache-2.0), ghostscript (AGPL, optional); Python deps ocrmypdf/pikepdf are MPL-2.0. See PLAN.md §7 for the full table.
Development
uv sync --dev # install
uv run pytest -m "not realworld" # fast path
uv run pytest -m realworld # noisy / slower regression pack
uv run pytest # full suite
uv run pdftoolbox probe all
uv run pdftoolbox probe all --json # structured dependency snapshot
uv run pdftoolbox doctor
uv run python tools/onboarding_check.py
uv run python tools/onboarding_check.py --jsonCross-platform check without leaving macOS:
docker run --rm -v "$PWD":/src:ro python:3.12-slim bash -c \
'apt-get update -qq >/dev/null && apt-get install -y -qq poppler-utils tesseract-ocr qpdf ghostscript >/dev/null &&
pip install -q uv && cp -r /src /work && cd /work && uv sync --dev --quiet && uv run pytest -q'Roadmap: v0.1.4 ships all 25 tools above; v0.1.5 hardened output safety and failure isolation; v0.1.6 hardens secrets handling, configuration writes, and sparse page extraction. Explicit non-goals: editing existing text, password cracking — see PLAN.md.
License
MIT
Available Tools
25 toolstool_batch_ocrTool Batch OcrB
批量 OCR 写回:inputs 为文件路径或目录(取全部 PDF)。单文件失败不中断,逐文件返回结果。
Inputs: inputs (required), lang, deskew, out_dir, +4 more. Returns: object
tool_check_repairTool Check RepairC
结构体检(语法/流编码);repair=true 尝试重建输出修复版文件。
Inputs: path (required), output, repair, overwrite. Returns: object
tool_compress_pdfTool Compress PdfA
压缩 PDF(ghostscript,有损:图像重采样)。target_mb 给定时沿 ebook→screen 下探直到达标(尽力而为)。
Inputs: path (required), output, quality, overwrite, +1 more. Returns: object
tool_dependency_statusTool Dependency StatusA
探测系统依赖、安装命令与可解锁工具。
工具报 missing_dependency 时先看这里。
Inputs: no named parameters. Returns: result
tool_doctorTool DoctorB
一键诊断:导入、依赖快照、README 关键路径。
Inputs: no named parameters. Returns: object
tool_edit_metadataTool Edit MetadataA
编辑元数据(docinfo+XMP 双写);clear=true 清空全部——对外发布前配合 sanitize 使用。
Inputs: path (required), clear, title, author, +5 more. Returns: object
tool_extract_attachmentsTool Extract AttachmentsA
抽取 PDF 内嵌附件文件到指定目录;overwrite=true 才允许覆盖同名文件。
Inputs: path (required), out_dir, overwrite. Returns: object
tool_extract_imagesTool Extract ImagesA
抽取 PDF 内嵌图片为 PNG;list_only=true 只返回图片清单不落盘。
overwrite=true 才允许覆盖同名图片。
Inputs: path (required), pages, out_dir, list_only, +1 more. Returns: object
tool_extract_textTool Extract TextB
提取 PDF 文本(pdftotext)。pages 精确页范围如 '1-3,5';layout 保持版面;per_page 按页返回。
Inputs: path (required), pages, layout, per_page. Returns: object
tool_fill_formTool Fill FormB
填写 AcroForm 表单(字段名→字符串/布尔)。未匹配字段在 missing 中返回。
Inputs: path (required), fields (required), output, overwrite. Returns: object
tool_is_searchableTool Is SearchableA
智能路由入口:判断 PDF 是否已有可提取文本层,返回建议动作(extract_text 或先 ocr_pdf)。不确定时先调这个。
Inputs: path (required), sample_pages. Returns: object
tool_linearizeTool LinearizeB
Web 优化:输出渐进加载版,适合在线浏览的发布文件。
Inputs: path (required), output, overwrite. Returns: object
tool_list_fontsTool List FontsA
字体体检:列出字体与嵌入状态,未嵌入字体跨设备查看/打印可能缺字。
Inputs: path (required). Returns: object
tool_locate_textTool Locate TextA
定位文本出现的页面与坐标框(PDF 点、左上原点)——找内容在哪、给 redact 量坐标的地基。
中文无分词、英文跨词均可命中(NFKC 归一化去空白匹配)。
Inputs: path (required), query (required), pages, max_results. Returns: object
tool_merge_pdfsTool Merge PdfsA
按传入顺序合并多个 PDF 为一个文件。
Inputs: paths (required), output (required), overwrite. Returns: object
tool_ocr_pdfTool Ocr PdfA
对扫描件 OCR 并把文本层写回,产出可搜索 PDF(输出 _ocr.pdf)——本工具箱的核心差异化能力。
默认跳过已有文本层的页;默认语言 chi_sim+eng(缺语言包时自动降级并在结果中说明)。
Inputs: path (required), lang, deskew, output, +2 more. Returns: object
tool_pdf_infoTool Pdf InfoA
获取 PDF 元信息:页数、是否加密、页面尺寸、标题作者等。处理任何 PDF 前先调用此工具。
Inputs: path (required). Returns: object
tool_protect_pdfTool Protect PdfB
AES-256 加密(对外分发)。user_password 留空 = 打开无密码、仅权限限制;权限默认可打印可复制、不可修改。
Inputs: path (required), output, overwrite, allow_form, +7 more. Returns: object
tool_redactTool RedactA
真涂黑(安全级):regions=[{page,x,y,w,h}](PDF 点、左上原点)。含涂黑区域的页被光栅化—— 被涂文字物理删除,复制/提取/文本层均无法恢复;其余页保留原文本层。 rasterize_all=true 全文档光栅化(最高防护档)。
Inputs: path (required), regions (required), dpi, output, +2 more. Returns: object
tool_redact_textTool Redact TextA
按内容真涂黑:自动定位每个关键词的全部出现处并涂黑(无需手工量坐标)。 如"把所有合同编号涂掉"。被涂页光栅化、文字物理删除;其余页保留文本层。
Inputs: path (required), queries (required), dpi, output, +2 more. Returns: object
tool_render_pagesTool Render PagesC
渲染指定页为 PNG。return_images=True 时直接返回图像内容块(供视觉查看复杂版面/图表/扫描页)。
Inputs: path (required), dpi, pages, out_dir, +2 more.
tool_rotate_pagesTool Rotate PagesB
旋转页面 90/180/270 度。pages 缺省旋转全部页。
Inputs: path (required), angle (required), pages, output, +1 more. Returns: object
tool_sanitizeTool SanitizeA
发布版脱敏:剥离 JS/OpenAction/元数据/附件(可选注释)。正文文本不动——防元数据与隐藏对象泄密。
Inputs: path (required), output, overwrite, strip_metadata, +3 more. Returns: object
tool_split_pdfTool Split PdfA
拆分 PDF:ranges='1-3,5' 按区间出文件,或 every_n=N 每 N 页一段。二者二选一。
Inputs: path (required), ranges, every_n, out_dir, +1 more. Returns: object
tool_unlock_pdfTool Unlock PdfA
用密码解锁加密 PDF,输出解密文件。user(打开)密码即可,无需 owner 密码。解锁后再走其他工具。
Inputs: path (required), password (required), output, overwrite. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Most tools target distinct PDF operations, but a few have overlapping boundaries: tool_redact and tool_redact_text both perform redaction via different input modes, and tool_doctor/tool_dependency_status both serve diagnostic purposes. The descriptions are generally clear enough to route correctly, so the overlap is manageable rather than confusing.
All tools follow a consistent snake_case style with a uniform tool_ prefix, and most use a verb_noun pattern like tool_merge_pdfs or tool_extract_text. A few names deviate into noun phrases or question style (tool_doctor, tool_dependency_status, tool_is_searchable), but these are minor exceptions in an otherwise predictable naming scheme.
25 tools sits at the heavy end of the ideal range for a PDF toolbox; each tool does target a genuine PDF operation, but the count is borderline and could feel sprawling. Grouping or reducing some of the more granular diagnostic tools might have made the surface tighter.
The surface covers the main PDF lifecycle well: inspection, text extraction, OCR, merge/split, rotation, redaction, compression, encryption, forms, metadata, and sanitization. Obvious gaps remain, such as creating a PDF from scratch, deleting/reordering pages, digital signing, or watermarking, but these are not core to the demonstrated purpose and can be worked around.
Maintenance
Related MCP Connectors
PDF and image tools for AI agents: compress, merge, split, OCR, sign. Runs locally, never uploads.
PDF tools for AI agents: validate, extract, merge, split, compress, OCR, sign and redact.
Merge, split, extract, rotate, reorder and stamp PDF pages from your AI chat, all offline.
Merge, split, extract, rotate, reorder and stamp PDF pages from your AI chat, all offline.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to perform comprehensive PDF operations locally, including compression, text extraction, PII redaction, page organization, splitting, merging, watermarking, creation, and form filling, all without cloud uploads.22 npm-
- AlicenseAqualityDmaintenanceEnables AI agents to inspect PDFs, merge or extract pages, and clean text entirely offline through the Model Context Protocol, with no uploads, API keys, or network calls.464 npmMIT
- AlicenseBqualityBmaintenanceLets AI assistants read, search, edit, annotate, sign, redact and OCR PDF files entirely on the local machine, with no uploads and non-destructive writes to new files. It also merges, splits and reorganises pages, fills forms, compares versions to detect tampering, and converts documents between PDF, Word, Excel, images and text, including turning bank statements into spreadsheet rows.22AGPL 3.0
- AlicenseAqualityBmaintenanceGives AI assistants a full PDF toolkit — encrypting, decrypting, merging, splitting, reordering, rotating, optimizing, repairing, and converting PDFs through natural-language requests, with sandboxed file access and safe handling of damaged or password-protected files.51MIT