PDF Reader MCP

PDF Reader MCP

A high-performance Model Context Protocol server that enables AI agents to extract text, images, and metadata from PDF documents using parallel processing. It features intelligent Y-coordinate content ordering to preserve natural reading flow and supports both local files and URL-based sources.

Category
访问服务器

README

<div align="center">

PDF Reader MCP 📄

Production-ready PDF processing server for AI agents

CI/CD codecov npm version coverage Downloads License

5-10x faster parallel processingY-coordinate content ordering94%+ test coverage103 tests passing

<a href="https://mseep.ai/app/SylphxAI-pdf-reader-mcp"> <img src="https://mseep.net/pr/SylphxAI-pdf-reader-mcp-badge.png" alt="Security Validated" width="200"/> </a>

</div>

基于原项目: 此项目基于 pdf-reader-mcp 修改而来


🚀 Overview

PDF Reader MCP is a production-ready Model Context Protocol server that empowers AI agents with enterprise-grade PDF processing capabilities. Extract text, images, and metadata with unmatched performance and reliability.

The Problem:

// Traditional PDF processing
- Sequential page processing (slow)
- No natural content ordering
- Complex path handling
- Poor error isolation

The Solution:

// PDF Reader MCP
- 5-10x faster parallel processing ⚡
- Y-coordinate based ordering 📐
- Flexible path support (absolute/relative) 🎯
- Per-page error resilience 🛡️
- 94%+ test coverage ✅

Result: Production-ready PDF processing that scales.


⚡ Key Features

Performance

  • 🚀 5-10x faster than sequential with automatic parallelization
  • 12,933 ops/sec error handling, 5,575 ops/sec text extraction
  • 💨 Process 50-page PDFs in seconds with multi-core utilization
  • 📦 Lightweight with minimal dependencies

Developer Experience

  • 🎯 Path Flexibility - Absolute & relative paths, Windows/Unix support (v1.3.0)
  • 🖼️ Smart Ordering - Y-coordinate based content preserves document layout
  • 🛡️ Type Safe - Full TypeScript with strict mode enabled
  • 📚 Battle-tested - 103 tests, 94%+ coverage, 98%+ function coverage
  • 🎨 Simple API - Single tool handles all operations elegantly

📊 Performance Benchmarks

Real-world performance from production testing:

Operation Ops/sec Performance Use Case
Error handling 12,933 ⚡⚡⚡⚡⚡ Validation & safety
Extract full text 5,575 ⚡⚡⚡⚡ Document analysis
Extract page 5,329 ⚡⚡⚡⚡ Single page ops
Multiple pages 5,242 ⚡⚡⚡⚡ Batch processing
Metadata only 4,912 ⚡⚡⚡ Quick inspection

Parallel Processing Speedup

Document Sequential Parallel Speedup
10-page PDF ~2s ~0.3s 5-8x faster
50-page PDF ~10s ~1s 10x faster
100+ pages ~20s ~2s Linear scaling with CPU cores

Benchmarks vary based on PDF complexity and system resources.


📦 Installation

# Quick start - zero installation
npx @sylphx/pdf-reader-mcp

# Using pnpm (recommended)
pnpm add @sylphx/pdf-reader-mcp

# Using npm
npm install @sylphx/pdf-reader-mcp

# Using yarn
yarn add @sylphx/pdf-reader-mcp

# For Claude Desktop (easiest)
npx -y @smithery/cli install @sylphx/pdf-reader-mcp --client claude

🎯 Quick Start

Configuration

Add to your MCP client (claude_desktop_config.json, Cursor, Cline):

{
  "mcpServers": {
    "pdf-reader-mcp": {
      "command": "npx",
      "args": ["@bachstudio/pdf-reader-mcp"]
    }
  }
}

Basic Usage

{
  "sources": [{
    "path": "documents/report.pdf"
  }],
  "include_full_text": true,
  "include_metadata": true,
  "include_page_count": true
}

Result:

  • ✅ Full text content extracted
  • ✅ PDF metadata (author, title, dates)
  • ✅ Total page count
  • ✅ Structural sharing - unchanged parts preserved

Extract Specific Pages

{
  "sources": [{
    "path": "documents/manual.pdf",
    "pages": "1-5,10,15-20"
  }],
  "include_full_text": true
}

Absolute Paths (v1.3.0+)

// Windows - Both formats work!
{
  "sources": [{
    "path": "C:\\Users\\John\\Documents\\report.pdf"
  }],
  "include_full_text": true
}

// Unix/Mac
{
  "sources": [{
    "path": "/home/user/documents/contract.pdf"
  }],
  "include_full_text": true
}

No more "Absolute paths are not allowed" errors!

Extract Images with Natural Ordering

{
  "sources": [{
    "path": "presentation.pdf",
    "pages": [1, 2, 3]
  }],
  "include_images": true,
  "include_full_text": true
}

Response includes:

  • Text and images in exact document order (Y-coordinate sorted)
  • Base64-encoded images with metadata (width, height, format)
  • Natural reading flow preserved for AI comprehension

Batch Processing

{
  "sources": [
    { "path": "C:\\Reports\\Q1.pdf", "pages": "1-10" },
    { "path": "/home/user/Q2.pdf", "pages": "1-10" },
    { "url": "https://example.com/Q3.pdf" }
  ],
  "include_full_text": true
}

All PDFs processed in parallel automatically!


✨ Features

Core Capabilities

  • Text Extraction - Full document or specific pages with intelligent parsing
  • Image Extraction - Base64-encoded with complete metadata (width, height, format)
  • Content Ordering - Y-coordinate based layout preservation for natural reading flow
  • Metadata Extraction - Author, title, creation date, and custom properties
  • Page Counting - Fast enumeration without loading full content
  • Dual Sources - Local files (absolute or relative paths) and HTTP/HTTPS URLs
  • Batch Processing - Multiple PDFs processed concurrently

Advanced Features

  • 5-10x Performance - Parallel page processing with Promise.all
  • 🎯 Smart Pagination - Extract ranges like "1-5,10-15,20"
  • 🖼️ Multi-Format Images - RGB, RGBA, Grayscale with automatic detection
  • 🛡️ Path Flexibility - Windows, Unix, and relative paths all supported (v1.3.0)
  • 🔍 Error Resilience - Per-page error isolation with detailed messages
  • 📏 Large File Support - Efficient streaming and memory management
  • 📝 Type Safe - Full TypeScript with strict mode enabled

🆕 What's New in v1.3.0

🎉 Absolute Paths Now Supported!

// ✅ Windows
{ "path": "C:\\Users\\John\\Documents\\report.pdf" }
{ "path": "C:/Users/John/Documents/report.pdf" }

// ✅ Unix/Mac
{ "path": "/home/john/documents/report.pdf" }
{ "path": "/Users/john/Documents/report.pdf" }

// ✅ Relative (still works)
{ "path": "documents/report.pdf" }

Other Improvements:

  • 🐛 Fixed Zod validation error handling
  • 📦 Updated all dependencies to latest versions
  • ✅ 103 tests passing, 94%+ coverage maintained

<details> <summary><strong>📋 View Full Changelog</strong></summary>

<br/>

v1.2.0 - Content Ordering

  • Y-coordinate based text and image ordering
  • Natural reading flow for AI models
  • Intelligent line grouping

v1.1.0 - Image Extraction & Performance

  • Base64-encoded image extraction
  • 10x speedup with parallel processing
  • Comprehensive test coverage (94%+)

View Full Changelog →

</details>


📖 API Reference

read_pdf Tool

The single tool that handles all PDF operations.

Parameters

Parameter Type Description Default
sources Array List of PDF sources to process Required
include_full_text boolean Extract full text content false
include_metadata boolean Extract PDF metadata true
include_page_count boolean Include total page count true
include_images boolean Extract embedded images false

Source Object

{
  path?: string;        // Local file path (absolute or relative)
  url?: string;         // HTTP/HTTPS URL to PDF
  pages?: string | number[];  // Pages to extract: "1-5,10" or [1,2,3]
}

Examples

Metadata only (fast):

{
  "sources": [{ "path": "large.pdf" }],
  "include_metadata": true,
  "include_page_count": true,
  "include_full_text": false
}

From URL:

{
  "sources": [{
    "url": "https://arxiv.org/pdf/2301.00001.pdf"
  }],
  "include_full_text": true
}

Page ranges:

{
  "sources": [{
    "path": "manual.pdf",
    "pages": "1-5,10-15,20"  // Pages 1,2,3,4,5,10,11,12,13,14,15,20
  }]
}

🔧 Advanced Usage

<details> <summary><strong>📐 Y-Coordinate Content Ordering</strong></summary>

<br/>

Content is returned in natural reading order based on Y-coordinates:

Document Layout:
┌─────────────────────┐
│ [Title]       Y:100 │
│ [Image]       Y:150 │
│ [Text]        Y:400 │
│ [Photo A]     Y:500 │
│ [Photo B]     Y:550 │
└─────────────────────┘

Response Order:
[
  { type: "text", text: "Title..." },
  { type: "image", data: "..." },
  { type: "text", text: "..." },
  { type: "image", data: "..." },
  { type: "image", data: "..." }
]

Benefits:

  • AI understands spatial relationships
  • Natural document comprehension
  • Perfect for vision-enabled models
  • Automatic multi-line text grouping

</details>

<details> <summary><strong>🖼️ Image Extraction</strong></summary>

<br/>

Enable extraction:

{
  "sources": [{ "path": "manual.pdf" }],
  "include_images": true
}

Response format:

{
  "images": [{
    "page": 1,
    "index": 0,
    "width": 1920,
    "height": 1080,
    "format": "rgb",
    "data": "base64-encoded-png..."
  }]
}

Supported formats: RGB, RGBA, Grayscale Auto-detected: JPEG, PNG, and other embedded formats

</details>

<details> <summary><strong>📂 Path Configuration</strong></summary>

<br/>

Absolute paths (v1.3.0+) - Direct file access:

{ "path": "C:\\Users\\John\\file.pdf" }
{ "path": "/home/user/file.pdf" }

Relative paths - Workspace files:

{ "path": "docs/report.pdf" }
{ "path": "./2024/Q1.pdf" }

Configure working directory:

{
  "mcpServers": {
    "pdf-reader-mcp": {
      "command": "npx",
      "args": ["@sylphx/pdf-reader-mcp"],
      "cwd": "/path/to/documents"
    }
  }
}

</details>

<details> <summary><strong>📊 Large PDF Strategies</strong></summary>

<br/>

Strategy 1: Page ranges

{ "sources": [{ "path": "big.pdf", "pages": "1-20" }] }

Strategy 2: Progressive loading

// Step 1: Get page count
{ "sources": [{ "path": "big.pdf" }], "include_full_text": false }

// Step 2: Extract sections
{ "sources": [{ "path": "big.pdf", "pages": "50-75" }] }

Strategy 3: Parallel batching

{
  "sources": [
    { "path": "big.pdf", "pages": "1-50" },
    { "path": "big.pdf", "pages": "51-100" }
  ]
}

</details>


🔧 Troubleshooting

"Absolute paths are not allowed"

Solution: Upgrade to v1.3.0+

npm update @sylphx/pdf-reader-mcp

Restart your MCP client completely.


"File not found"

Causes:

  • File doesn't exist at path
  • Wrong working directory
  • Permission issues

Solutions:

Use absolute path:

{ "path": "C:\\Full\\Path\\file.pdf" }

Or configure cwd:

{
  "pdf-reader-mcp": {
    "command": "npx",
    "args": ["@sylphx/pdf-reader-mcp"],
    "cwd": "/path/to/docs"
  }
}

"No tools showing up"

Solution:

npm cache clean --force
rm -rf node_modules package-lock.json
npm install @sylphx/pdf-reader-mcp@latest

Restart MCP client completely.


🏗️ Architecture

Tech Stack

Component Technology
Runtime Node.js 22+ ESM
PDF Engine PDF.js (Mozilla)
Validation Zod + JSON Schema
Protocol MCP SDK
Language TypeScript (strict)
Testing Vitest (103 tests)
Quality Biome (50x faster)
CI/CD GitHub Actions

Design Principles

  • 🔒 Security First - Flexible paths with secure defaults
  • 🎯 Simple Interface - One tool, all operations
  • Performance - Parallel processing, efficient memory
  • 🛡️ Reliability - Per-page isolation, detailed errors
  • 🧪 Quality - 94%+ coverage, strict TypeScript
  • 📝 Type Safety - No any types, strict mode
  • 🔄 Backward Compatible - Smooth upgrades always

🧪 Development

<details> <summary><strong>Setup & Scripts</strong></summary>

<br/>

Prerequisites:

  • Node.js >= 22.0.0
  • pnpm (recommended) or npm

Setup:

git clone https://github.com/SylphxAI/pdf-reader-mcp.git
cd pdf-reader-mcp
pnpm install && pnpm build

Scripts:

pnpm run build       # Build TypeScript
pnpm run test        # Run 103 tests
pnpm run test:cov    # Coverage (94%+)
pnpm run check       # Lint + format
pnpm run check:fix   # Auto-fix
pnpm run benchmark   # Performance tests

Quality:

  • ✅ 103 tests
  • ✅ 94%+ coverage
  • ✅ 98%+ function coverage
  • ✅ Zero lint errors
  • ✅ Strict TypeScript

</details>

<details> <summary><strong>Contributing</strong></summary>

<br/>

Quick Start:

  1. Fork repository
  2. Create branch: git checkout -b feature/awesome
  3. Make changes: pnpm test
  4. Format: pnpm run check:fix
  5. Commit: Use Conventional Commits
  6. Open PR

Commit Format:

feat(images): add WebP support
fix(paths): handle UNC paths
docs(readme): update examples

See CONTRIBUTING.md

</details>


📚 Documentation


🗺️ Roadmap

✅ Completed

  • [x] Image extraction (v1.1.0)
  • [x] 5-10x parallel speedup (v1.1.0)
  • [x] Y-coordinate ordering (v1.2.0)
  • [x] Absolute paths (v1.3.0)
  • [x] 94%+ test coverage (v1.3.0)

🚀 Next

  • [ ] OCR for scanned PDFs
  • [ ] Annotation extraction
  • [ ] Form field extraction
  • [ ] Table detection
  • [ ] 100+ MB streaming
  • [ ] Advanced caching
  • [ ] PDF generation

Vote at Discussions


🏆 Recognition

Featured on:

Trusted worldwideEnterprise adoptionBattle-tested


🤝 Support

GitHub Issues Discord

Show Your Support: ⭐ Star • 👀 Watch • 🐛 Report bugs • 💡 Suggest features • 🔀 Contribute


📊 Stats

Stars Forks Downloads Contributors

103 Tests94%+ CoverageProduction Ready


📄 License

MIT © Sylphx


🙏 Credits

Built with:

Special thanks to the open source community ❤️


<p align="center"> <strong>5-10x faster. Production-ready. Battle-tested.</strong> <br> <sub>The PDF processing server that actually scales</sub> <br><br> <a href="https://sylphx.com">sylphx.com</a> • <a href="https://x.com/SylphxAI">@SylphxAI</a> • <a href="mailto:hi@sylphx.com">hi@sylphx.com</a> </p>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选