Skip to main content
Glama

📄 MCP PDF

PDF処理のためのFastMCPサーバー

テキスト抽出、OCR、テーブル、フォーム、注釈、Markdown↔PDF変換など、47種類のツール

Python 3.11+ FastMCP License: MIT PyPI

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

ツール

コンテンツ抽出

ツール

機能

extract_text

PDFページからテキストを抽出(大きなファイル用に自動チャンク分割)

extract_tables

テーブルをJSON、CSV、またはMarkdownとして抽出

extract_images

埋め込み画像を抽出

extract_links

ページフィルタリング付きですべてのハイパーリンクを取得

ocr_pdf

Tesseractを使用してスキャン済みドキュメントをOCR処理

extract_vector_graphics

ベクターグラフィックスをSVGとしてエクスポート(回路図、チャート、図面)

フォーマット変換

ツール

機能

pdf_to_markdown

構造を保持したままPDFをMarkdownに変換。画像やSVGベクターをディスクに抽出

markdown_to_pdf

.mdファイル(またはインラインテキスト)をpandoc経由でPDFに変換(エンジン自動検出)

markdown_to_pdfの要件: pip install mcp-pdf[markdown] に加え、pandocバイナリと少なくとも1つのPDFエンジン(xelatexpdflatextectonicweasyprint、またはwkhtmltopdf)がPATH上にある必要があります。ツールは利用可能なものを自動検出し、最高品質のものを使用します。pdf_engine=で指定するか、extra_args=で生のpandocオプションを渡すことができます。

ドキュメント分析

ツール

機能

extract_metadata

タイトル、作成者、作成日、ページ数などを取得

get_document_structure

目次とブックマークを抽出

analyze_layout

列、ヘッダー、フッターを検出

is_scanned_pdf

PDFにOCRが必要か確認

compare_pdfs

テキスト、構造、またはメタデータで2つのPDFを比較

analyze_pdf_health

破損や最適化の可能性をチェック

analyze_pdf_security

暗号化、権限、署名をレポート

フォーム

ツール

機能

extract_form_data

フォームフィールド名と値を取得

fill_form_pdf

JSONからフォームフィールドに入力

create_form_pdf

テキストフィールド、チェックボックス、ドロップダウンを含む新しいフォームを作成

add_form_fields

既存のPDFにフィールドを追加

許可フォーム(座標ベース)

スキャンされたPDFやインタラクティブなフィールドがないフォーム用。座標(x, y)にテキストを描画します。

ツール

機能

fill_permit_form

座標を指定して描画することで任意のPDFに入力(スキャンされたフォームでも動作)

get_field_schema

検証やUI生成のためのフィールド定義を取得

validate_permit_form_data

入力前にフィールドスキーマに対してデータを検証

preview_field_positions

フィールド境界を示すPDFを生成(デバッグ用)

insert_attachment_pages

「Xページを参照」という参照付きの画像/テキストページを挿入

要件: pip install mcp-pdf[forms] (reportlab依存関係を追加)

ドキュメント構成

ツール

機能

merge_pdfs

ブックマークを保持したまま複数のPDFを結合

split_pdf_by_pages

ページ範囲で分割

split_pdf_by_bookmarks

章やセクションの境界で分割

reorder_pdf_pages

ページをカスタム順序で並べ替え

注釈

ツール

機能

add_sticky_notes

コメント注釈を追加

add_highlights

テキスト領域をハイライト

add_stamps

「承認済み」「ドラフト」「機密」などのスタンプを追加

extract_all_annotations

注釈をJSONとしてエクスポート


フォールバックの仕組み

サーバーは各操作に対して複数のライブラリを試行します:

テキスト抽出:

  1. PyMuPDF (最速)

  2. pdfplumber (複雑なレイアウトに最適)

  3. pypdf (最も互換性が高い)

テーブル抽出:

  1. Camelot (最高精度、Ghostscriptが必要)

  2. pdfplumber (依存関係なし)

  3. Tabula (Javaが必要)

あるライブラリでPDFの処理が失敗した場合、自動的に次が試行されます。


トークン管理

大きな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

tesseract-ocr

Camelotテーブル

ghostscript

Tabulaテーブル

default-jre-headless

PDFから画像へ

poppler-utils

markdown_to_pdf

pandoc + 次のいずれか: tectonic, texlive-xetex (+ texlive-latex-extra), weasyprint, wkhtmltopdf

markdown_to_pdf 用のPDFエンジンの選択

PandocはMarkdown → HTMLまたはLaTeX → PDFの変換を行います。LaTeXパスは最も洗練された出力を生成しますが、TeXのインストールが必要です。トレードオフは以下の通りです:

エンジン

ディスクサイズ

メモ

tectonic

~30 MB

新規インストールに推奨。 単一の静的バイナリ。LaTeXパッケージをオンデマンドでダウンロードするため、事前の大量インストールが不要。

xelatex + texlive-latex-extra

~500 MB

インストール後の出力は最高。すでにTeXを使用している場合に推奨。-extraパッケージが重要です:pandocのデフォルトテンプレートは lastpage, xcolor, framed, fancyhdr などが必要ですが、これらは texlive-xetex ではなく texlive-latex-extra に含まれています。

xelatex 単体 (texlive-xetex のみ)

~200 MB

頻繁に失敗します。 実際のドキュメントで ! LaTeX Error: File 'X.sty' not found が発生する可能性があります。

weasyprint

~40 MB

純粋なPython (pip install weasyprint) + cairo/pangoシステムライブラリ。HTML/CSSパスを使用し、LaTeXは不要。単純なドキュメントには適していますが、数式、脚注、引用には弱いです。

wkhtmltopdf

~40 MB

古いHTML-to-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 weasyprint

Arch 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-static

macOS (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

オプションのエクストラ

ベースインストールは軽量に保たれています。重い、またはニッチな依存関係はエクストラとして分離されています:

エクストラ

追加内容

インストール時期

mcp-pdf[forms]

reportlab

フォーム作成ツール (create_form_pdf, 許可フォーム)

mcp-pdf[tables]

camelot-py, tabula-py

高精度なテーブル抽出(Java + Ghostscriptも必要)

mcp-pdf[markdown]

pypandoc

markdown_to_pdf ツール(pandocバイナリも必要)

mcp-pdf[all]

上記すべて

すべての機能が必要な場合


設定

オプションの環境変数:

変数

目的

MCP_PDF_ALLOWED_PATHS

ファイル出力用のコロン区切りディレクトリ

PDF_TEMP_DIR

処理用の一時ディレクトリ (デフォルト: /tmp/mcp-pdf-processing)

TESSDATA_PREFIX

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

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides 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
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI applications to read and process PDF files with intelligent file search, text extraction, image processing, and optional OCR support for scanned documents.
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

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