pdf-mcp — 巨大 PDF を AI に読ませる Python 製ハブ(テキスト・表・OCR・セマンティック検索)
jztan 氏が公開する PDF 処理特化の MCP サーバー。PyMuPDF ベースで PDF からテキスト・表・画像を抽出、Tesseract OCR にも対応、SQLite キャッシュで再読込を高速化。`pdf-mcp[semantic]` でハイブリッド検索(BM25+ベクトル)にも拡張可能。
- 最終確認:
- 2026-05-13
- ライセンス:
- MIT
設定方法
{
"mcpServers": {
"pdf": {
"command": "uvx",
"args": ["pdf-mcp"]
}
}
}
{
"mcpServers": {
"pdf": {
"command": "uvx",
"args": ["pdf-mcp"]
}
}
}
{
"mcpServers": {
"pdf": {
"command": "uvx",
"args": ["pdf-mcp"]
}
}
}
概要
pdf-mcp は jztan 氏が公開する PDF 処理特化の MCP サーバーです(PyPI: pdf-mcp / GitHub: jztan/pdf-mcp / MIT ライセンス / 2026-05-12 v1.12.1 / Python 3.10+)。
PyMuPDF をエンジンとして、AI が 大きな PDF をコンテキスト溢れなく扱えるように設計されています。文書情報の取得(メタデータ / トークン推定 / OCR 候補判定)、ページ範囲指定の読み取り、表構造の抽出、画像レンダリング、ハイブリッド検索(BM25 + セマンティック)まで、PDF 周りの処理を1つの MCP で完結できます。
SQLite キャッシュで一度処理した PDF は高速に再アクセス可能。OCR や セマンティック検索はオプショナル拡張のため、軽量起動も可能です。
導入手順
前提条件
- uv または Python 3.10+
- (任意)Tesseract — OCR を使う場合のみ・システムレベルでインストール
- macOS:
brew install tesseract - Linux:
sudo apt-get install tesseract-ocr - Windows: UB-Mannheim 公式インストーラ
- macOS:
- (任意)日本語 OCR を使う場合は
tesseract-ocr-jpn言語パック
ステップ
- ページ上部のタブから使用環境(Claude Desktop / Cursor / Cline)を選択し、JSON 設定をコピー
- コピーした JSON を設定ファイルに追記して保存
- クライアントを再起動
uvx pdf-mcp が初回実行時に PyPI からパッケージを取得・起動します。
セマンティック検索を使う場合
uvx pdf-mcp[semantic]
または手動で pip install 'pdf-mcp[semantic]'。約67MB の fastembed + numpy が追加されます。
使い方の例
「report.pdf の中で『売上』に関する箇所だけ集めて要約して」
→ pdf_search → pdf_read_pages の連携で関連ページのみ抽出
「scanned_invoice.pdf (スキャン画像PDF)から日付・金額・取引先を抽出して」
→ pdf_read_pages の OCR 機能で画像 PDF をテキスト化
「論文の章立てを教えて、その上で第3章だけ詳しく読んで」
→ pdf_get_toc で目次取得 → 該当ページ範囲を pdf_read_pages
提供されるツール
公式リポジトリの src/pdf_mcp/server.py 内 @mcp.tool() デコレータから逐語抽出した 8 ツール(docstring の冒頭は実装の文言そのまま):
読み取り系
pdf_info— "Get PDF document information including metadata, page count, and table of contents. Always call this first to understand the document structure before reading content."pdf_read_pages— "Read text content and images from specific pages of a PDF. Use page ranges to control how much content is loaded."pdf_read_all— "Read the entire PDF document. Warning: Only use for small documents. For large documents, use pdf_read_pages with specific page ranges."pdf_render_pages— "Render PDF pages as images for visual inspection by vision-capable models. Use when you need to see page content directly."
検索・構造
pdf_search— "Search for text within a PDF document. Use this to find relevant pages before reading full content. Much more efficient than loading the entire document."(pdf-mcp[semantic]拡張で BM25 + ベクトルのハイブリッド RRF 検索に発展可能)pdf_get_toc— "Get the table of contents (bookmarks/outline) from a PDF. Useful for understanding document structure and navigating to specific sections."
キャッシュ管理
pdf_cache_stats— "Get PDF cache statistics and optionally clear expired entries."pdf_cache_clear— "Clear the PDF cache."
注意事項
- Python 3.10+ が必要です。
- OCR 機能はオプショナルです。スキャン PDF を扱わない場合は Tesseract のインストール不要で軽量に起動できます。
- 環境変数
PDF_MCP_CACHE_DIR(デフォルト~/.cache/pdf-mcp)とPDF_MCP_CACHE_TTL(デフォルト 24時間)でキャッシュ挙動を制御可能。 - 表抽出(pdf_read_pages の table extraction)は構造化データ(header + rows)として返されます。
- 日本語 PDF(テキスト埋め込み済み)は PyMuPDF が直接読み取りますが、スキャン画像 PDF を日本語 OCR するには Tesseract に
jpn.traineddataを追加してください。
主なユースケース
- 「この300ページの仕様書 PDF から API エンドポイントだけ抜き出して表にして」と頼み、`pdf_search` + `pdf_read_pages` で必要箇所のみ抽出
- 「スキャン PDF の領収書から日付・金額・取引先を抽出して」と頼み、`pdf_read_pages` の OCR 機能で画像化された PDF からテキスト化
- 「論文 PDF の目次から第3章だけ読んで要約して」と頼み、`pdf_get_toc` + `pdf_read_pages` で章単位アクセス
- 「この技術書の中で `transformer` の章を探して」と頼み、`pdf-mcp[semantic]` 拡張でハイブリッド検索(BM25 + ベクトル)
- 繰り返し参照する PDF を SQLite キャッシュで高速再読込(`pdf_cache_stats` でキャッシュ状況確認)
プラットフォーム別の注意事項
- Windows:PowerShellからの `uvx` 実行に追加設定は不要です。OCR を使う場合は別途 Tesseract(システムレベル)のインストールが必要です([公式インストーラ](https://github.com/UB-Mannheim/tesseract/wiki))。
- :OCR 機能はオプショナルでシステム Tesseract が必要。日本語 PDF を OCR したい場合は `tesseract-ocr-jpn` 言語パックを併せてインストールしてください(README には逐語記載なし / Tesseract の標準フローに準拠)。
- :ハイブリッド検索を使うなら `pdf-mcp[semantic]` 拡張をインストール(fastembed + numpy 約67MB)。