Skip to main content
Glama
pdf-toolbox-mcp

pdf-toolbox-mcp

by twoer

pdf-toolbox-mcp

中文文档 | Local-first PDF processing for AI agents.

Listed on mcpservers.org

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 list

  • Claude Desktop: uv run pdftoolbox client show claude-desktop

  • Cursor: uv run pdftoolbox client show cursor

  • Universal project .mcp.json: uv run pdftoolbox client show universal

  • Export all client files: uv run pdftoolbox client export

  • Detect the current client surface: uv run pdftoolbox client detect

  • Semi-auto install: uv run pdftoolbox client install or uv run pdftoolbox client install --scope auto

  • Import an existing Claude Desktop setup into Claude Code: uv run pdftoolbox client import-claude-desktop

  • Add --all only 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+eng

  • Unlock a file: uv run pdftoolbox unlock locked.pdf --password 'xxx'

MCP first task:

  1. Ask tool_doctor

  2. Then 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 ghostscript

  • Debian/Ubuntu: sudo apt install qpdf poppler-utils tesseract-ocr tesseract-ocr-chi-sim ghostscript

  • Windows: use the per-package commands in the table below

Level

Binary

Unlocks

macOS

Debian/Ubuntu

Windows

L0

qpdf

split / merge / rotate / unlock

brew install qpdf

apt install qpdf

choco/scoop install qpdf

L1

poppler

extract_text / render / info

brew install poppler

apt install poppler-utils

choco/scoop install poppler or conda-forge

L2

tesseract

ocr_pdf (write-back)

brew install tesseract tesseract-lang

apt install tesseract-ocr tesseract-ocr-chi-sim

choco/scoop install tesseract

L3

ghostscript

compress

brew install ghostscript

apt install ghostscript

scoop install ghostscript / winget install ArtifexSoftware.GhostScript

Windows note: Ghostscript's binary is gswin64c.exe there — the probe detects it automatically, so compress_pdf works out of the box. Tesseract language packs (e.g. chi_sim) must be downloaded to its tessdata folder 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_pdf decrypts 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

pdf_info

Pages, encryption status, metadata — always call first

pdfinfo

is_searchable

Smart routing: text density check → recommends extract_text or ocr_pdf

pdftotext

extract_text

Layout-aware text, exact page ranges 1-3,5, per-page mode

pdftotext

ocr_pdf

OCR write-back: scan → searchable PDF (deskew, skip/redo, lang fallback)

OCRmyPDF

batch_ocr

Whole-directory OCR with per-file results, retries, timeouts

OCRmyPDF

render_pages

PNG per page, return_images=true streams image blocks to the vision model

pdftoppm

extract_images

Pull embedded images (inventory or PNG files)

pdfimages

extract_attachments

Pull embedded attachment files

pdfdetach

list_fonts

Font audit — non-embedded fonts risk missing glyphs on other machines

pdffonts

unlock_pdf

Decrypt with user password, output a clean decrypted file; password sent via stdin

qpdf

protect_pdf

AES-256 + granular permissions (print/extract/modify/…)

pikepdf

split_pdf

By ranges or every N pages

qpdf

merge_pdfs

Ordered merge

qpdf

rotate_pages

90/180/270 on selected pages

qpdf

check_repair

Structural check; repair=true rebuilds damaged files

qpdf

linearize

Web-optimized progressive-loading output

qpdf

sanitize

Publishing hygiene: strip JS/OpenAction/metadata/attachments

pikepdf

redact

True redaction: affected pages rasterized + opaque boxes — redacted text physically unrecoverable, other pages keep their text layer (rasterize_all=true for max protection)

pdftoppm + PIL

redact_text

Redact by content: locate every occurrence of the given keywords and black them out — no manual coordinates needed

pdftotext -bbox

locate_text

Find where text occurs: page + bounding boxes (PDF points, top-left origin) — the foundation for redaction & highlighting

pdftotext -bbox

fill_form

Fill AcroForm fields (missing fields reported)

pikepdf

edit_metadata

Set/clear Title/Author/… (docinfo + XMP)

pikepdf

compress_pdf

Compress, optionally down a quality ladder until hitting target_mb

ghostscript

dependency_status

Probe system tools + install commands

—

doctor

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, and extract_attachments stage multi-file exports in a temporary directory and publish them only after all files are ready.

  • overwrite defaults to false; pass overwrite=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 pdftoolbox

1 · Scan → searchable PDF (the flagship)

“contract-scan.pdf is 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-3

2 · Encrypted PDF → readable

“locked.pdf is password-protected; the password is hunter2. 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 3

3 · Redact secrets before sharing

“Black out every occurrence of 张三 and HT-2026-088 in draft.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-088

More 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

PDF_TOOLBOX_TESS_LANG

chi_sim+eng

Default OCR languages; missing packs auto-fallback (flagged via lang_fallback)

PDF_TOOLBOX_WORKSPACE

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=true must 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 --json

Cross-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 tools
tool_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

    B3.4/5.0

    Scored across 25 tools

    Disambiguation4/5

    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.

    Naming Consistency4/5

    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.

    Tool Count3/5

    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.

    Completeness4/5

    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

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables 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
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables 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.
      4
      64 npm
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Lets 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.
      22
      AGPL 3.0
    • A
      license
      A
      quality
      B
      maintenance
      Gives 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.
      51
      MIT