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
Visit Server

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 processing โ€ข Y-coordinate content ordering โ€ข 94%+ test coverage โ€ข 103 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 worldwide โ€ข Enterprise adoption โ€ข Battle-tested


๐Ÿค Support

GitHub Issues Discord

Show Your Support: โญ Star โ€ข ๐Ÿ‘€ Watch โ€ข ๐Ÿ› Report bugs โ€ข ๐Ÿ’ก Suggest features โ€ข ๐Ÿ”€ Contribute


๐Ÿ“Š Stats

Stars Forks Downloads Contributors

103 Tests โ€ข 94%+ Coverage โ€ข Production 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>

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured