MokuPDF - Intelligent PDF Reading Server for AI
MokuPDF is a powerful, MCP (Model Context Protocol) compatible server that enables AI applications to read and process PDF files with advanced capabilities. It combines intelligent file search, comprehensive text extraction, image processing, and optional OCR support to handle any type of PDF document - from simple text files to complex scanned documents.
๐ Perfect for Claude Desktop, ChatGPT plugins, and any AI application that needs PDF processing capabilities!
๐ Table of Contents
โจ Key Features
๐ Intelligent PDF Processing
๐ Full Text Extraction - Extract all text content from any PDF
๐ผ๏ธ Advanced Image Handling - Extract embedded images as base64 PNG with proper format conversion
๐ฑ Scanned PDF Support - Auto-detects and renders image-based/scanned PDFs at high resolution
๐ค Optional OCR Integration - Extract text from scanned documents using Tesseract (optional)
๐ Page-by-Page Processing - Handle large PDFs efficiently without memory issues
๐ฏ Smart File Operations
๐ง Intelligent File Search - Find PDFs using natural language: "find the report", "open invoice"
๐ Multi-Location Search - Automatically searches Desktop, Downloads, Documents, and OneDrive
๐ Fuzzy Matching - Handles typos and partial filenames intelligently
๐ Advanced Text Search - Search within PDFs with regex support and context
๐ค AI Integration
โก MCP Protocol Compliant - Seamlessly integrates with Claude Desktop and other AI tools
๐ FastMCP Architecture - Built on the official MCP Python SDK for reliability
๐ก JSON-RPC Interface - Clean, standardized API for easy integration
โ๏ธ Configurable & Lightweight - Minimal dependencies, fast startup, customizable options
๐ฆ Installation
From Source
Using pip (when published)
Note: For OCR functionality, you'll also need Tesseract installed on your system:
Windows: Download from GitHub releases
Mac:
brew install tesseractLinux:
sudo apt-get install tesseract-ocr
๐ฏ Quick Start
Running the Server
Command Line Options
Option | Description | Default |
| Port to listen on | 8000 |
| Enable verbose logging | False |
| Base directory for PDF files | Current directory |
| Maximum PDF file size in MB | 100 |
| Show version information | - |
| Show help message | - |
๐ง MCP Configuration
Add MokuPDF to your MCP configuration file:
๐ Available MCP Tools
1. open_pdf
Open a PDF file for processing.
2. read_pdf
Read PDF pages with text and images. Supports page ranges for efficient processing.
Response includes:
Text content with
[IMAGE: ...]placeholdersBase64-encoded images
Page information
3. search_text
Search for text within the current PDF.
4. get_page_text
Extract text from a specific page.
5. get_metadata
Get metadata from the current PDF.
6. close_pdf
Close the current PDF and free memory.
7. find_pdf_files
Find PDF files using intelligent search across common directories.
๐ก Usage Examples
๐ฏ Natural Language File Access
๐ Text-Based PDFs
๐ผ๏ธ Scanned PDFs (Image-Based)
๐ Smart Search & Discovery
๐ผ๏ธ Image & Scanned PDF Support
MokuPDF automatically handles different PDF types:
PDF Type | Text Extraction | Image Handling | OCR Support |
Text-based PDF | โ Direct extraction | โ Embedded images extracted | โ Not needed |
Mixed PDF | โ Text + images | โ All images extracted | โ Not needed |
Scanned PDF | โ ๏ธ Limited/None | โ Full page rendered | โ Optional OCR |
Image-only PDF | โ None | โ Full page rendered | โ Optional OCR |
OCR Installation
๐ Smart File Search
MokuPDF's intelligent file finder works with natural language:
Search Patterns
Exact matches:
"report"โAnnual_Report.pdfPartial matches:
"ann"โAnnual_Report.pdfMultiple terms:
"financial report 2024"โFinancial_Report_2024.pdfFuzzy matching:
"finacial"โFinancial_Report.pdf(handles typos)
Search Locations
Current working directory
~/Desktop~/Downloads~/Documents~/OneDrive/Desktop(if available)~/OneDrive/Documents(if available)
Ranking System
Files are ranked by:
Exact name matches (highest priority)
Word boundary matches
Partial string matches
Recent modification time (boost for recent files)
File location (Desktop files prioritized)
โ๏ธ Configuration Options
Command Line Arguments
MCP Server Configuration
๐ป Development
Project Structure
Running Tests
Code Quality
Architecture
MokuPDF is built using:
FastMCP: Official MCP Python SDK for reliable protocol handling
PyMuPDF (fitz): High-performance PDF processing and rendering
Pillow: Image format conversion and processing
pytesseract: Optional OCR text extraction from scanned documents
๐ ๏ธ Troubleshooting
Common Issues
๐ธ "ModuleNotFoundError: No module named 'mokupdf'"
๐ธ "No PDF is currently open"
๐ธ "PDF file not found"
๐ธ OCR not working
๐ธ "File too large" errors
Debug Mode
๐ Performance Tips
Large PDFs: Use
start_pageandend_pageparameters for chunked processingMemory usage: Close PDFs when done with
close_pdftoolOCR speed: OCR processing adds significant time - disable if not needed
File search: Search is cached - repeated searches are faster
Image quality: Scanned pages rendered at 2x resolution for clarity
๐บ๏ธ Roadmap
Advanced OCR: Multiple language support, confidence scores
Enhanced Search: Content-based PDF search (search inside PDF text)
Batch Processing: Process multiple PDFs simultaneously
Format Support: Add support for other document formats (DOCX, PPTX)
Cloud Integration: Support for cloud storage (Google Drive, OneDrive API)
Performance: Async processing for better concurrent handling
๐ Example Usage
Python Script Example
Integration with LLMs
MokuPDF is designed to work seamlessly with LLM applications through MCP. The read_pdf tool returns content in a format optimized for LLM consumption:
Text is extracted with page markers
Images are embedded as base64 PNG with placeholders in text
Large PDFs can be read page-by-page to avoid context limits
๐ ๏ธ Troubleshooting
Common Issues
Issue: ModuleNotFoundError: No module named 'mokupdf'
Solution: Install the package with
pip install .
Issue: Port already in use
Solution: Use a different port with
--port 8081
Issue: PDF file not found
Solution: Check the base directory and ensure paths are relative to it
Issue: Large PDF causes timeout
Solution: Use page-by-page reading with
start_pageandend_pageparameters
Debug Mode
Enable verbose logging for detailed information:
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Contributing
We welcome contributions! MokuPDF is designed to be the best PDF processing tool for AI applications.
How to Contribute
๐ด Fork the repository
๐ฟ Create a feature branch:
git checkout -b feature/amazing-feature๐ Make your changes with clear, documented code
โ Add tests for new functionality
๐งน Run code formatting:
black mokupdf/โจ Submit a pull request
Development Setup
Contribution Ideas
๐ Multi-language OCR support
โก Performance optimizations
๐ Advanced search algorithms
๐ฑ New document format support
๐ Bug fixes and improvements
๐ Documentation enhancements
๐ Support & Community
Getting Help
๐ Issues: Open a GitHub issue for bugs or feature requests
๐ฌ Discussions: Use GitHub Discussions for questions and community support
๐ง Troubleshooting: Enable
--verbosemode for detailed debugging information
Reporting Bugs
When reporting issues, please include:
Operating system and Python version
MokuPDF version (
mokupdf --version)Sample PDF file (if possible)
Complete error message and traceback
Steps to reproduce the issue
๐ Acknowledgments
MokuPDF is built on the shoulders of giants:
PyMuPDF - Exceptional PDF processing and rendering capabilities
FastMCP - Official MCP Python SDK for reliable protocol handling
Tesseract OCR - Open-source OCR engine for text extraction
Pillow - Python Imaging Library for image processing
Model Context Protocol - Standardized protocol for AI tool integration
Special thanks to the AI and open-source communities for inspiration and feedback.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License Summary
โ Commercial use - Use in commercial applications
โ Modification - Modify and distribute changes
โ Distribution - Distribute original or modified versions
โ Private use - Use privately without restrictions
โ No warranty - Software provided "as-is"
โ๏ธ License notice - Include original license in copies
๐ Made with โค๏ธ for the AI community