PDF MCP Server

PDF MCP Server

Enables AI-powered PDF manipulation through natural language commands, integrating with Claude to perform operations like merging, splitting, encrypting, optimizing, and analyzing PDFs.

Category
Visit Server

README

PDF MCP Server

GitHub stars GitHub issues GitHub license Python 3.8+

Transform PDF manipulation with AI-powered natural language commands through Claude integration

Comprehensive PDF toolkit that integrates seamlessly with Claude AI via MCP (Model Context Protocol). Perform complex PDF operations using simple conversational commands - merge, split, encrypt, optimize, and analyze PDFs effortlessly.

Demo

šŸš€ Quick Start

Clone & Setup

git clone https://github.com/Sohaib-2/pdf-mcp-server.git
cd pdf-mcp-server

Option 1: With Virtual Environment (Recommended)

python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux  
source .venv/bin/activate

pip install -r requirements.txt

Option 2: Without Virtual Environment

pip install fastmcp requests pathlib

Install PDF Tools

PDFtk:

# Ubuntu/Debian
sudo apt-get install pdftk
# macOS
brew install pdftk-java
# Windows: Download from https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

QPDF:

# Ubuntu/Debian
sudo apt-get install qpdf
# macOS
brew install qpdf
# Windows: Download from https://qpdf.sourceforge.io/

šŸ”§ Claude Desktop Integration

  1. Locate Claude config file:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  2. Add PDF MCP Server:

With Virtual Environment:

{
  "mcpServers": {
    "pdf-tools": {
      "command": "C:\\path\\to\\pdf-mcp-server\\.venv\\Scripts\\python.exe",
      "args": ["C:\\path\\to\\pdf-mcp-server\\server.py"]
    }
  }
}

Without Virtual Environment:

{
  "mcpServers": {
    "pdf-tools": {
      "command": "python",
      "args": ["C:\\path\\to\\pdf-mcp-server\\server.py"]
    }
  }
}

macOS/Linux with venv:

{
  "mcpServers": {
    "pdf-tools": {
      "command": "/path/to/pdf-mcp-server/.venv/bin/python",
      "args": ["/path/to/pdf-mcp-server/server.py"]
    }
  }
}
  1. Restart Claude Desktop

  2. Start using natural language:

    • "Merge these 3 PDFs into one document"
    • "Encrypt my report with password protection"
    • "Extract pages 1-10 from this manual"

šŸ“š Complete Tool Reference

Core Operations

Tool Description Example
merge_pdfs Combine multiple PDFs merge_pdfs(['doc1.pdf', 'doc2.pdf'], 'combined.pdf')
split_pdf Split into individual pages split_pdf('document.pdf', './pages/')
extract_pages Extract specific page ranges extract_pages('book.pdf', '1-5,10,15-20', 'excerpt.pdf')
rotate_pages Rotate pages by degrees rotate_pages('scan.pdf', '90', 'rotated.pdf', '1-3')

Security & Encryption

Tool Description Example
encrypt_pdf AES-256 encryption encrypt_pdf('file.pdf', 'secure.pdf', 'password123')
encrypt_pdf_basic Basic password protection encrypt_pdf_basic('doc.pdf', 'protected.pdf', 'pass', 'admin')
decrypt_pdf Remove password protection decrypt_pdf('locked.pdf', 'unlocked.pdf', 'password')

Optimization & Repair

Tool Description Example
optimize_pdf Compress for web/email optimize_pdf('large.pdf', 'small.pdf', 'high')
repair_pdf Fix corrupted PDFs repair_pdf('broken.pdf', 'fixed.pdf')
check_pdf_integrity Validate PDF structure check_pdf_integrity('suspicious.pdf')

Information & Analysis

Tool Description Example
get_pdf_info Detailed metadata (JSON) get_pdf_info('document.pdf')
update_pdf_metadata Modify title/author/etc update_pdf_metadata('file.pdf', 'updated.pdf', title='New Title')
inspect_pdf_structure Internal structure analysis inspect_pdf_structure('complex.pdf', detailed=True)
extract_pdf_attachments Extract embedded files extract_pdf_attachments('portfolio.pdf', './attachments/')

File Management

Tool Description Example
download_pdf Download from URL download_pdf('https://example.com/file.pdf', 'local.pdf')
open_pdf_preview Open with system viewer open_pdf_preview('report.pdf', browser=False)
get_file_info File size/path details get_file_info('document.pdf')
configure_pdf_workspace Set working directory configure_pdf_workspace('/path/to/workspace')
count_pdfs_in_directory List PDFs in folder count_pdfs_in_directory('./pdf_folder/')

System Management

Tool Description Purpose
get_server_status Check tool availability Verify PDFtk/QPDF installation
list_default_directories Show search paths Debug file resolution issues
get_pdf_tools_help Complete documentation In-app help reference

šŸ’¬ Natural Language Examples

Document Management:

  • "Combine all my research papers into one bibliography"
  • "Split this 100-page manual into chapters"
  • "Extract the executive summary from pages 2-4"

Security Operations:

  • "Encrypt this contract with military-grade protection"
  • "Remove password from this locked document"
  • "Add owner permissions to prevent editing"

File Optimization:

  • "Optimize all PDFs in my downloads folder"
  • "Fix this corrupted presentation file"

Advanced Analysis:

  • "Show me detailed metadata about this academic paper"
  • "Analyze the internal structure for security audit"

šŸ—‚ļø File Path Handling

Flexible path resolution:

  • Absolute: C:\Documents\file.pdf
  • Relative: ../pdfs/document.pdf
  • Filename only: report.pdf (searches default directories)

Default search order:

  1. PDF_WORKSPACE environment variable
  2. ~/Documents/PDFs
  3. ~/Downloads
  4. ~/Desktop
  5. Current working directory

āš™ļø Configuration

Custom workspace:

configure_pdf_workspace('/path/to/your/pdfs')

Check installation:

get_server_status()  # Verify PDFtk and QPDF availability

šŸ› ļø Troubleshooting

Common issues:

Problem Solution
PDFtk not found Install PDFtk and add to PATH
QPDF error Install QPDF via package manager
File not found Use list_default_directories() to check search paths
Permission denied Run with appropriate file permissions
Invalid PDF Use check_pdf_integrity() to validate file

Debug commands:

get_server_status()           # Check tool installation
list_default_directories()    # Verify search paths  
get_pdf_info('file.pdf')      # Validate PDF structure

šŸ—ļø Architecture

pdf-mcp-server/
ā”œā”€ā”€ server.py              # FastMCP server with 16 tools
ā”œā”€ā”€ pdftk_tools.py         # PDFtk CLI wrapper
ā”œā”€ā”€ qpdf_tools.py          # QPDF CLI wrapper  
ā”œā”€ā”€ utils.py               # File utilities & path resolution
└── requirements.txt       # Python dependencies

Built with:

  • FastMCP - MCP server framework
  • PDFtk - PDF manipulation
  • QPDF - Advanced PDF processing

šŸ¤ Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open Pull Request

šŸ“„ License

This project is licensed under the MIT License

šŸ‘Øā€šŸ’» Author

Sohaib-2 - GitHub

🌟 Acknowledgments


⭐ Star this repo if it helped you! | šŸ› Report issues | šŸ’” Request features

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
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
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
E2B

E2B

Using MCP to run code via e2b.

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

Qdrant Server

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

Official
Featured