PDF-MCP
This server lets you inspect, search, compare, and generate PDF documents through MCP tools.
Extract readable text from PDFs, optionally limited to a page range.
Retrieve PDF metadata such as page count, file size, title, author, and encryption status.
Batch-search PDFs in a directory using keywords or regex patterns.
Compare two PDFs page by page to find text differences and page-count mismatches.
Generate styled PDF reports from structured JSON or external JSON/Markdown input files.
Compile Markdown files or raw Markdown into publication-grade PDFs with YAML frontmatter, sections, Q&A cards, tables, callouts, code blocks, images, bullets, and LaTeX math support.
Apply themes such as navy_blue, emerald, and slate, with Unicode/Turkish text support.
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-MCP extract the text from pages 1-5 of Q4_report.pdf"
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-MCP (v1.2.0): Model Context Protocol (MCP) Server & CLI Toolkit
🌐 🇬🇧 English Documentation | 🇹🇷 Türkçe Dokümantasyon
🇬🇧 English Documentation
PDF-MCP is a lightweight, high-performance Model Context Protocol (MCP) server and command-line (CLI) toolkit designed for AI coding assistants (Google Antigravity, Claude Desktop, Cursor) and developers.
It empowers AI agents to natively inspect, batch-search, and diff PDF documents, as well as compile publication-grade A4 PDF reports directly from Markdown (.md) or structured JSON—complete with cover pages, Q&A cards, LaTeX mathematical equations, code blocks, zebra-striped tables, callout alerts, embedded diagrams, and full UTF-8/Unicode typography support—without writing intermediate dump scripts.
🆕 What's New in v1.2.0
📐 Native LaTeX Math & Equation Rendering (
math): High-resolution 300 DPI mathematical typography rendered viamatplotlib.mathtextwithout requiring external TeX distributions (TeX Live/MiKTeX). Supports block formulas ($$...$$,\[...\],```math) into styled cards with labels/captions, plus automatic inline math conversion ($E=mc^2$,\alpha,\sum,\int,\frac{a}{b}) into clean Unicode typography.🛡️ Bulletproof Box Overflow & Overlap Prevention: Replaced naive line estimation with exact dynamic measurement (
multi_cell(..., dry_run=True, output=MethodReturnValue.HEIGHT)). Callouts, Q&A cards, and cover descriptions dynamically expand to fit text perfectly, eliminating content truncation and text collisions.📜 Smart Code Block Wrapping & Pagination: Long code lines soft-wrap cleanly with indentation without clipping margins; multi-page code blocks gracefully split across page boundaries with individual boxed containers.
📝 Markdown-First PDF Compiler (
pdf_from_markdown): Pass a standard Markdown file or string; the engine automatically compiles YAML frontmatter,#sections,##Q&A cards, LaTeX equations, fenced code blocks, Markdown tables,> [!NOTE]callouts, andfigures into a styled PDF.📊 Native Styled Table Engine (
table): Automatic column sizing, primary-colored headers, and alternating row backgrounds (zebra striping).💡 Rich Alert / Callout Boxes (
callout): Left-accented callout panels forNOTE,TIP,WARNING,IMPORTANT, andCAUTION.🖼️ Smart Image & Diagram Embedding (
image): Aspect-ratio preserving centered image rendering with italic captions and graceful fallback placeholders if an image path is missing.📂 Direct File Input (
input_file): Pass a disk path (.mdor.json) topdf_generate_reportinstead of serializing 100KB+ payloads into the LLM context window.
Related MCP server: MokuPDF
✨ Core Tools & Capabilities
Tool Name | Description |
| Compiles a |
| Builds a styled PDF from structured JSON data or an external |
| Extracts clean text from an entire PDF or specific page ranges ( |
| Rapidly searches across dozens of PDFs in a directory ( |
| Retrieves total page count, file size, title, author, and encryption status. |
| Compares two PDF files page-by-page to pinpoint textual differences. |
Full Unicode & Math | Native TrueType font support ( |
🚀 Quick Start & Installation (EN)
1. Install Dependencies
PDF-MCP requires lightweight, zero-system-overhead Python packages (pypdf, fpdf2, matplotlib):
git clone https://github.com/your-username/pdf-mcp.git
cd pdf-mcp
pip install -r requirements.txt(Optional) Install in editable mode for global pdf-mcp CLI access:
pip install -e .2. MCP Server Configuration
Google Antigravity (~/.gemini/config/mcp_config.json)
{
"mcpServers": {
"pdf-toolkit": {
"command": "python",
"args": [
"C:/path/to/pdf-mcp/pdf_mcp/server.py"
],
"disabled": false
}
}
}Claude Desktop / Cursor (claude_desktop_config.json)
{
"mcpServers": {
"pdf-toolkit": {
"command": "python",
"args": [
"C:/path/to/pdf-mcp/pdf_mcp/server.py"
]
}
}
}⚡ Instant Usage Guide (Markdown → PDF)
Scenario: Compile Markdown to PDF in One Step (Recommended)
Create a .md file with optional YAML frontmatter to configure the cover page and theme (navy_blue, emerald, slate):
---
title: CLOUD INFRASTRUCTURE AUDIT REPORT
subtitle: Q4 Security, Latency & Scalability Review
category: TECHNICAL REPORT
description: Comprehensive architectural evaluation of distributed API services and storage layers.
theme: navy_blue
Prepared By: Platform Engineering Team
Author: Alex Rivera
Date: 2026
---
# SECTION 1: SERVICE ARCHITECTURE & LATENCY
## Question 1.1: How does edge caching impact P99 response times?
Deploying regional edge caches reduces round-trip latency by serving static and pre-computed payloads directly from points of presence closest to the client.
> [!IMPORTANT] Rate Limiting Policy
> All public endpoints must enforce token-bucket rate limiting at the API Gateway layer prior to production rollout.
- **Edge Gateway:** Handles TLS termination and request routing.
- **Worker Pool:** Processes asynchronous background jobs with automatic retry policies.
```sql
SELECT service_name, AVG(latency_ms) AS avg_latency
FROM telemetry_logs
WHERE status_code = 200
GROUP BY service_name;
```
| Service ID | Component Name | Uptime SLA |
| :--- | :--- | :--- |
| SVC-101 | Auth Gateway | 99.99% |
| SVC-204 | Billing Engine | 99.95% |
Invoke via MCP Tool (pdf_from_markdown):
{
"output_path": "C:/path/to/Output_Report.pdf",
"markdown_file": "C:/path/to/draft.md"
}Markdown-to-PDF Syntax Mapping
Markdown Syntax | Rendered PDF Component |
| Cover page title, subtitle, abstract box, color theme, and bottom metadata key-values |
| Full-width colored Section Header banner ( |
| Clean bold Subheading ( |
| Left-accented shaded Q&A Card ( |
| Standalone high-res LaTeX Mathematical Equation Card ( |
| In-line smooth Unicode mathematical typography (Greek letters, symbols, roots, fractions) |
| Shaded monospace Code Block with long-line soft-wrap ( |
| Zebra-striped Table with primary-colored header ( |
| Dynamic-height Styled Callout / Alert Box without overflow ( |
| Centered auto-scaled Image with italic caption ( |
| Bold-prefixed Bullet Point ( |
💻 CLI Usage (EN)
# 1. Compile a Markdown file into a styled PDF (with emerald theme)
python pdf_mcp/cli.py from-md "notes.md" "Output.pdf" --theme emerald
# 2. Generate a PDF from a structured JSON file
python pdf_mcp/cli.py generate "payload.json" "Report.pdf"
# 3. Extract text from specific pages (pages 1 to 3)
python pdf_mcp/cli.py read "manual.pdf" --start 1 --end 3
# 4. Batch-search across all PDFs in a folder
python pdf_mcp/cli.py search "./docs" --pattern "*.pdf" -q "latency"
# 5. Inspect PDF metadata
python pdf_mcp/cli.py meta "document.pdf"
# 6. Compare two PDF files page by page
python pdf_mcp/cli.py diff "v1.pdf" "v2.pdf"🐍 Python API Usage (EN)
from pdf_mcp import build_pdf_from_markdown, PDFReportBuilder
# Option 1: One-Line Markdown Compilation
build_pdf_from_markdown(
output_path="Quick_Report.pdf",
markdown_file="draft.md",
theme="navy_blue"
)
# Option 2: Programmatic Builder API
builder = PDFReportBuilder(header_title="Architecture Report", theme_name="slate")
builder.draw_cover(
title="SYSTEM ARCHITECTURE REPORT",
subtitle="Performance & Throughput Benchmarks",
category="ENGINEERING",
description="Comparative analysis of distributed caching and message queue throughput.",
metadata={"Author": "Alex Rivera", "Version": "1.1.0"}
)
builder.add_page()
builder.add_section_header("1. BENCHMARK SUMMARY", "Throughput Under Load")
builder.add_math(r"\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}", caption="Gaussian Integral", label="1.1")
builder.add_table(
headers=["Engine", "Read Latency", "Write Throughput"],
rows=[
["In-Memory Cache", "0.4 ms", "120,000 ops/sec"],
["Distributed Store", "2.1 ms", "45,000 ops/sec"]
]
)
builder.add_callout("Enable connection pooling to prevent socket exhaustion under peak load.", kind="tip")
builder.add_image("diagram.png", caption="Figure 1: Cluster Replication Flow")
builder.output("Architecture_Report.pdf")🇹🇷 Türkçe Dokümantasyon
PDF-MCP, yapay zeka kodlama asistanları (Google Antigravity, Claude Desktop, Cursor) ve geliştiriciler için tasarlanmış hafif, yüksek performanslı bir Model Context Protocol (MCP) sunucusu ve komut satırı (CLI) araç setidir.
Ajanların PDF belgelerini okumasına, onlarca doküman içinde toplu arama yapmasına, iki PDF'i karşılaştırmasına ve hiçbir ara JSON dönüştürücü script yazmaya gerek kalmadan doğrudan Markdown (.md) veya JSON üzerinden yayın kalitesinde A4 PDF raporlar üretmesine olanak tanır.
🆕 v1.2.0 ile Gelen Yenilikler
📐 Yerleşik LaTeX Matematik ve Denklem Motoru (
math): Harici bir TeX dağıtımına (TeX Live/MiKTeX) ihtiyaç duymadanmatplotlib.mathtextile 300 DPI çözünürlükte matematiksel formül render desteği. Blok denklemleri ($$...$$,\[...\],```math) şık denklem kartlarına çevirir; satır içi matematik ifadelerini ($E=mc^2$,\alpha,\sum,\int,\frac{a}{b}) pürüzsüz Unicode karakterlere dönüştürür.🛡️ Kutu Taşma ve Üst Üste Binme (Overlap) Çözümü: Kaba satır tahminleri kaldırılarak
fpdf2'ninmulti_cell(..., dry_run=True, output=MethodReturnValue.HEIGHT)özelliğiyle piksel hassasiyetinde dinamik yükseklik ölçümüne geçildi. Çağrı kutuları (callout), soru-cevap kartları ve kapak özetleri metnin gerçek boyutuna göre esner; metin taşması veya bir sonraki paragrafın üstüne binme sorunları tamamen ortadan kaldırıldı.📜 Kod Bloklarında Akıllı Satır Kaydırma ve Sayfalama: 162 mm'yi aşan uzun kod satırları marjinden taşmayacak şekilde girintili olarak yumuşak sarılır (soft-wrap); sayfaları aşan kod blokları sayfa kırılımlarında parçalı çerçevelerle bölünür.
📝 Markdown-First PDF Derleyici (
pdf_from_markdown): Ajan veya kullanıcı standart bir Markdown metni/dosyası verir; sistem otomatik olarak kapak sayfası, bölüm başlıkları, soru-cevap kartları, LaTeX denklemleri, kod blokları, tablolar, uyarı kutuları ve görseller içeren şık bir PDF üretir.📊 Yerleşik Stilize Tablo Motoru (
table): Tema renkli başlık satırı, zebra desenli (alternatif satır dolgulu) ve otomatik metin kaydırmalı tablolar.💡 Renkli Uyarı / Bilgi Panelleri (
callout):NOTE,TIP,WARNING,IMPORTANT,CAUTIONtiplerinde sol kenarı renk şeritli vurgu kutuları.🖼️ Akıllı Görsel ve Diyagram Gömme (
image): En-boy oranını (aspect ratio) koruyarak ortalanmış resim/diyagram ekleme, alt yazı (caption) desteği ve eksik görsellerde çökmeyi önleyen hata toleranslı yer tutucu (fallback).📂 Dosya Yolu Desteği (
input_file): Büyük raporlarda 100 KB+ veriyi sohbet bağlamına (context) basmak yerine doğrudan diskteki.mdveya.jsondosya yolunu vererek tek adımda derleme.
✨ Temel Özellikler
Özellik / Araç | Açıklama |
|
|
| Yapılandırılmış JSON verisinden veya harici |
| Tam belgeyi veya belirli sayfa aralıklarını ( |
| Bir klasördeki onlarca PDF içinde ( |
| Sayfa sayısı, dosya boyutu, başlık, yazar ve şifreleme durumunu döndürür. |
| İki PDF dosyasını sayfa sayfa karşılaştırarak metin farklarını tespit eder. |
Tam Türkçe ve Matematik |
|
🚀 Hızlı Kurulum (TR)
1. Gereksinimlerin Kurulması
Proje hafif ve sistem bağımsız kütüphanelere (pypdf, fpdf2, matplotlib) ihtiyaç duyar:
git clone https://github.com/your-username/pdf-mcp.git
cd pdf-mcp
pip install -r requirements.txt(İsteğe Bağlı) Terminalden her yerden pdf-mcp komutuyla erişmek için düzenlenebilir modda kurun:
pip install -e .2. MCP Sunucu Kurulumu
Google Antigravity (~/.gemini/config/mcp_config.json)
{
"mcpServers": {
"pdf-toolkit": {
"command": "python",
"args": [
"C:/path/to/pdf-mcp/pdf_mcp/server.py"
],
"disabled": false
}
}
}Claude Desktop / Cursor (claude_desktop_config.json)
{
"mcpServers": {
"pdf-toolkit": {
"command": "python",
"args": [
"C:/path/to/pdf-mcp/pdf_mcp/server.py"
]
}
}
}⚡ Anlık Kullanım Rehberi (Markdown → PDF)
Senaryo: Markdown Dosyasından Tek Adımda PDF Üretimi (Tavsiye Edilen)
Herhangi bir .md dosyası oluşturun. YAML başlığı (frontmatter) ile kapak bilgilerini ve temayı (navy_blue, emerald, slate) belirleyebilirsiniz:
---
title: BULUT ALTYAPI VE PERFORMANS RAPORU
subtitle: 4. Çeyrek Güvenlik, Gecikme ve Ölçeklenebilirlik Analizi
category: TEKNİK RAPOR
description: Dağıtık mikroservislerin ve depolama katmanlarının kapsamlı mimari değerlendirmesi.
theme: navy_blue
Birim: Platform Mühendisliği Ekibi
Hazırlayan: Deniz Yılmaz
Tarih: 2026
---
# BÖLÜM 1: SERVİS MİMARİSİ VE GECİKME ANALİZİ
## Soru 1.1: Uç önbellekleme (Edge Caching) yanıt sürelerini nasıl etkiler?
Bölgesel önbellek sunucuları, statik ve sık erişilen verileri istemciye en yakın noktadan sunarak ağ gecikmesini minimuma indirir.
> [!IMPORTANT] Hız Sınırlandırma (Rate Limiting) Kuralı
> Tüm dışa açık API uç noktalarında üretim ortamına geçilmeden önce API Gateway katmanında istek sınırlandırma aktif edilmelidir.
- **API Geçidi:** TLS sonlandırma ve yük dengeleme işlemlerini yürütür.
- **İşçi Havuzu (Worker Pool):** Asenkron arka plan görevlerini otomatik yeniden deneme mekanizmasıyla işler.
```sql
SELECT servis_adi, AVG(gecikme_ms) AS ortalama_gecikme
FROM sistem_kayitlari
WHERE durum_kodu = 200
GROUP BY servis_adi;
```
| Servis Kodu | Bileşen Adı | Çalışma Süresi (SLA) |
| :--- | :--- | :--- |
| SRV-101 | Kimlik Doğrulama Geçidi | 99.99% |
| SRV-204 | Ödeme Motoru | 99.95% |
MCP Aracı İle Çağrımı (pdf_from_markdown):
{
"output_path": "C:/path/to/Cikti_Raporu.pdf",
"markdown_file": "C:/path/to/rapor_taslagi.md"
}Markdown Sözdizimi Eşleme Tablosu
Markdown İfadesi | PDF Çıktısındaki Karşılığı |
| Kapak sayfası başlığı, alt başlığı, özet kutusu, tema ve alt bilgi metaverileri |
| Tam genişlikte renkli Bölüm Başlığı ( |
| Vurgulu, temiz Alt Başlık ( |
| Sol şeritli, gölgeli Soru-Cevap Kartı ( |
| Yüksek çözünürlüklü LaTeX Matematik Denklem Kartı ( |
| Paragraf içi pürüzsüz Unicode matematik tipografisi (Yunan harfleri, semboller, kesirler) |
| Monospace fontlu, uzun satır kaydırmalı (soft-wrap) Kod Bloğu ( |
| Zebra desenli, renkli başlıklı Tablo ( |
| Dinamik yükseklikli, taşma korumalı Renkli Uyarı / Bilgi Paneli ( |
| Ortalanmış, ölçeklenmiş Görsel ve İtalik Alt Yazı ( |
| Kalın başlıklı Madde İmi ( |
💻 Komut Satırı (CLI) Kullanımı (TR)
# 1. Markdown dosyasını PDF'e derle (Zümrüt Yeşili tema ile)
python pdf_mcp/cli.py from-md "notlar.md" "Cikti.pdf" --theme emerald
# 2. JSON payload dosyasından PDF üret
python pdf_mcp/cli.py generate "payload.json" "Rapor.pdf"
# 3. PDF'ten belirli sayfa aralığını oku (1-3. sayfalar)
python pdf_mcp/cli.py read "kilavuz.pdf" --start 1 --end 3
# 4. Klasördeki tüm PDF belgelerinde kelime ara
python pdf_mcp/cli.py search "./Belgeler" --pattern "*.pdf" -q "performans"
# 5. PDF teknik bilgilerini görüntüle
python pdf_mcp/cli.py meta "dokuman.pdf"
# 6. İki PDF dosyasını karşılaştır
python pdf_mcp/cli.py diff "v1.pdf" "v2.pdf"🐍 Python API Kullanımı (TR)
from pdf_mcp import build_pdf_from_markdown, PDFReportBuilder
# Yöntem 1: Doğrudan Markdown'dan PDF Üretimi
build_pdf_from_markdown(
output_path="Hizli_Rapor.pdf",
markdown_file="taslak.md",
theme="navy_blue"
)
# Yöntem 2: Programatik Builder API
builder = PDFReportBuilder(header_title="Teknik Rapor", theme_name="slate")
builder.draw_cover(
title="SİSTEM MİMARİSİ RAPORU",
subtitle="Performans ve Yük Testi Analizi",
category="MÜHENDİSLİK",
description="Dağıtık önbellek ve mesaj kuyruğu sistemlerinin karşılaştırmalı analizi.",
metadata={"Hazırlayan": "Deniz Yılmaz", "Sürüm": "1.1.0"}
)
builder.add_page()
builder.add_section_header("1. PERFORMANS ÖZETİ", "Yük Altında Tepki Süreleri")
builder.add_math(r"\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}", caption="Gauss İntegrali", label="1.1")
builder.add_table(
headers=["Motor Türü", "Okuma Gecikmesi", "Yazma Kapasitesi"],
rows=[
["Bellek İçi Önbellek", "0.4 ms", "120,000 işlem/sn"],
["Dağıtık Depolama", "2.1 ms", "45,000 işlem/sn"]
]
)
builder.add_callout("Yoğun trafik altında soket tükenmesini önlemek için bağlantı havuzu (connection pool) kullanılmalıdır.", kind="tip")
builder.add_image("diyagram.png", caption="Şekil 1: Küme Replikasyon Akışı")
builder.output("Mimari_Rapor.pdf")🧪 Testing / Testler
Run the unit and MCP server integration test suite / Birim ve entegrasyon testlerini çalıştırın:
python -m unittest discover -s tests -v📄 License / Lisans
MIT License — see LICENSE for details.
Available Tools
6 toolspdf_compare_filesC
Compare two PDF files page by page to detect text differences and page count mismatches.
Inputs: file1 (required), file2 (required).
pdf_from_markdownA
Compile a Markdown file (.md) or raw Markdown string directly into a styled, publication-grade PDF report without needing JSON conversion. Supports YAML frontmatter, # sections, ##/### Q&A headers, code blocks, | tables |, > [!NOTE] callouts, figures, and bullet points.
Inputs: output_path (required), theme, title, category, +5 more.
pdf_generate_reportB
Generate a publication-grade, styled PDF document from structured JSON data or an external JSON/Markdown file ('input_file') with cover page, headers/footers, Q&A cards, tables, images, callouts, code blocks, and full Turkish Unicode support.
Inputs: output_path (required), theme, title, category, +5 more.
pdf_get_metadataC
Retrieve technical metadata, total page count, file size, title, and author of a PDF file.
Inputs: file_path (required).
pdf_read_textC
Extract readable text from a PDF file with optional page range boundaries (1-based index).
Inputs: file_path (required), end_page, start_page.
pdf_search_batchB
Search across multiple PDF files in a directory matching a pattern (e.g. '.pdf', 'L.pdf') for a keyword or regex.
Inputs: directory (required), query, pattern, max_results, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct operation: metadata, text extraction, batch search, comparison, and two generation paths. The only real overlap is pdf_generate_report vs pdf_from_markdown, both producing styled PDFs, though the descriptions clearly delineate JSON/structured input versus Markdown input.
All tools share a pdf_ prefix and snake_case, with verb-led names (get, read, search, compare, generate). Minor deviations: pdf_search_batch orders noun-before-verb, and pdf_from_markdown uses a preposition rather than an action verb.
Six tools is a tight, well-scoped surface for a PDF utility server, with no redundant entries. Every tool corresponds to a recognizable user task in the PDF lifecycle.
Reading, metadata, search, comparison, and generation from two input formats are covered, but document manipulation operations (split, merge, rotate, page extraction, image extraction, PDF forms) are absent. Agents wanting to modify existing PDFs rather than just read or create them will hit dead ends.
Maintenance
Related MCP Connectors
Generate and read PDFs for AI agents: a generate_pdf and a read_pdf tool, priced per document.
PDF tools for AI agents: validate, extract, merge, split, compress, OCR, sign and redact.
PDF tools for AI agents: fill, merge, edit, read text and tables, create, protect and invoice PDFs.
PDF, image, video, OCR, screenshot, SQL, QR and text tools for agents. No API key, no signup.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to generate professional PDF documents from markdown content with advanced typography, syntax highlighting, math equations, dark mode, and customizable styling options.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
- AlicenseAqualityDmaintenanceEnables AI agents to process and inspect PDFs by detecting document type, extracting text, and generating Markdown with layout information.71MIT
- 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