MCP PDF
📄 MCP PDF
用于 PDF 处理的 FastMCP 服务器
47 种工具,支持文本提取、OCR、表格、表单、注释、Markdown↔PDF 转换等
可与 MCP Office Tools 完美配合使用
功能概述
MCP PDF 通过多种库自动回退机制从 PDF 中提取内容。如果一种方法失败,它会自动尝试另一种。
核心能力:
文本提取:通过 PyMuPDF、pdfplumber 或 pypdf(自动回退)
表格提取:通过 Camelot、pdfplumber 或 Tabula(自动回退)
OCR:通过 Tesseract 处理扫描文档
表单处理 - 提取、填写和创建 PDF 表单
文档组装 - 合并、拆分、重排页面
注释 - 便签、高亮、印章
矢量图形 - 提取为 SVG 以用于原理图和技术绘图
格式转换 - PDF ↔ Markdown(PDF→MD 通过 PyMuPDF,MD→PDF 通过 pandoc)
Related MCP server: PDF MCP Flow
快速开始
# Run from PyPI (one-shot, no permanent install)
uvx mcp-pdf
# Add to Claude Code — note the `--` separator before uvx
claude mcp add pdf-tools -- uvx mcp-pdf
# Include the markdown_to_pdf tool (requires pandoc on host)
claude mcp add pdf-tools -- uvx --from "mcp-pdf[markdown]" mcp-pdf
uvx会积极缓存工具安装。升级到新版本后,请使用uvx --refresh mcp-pdf强制刷新(如果使用了扩展功能,请使用uvx --refresh --from "mcp-pdf[markdown]" mcp-pdf)。
git clone https://github.com/rsp2k/mcp-pdf
cd mcp-pdf
uv sync
# System dependencies (Ubuntu/Debian)
sudo apt-get install tesseract-ocr tesseract-ocr-eng poppler-utils ghostscript
# For markdown_to_pdf — pick one PDF-engine route:
sudo apt-get install pandoc tectonic # recommended (small)
# or: sudo apt-get install pandoc texlive-xetex texlive-latex-extra # full TeX
# or: sudo apt-get install pandoc && pip install weasyprint # skip TeX
# Verify
uv run python examples/verify_installation.py工具
内容提取
工具 | 功能 |
| 从 PDF 页面提取文本,支持大文件自动分块 |
| 将表格提取为 JSON、CSV 或 Markdown |
| 提取嵌入的图像 |
| 获取所有超链接,支持页面过滤 |
| 使用 Tesseract 对扫描文档进行 OCR |
| 将矢量图形导出为 SVG(原理图、图表、绘图) |
格式转换
工具 | 功能 |
| 将 PDF 转换为 Markdown 并保留结构;将图像和 SVG 矢量图提取到磁盘 |
| 通过 pandoc 将 |
markdown_to_pdf 要求: pip install mcp-pdf[markdown] 以及 pandoc 二进制文件和至少一个 PDF 引擎(xelatex、pdflatex、tectonic、weasyprint 或 wkhtmltopdf)在 PATH 中。该工具会自动检测可用引擎并使用质量最高的一个。传入 pdf_engine= 可覆盖默认设置,或使用 extra_args= 传入原始 pandoc 参数。
文档分析
工具 | 功能 |
| 获取标题、作者、创建日期、页数等 |
| 提取目录和书签 |
| 检测列、页眉、页脚 |
| 检查 PDF 是否需要 OCR |
| 通过文本、结构或元数据对比两个 PDF |
| 检查损坏情况及优化机会 |
| 报告加密、权限、签名情况 |
表单
工具 | 功能 |
| 获取表单字段名称和值 |
| 从 JSON 填充表单字段 |
| 创建带有文本字段、复选框、下拉菜单的新表单 |
| 向现有 PDF 添加字段 |
许可表单(基于坐标)
适用于扫描版 PDF 或没有交互式字段的表单。在 (x, y) 坐标处绘制文本。
工具 | 功能 |
| 通过在坐标处绘制内容来填充任何 PDF(适用于扫描表单) |
| 获取字段定义以进行验证或 UI 生成 |
| 在填充前根据字段模式验证数据 |
| 生成显示字段边界的 PDF(用于调试) |
| 插入带有“见第 X 页”引用的图像/文本页面 |
要求: pip install mcp-pdf[forms](添加 reportlab 依赖)
文档组装
工具 | 功能 |
| 合并多个 PDF 并保留书签 |
| 按页面范围拆分 |
| 按章节/部分边界拆分 |
| 按自定义顺序重排页面 |
注释
工具 | 功能 |
| 添加评论注释 |
| 高亮文本区域 |
| 添加“已批准/草稿/机密”印章 |
| 将注释导出为 JSON |
回退机制的工作原理
服务器为每个操作尝试多个库:
文本提取:
PyMuPDF(最快)
pdfplumber(更适合复杂布局)
pypdf(兼容性最好)
表格提取:
Camelot(精度最高,需要 Ghostscript)
pdfplumber(无依赖)
Tabula(需要 Java)
如果 PDF 在一个库中处理失败,会自动尝试下一个。
Token 管理
大型 PDF 可能会超出 MCP 响应限制。服务器处理方式如下:
自动分块:将大型文档拆分为页面组
表格行限制:防止超大表格导致响应溢出
摘要模式:返回结构而不返回完整内容
# Get first 10 pages
result = await extract_text("huge.pdf", pages="1-10")
# Limit table rows
tables = await extract_tables("data.pdf", max_rows_per_table=50)
# Structure only
tables = await extract_tables("data.pdf", summary_only=True)URL 处理
PDF 可以直接从 HTTPS URL 获取:
result = await extract_text("https://example.com/report.pdf")文件会在本地缓存以供后续操作使用。
系统依赖
某些功能需要系统包:
功能 | 依赖 |
OCR |
|
Camelot 表格 |
|
Tabula 表格 |
|
PDF 转图像 |
|
|
|
为 markdown_to_pdf 选择 PDF 引擎
Pandoc 将 Markdown → HTML 或 LaTeX → PDF。LaTeX 路径生成的输出最精美,但需要 TeX 安装。权衡如下:
引擎 | 磁盘占用 | 说明 |
| ~30 MB | 推荐用于新安装。 单个静态二进制文件。按需下载 LaTeX 包 — 无需预先安装大量内容。 |
| ~500 MB | 安装后效果最好。如果您已经运行 TeX,请使用此项。 |
| ~200 MB | 经常出错。 在真实文档上可能会遇到 |
| ~40 MB | 纯 Python ( |
| ~40 MB | 较旧的 HTML 转 PDF 工具。可用但维护较少。 |
Ubuntu/Debian:
sudo apt-get install tesseract-ocr tesseract-ocr-eng poppler-utils ghostscript default-jre-headless
# For markdown_to_pdf — pick one engine route:
# Option A — tectonic (smallest, downloads packages on demand)
sudo apt-get install pandoc
# tectonic isn't in apt — install via cargo or download static binary:
# https://tectonic-typesetting.github.io/en-US/install.html
# Option B — full TeX (best quality, large download)
sudo apt-get install pandoc texlive-xetex texlive-latex-extra texlive-fonts-extra
# Option C — weasyprint (skip TeX entirely)
sudo apt-get install pandoc
pip install weasyprintArch Linux:
sudo pacman -S tesseract tesseract-data-eng poppler ghostscript jre-openjdk-headless
# For markdown_to_pdf — pick one engine route:
# Option A — tectonic (recommended for new installs, in official repo)
sudo pacman -S pandoc tectonic
# Option B — full TeX (best output, ~500 MB)
sudo pacman -S pandoc texlive-xetex texlive-latexextra texlive-fontsextra
# Option C — weasyprint (skip TeX)
sudo pacman -S pandoc
pip install weasyprint # or: uv pip install weasyprint
# Option D — wkhtmltopdf (from AUR)
yay -S wkhtmltopdf-staticmacOS (Homebrew):
brew install tesseract poppler ghostscript
# For markdown_to_pdf — pick one engine route:
# Option A — tectonic (recommended)
brew install pandoc tectonic
# Option B — full TeX (mactex-no-gui includes the latex-extra equivalent)
brew install pandoc
brew install --cask mactex-no-gui
# Option C — weasyprint
brew install pandoc weasyprint可选扩展
基础安装保持精简。繁重或小众的依赖项被放在扩展中:
扩展 | 添加内容 | 何时安装 |
|
| 表单创建工具 ( |
|
| 高精度表格提取(还需要 Java + Ghostscript) |
|
|
|
| 以上所有 | 需要全部功能 |
配置
可选环境变量:
变量 | 用途 |
| 用于文件输出的冒号分隔目录 |
| 处理时的临时目录(默认: |
| Tesseract 语言数据位置 |
开发
# Run tests
uv run pytest
# With coverage
uv run pytest --cov=mcp_pdf
# Format
uv run black src/ tests/
# Lint
uv run ruff check src/ tests/许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive PDF processing including text extraction, image extraction, and OCR capabilities for reading text within images across multiple languages.12MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI-driven PDF document processing including PDF to Markdown conversion, intelligent text and table extraction, image extraction, format conversion between PDF/Word/Markdown, batch processing, and fuzzy search - optimized for LLM context and RAG workflows.2MIT
- AlicenseNot gradedqualityDmaintenanceProvides intelligent OCR and PDF processing capabilities that automatically detect whether PDFs contain digital text or scanned images and apply appropriate extraction methods. Supports text extraction, OCR processing, structure analysis, and batch operations.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI applications to read and process PDF files with intelligent file search, text extraction, image processing, and optional OCR support for scanned documents.MIT
Related MCP Connectors
Turn any PDF into structured JSON via AI + OCR: invoices, bank statements, contracts.
PDF accessibility checks (veraPDF PDF/UA-1), auto-fix and Markdown conversion. EU-hosted.
Convert PDF bank statements into structured transactions, accounts, and balances.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rsp2k/mcp-pdf'
If you have feedback or need assistance with the MCP directory API, please join our Discord server