Click on "Install 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., "@MCP PDF Reader Serverextract text from pages 1-5 of my quarterly 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.
MCP PDF Reader Server (Python + FastMCP)
A powerful Model Context Protocol (MCP) server built with FastMCP that provides comprehensive PDF processing capabilities including text extraction, image extraction, and OCR for reading text within images.
Features
Text Extraction: Extract text content from PDF pages
Image Extraction: Extract all images from PDF files
OCR Capabilities: Read text from images using Tesseract OCR
Comprehensive Analysis: Get detailed PDF structure and metadata
Page Range Support: Process specific page ranges
Multiple Languages: OCR support for multiple languages
Prerequisites
System Dependencies
Tesseract OCR
You need to install Tesseract OCR on your system:
Ubuntu/Debian:
macOS:
Windows:
Download from: https://github.com/UB-Mannheim/tesseract/wiki
Install and add to PATH
Or use:
conda install -c conda-forge tesseract
Additional Language Packs (Optional)
Installation
Quick Start with UV
Install UV (if not already installed):
Clone/Create the project:
Initialize and install with UV:
Verify installation:
Alternative: Manual Setup
If you prefer traditional setup:
Create virtual environment:
Install dependencies:
Usage
Running the Server
With UV:
Or if you have the environment activated:
The server will start and listen for MCP requests on stdin/stdout.
Available Tools
1. read_pdf_text
Extract text content from PDF pages.
Parameters:
file_path(string, required): Path to the PDF filepage_range(object, optional): Dict withstartandendpage numbers
Example:
2. extract_pdf_images
Extract all images from a PDF file.
Parameters:
file_path(string, required): Path to the PDF fileoutput_dir(string, optional): Directory to save imagespage_range(object, optional): Page range to process
Example:
3. read_pdf_with_ocr
Extract text from both regular text and images using OCR.
Parameters:
file_path(string, required): Path to the PDF filepage_range(object, optional): Page range to processocr_language(string, optional): OCR language code (default: "eng")
Example:
Supported OCR Languages:
eng- Englishfra- Frenchdeu- Germanspa- Spanisheng+fra- Multiple languages
4. get_pdf_info
Get comprehensive metadata and statistics about a PDF.
Parameters:
file_path(string, required): Path to the PDF file
5. analyze_pdf_structure
Analyze the structure and content distribution of a PDF.
Parameters:
file_path(string, required): Path to the PDF file
Configuration with Claude Desktop
With UV
Add this to your claude_desktop_config.json:
With Virtual Environment
System Python
Example Responses
Text Extraction Response
OCR Response
Performance Considerations
OCR Performance
OCR processing can be slow for large images
Consider processing smaller page ranges for faster results
Images smaller than 50x50 pixels are automatically skipped
Memory Usage
Large PDFs with many images may consume significant memory
The server processes pages sequentially to manage memory usage
Extracted images are saved to disk to reduce memory pressure
Optimization Tips
Use page ranges for large documents
Specify output directories for image extraction to avoid temp file buildup
Choose appropriate OCR languages to improve accuracy and speed
Preprocess images if OCR quality is poor (consider adding OpenCV)
Troubleshooting
Common Issues
Tesseract not found:
TesseractNotFoundError: tesseract is not installedInstall Tesseract OCR system package
Ensure it's in your PATH
Permission errors:
Ensure the Python process has read access to PDF files
Ensure write access to output directories
Poor OCR results:
Try different OCR language codes
Consider image preprocessing
Check if images are high enough resolution
Memory errors:
Process smaller page ranges
Close other applications
Consider increasing available RAM
Debug Mode
Run with debug logging using UV:
Or with regular Python:
Testing OCR
Test Tesseract directly:
Dependencies
fastmcp: Modern MCP server framework
PyMuPDF: Fast PDF processing and rendering
pytesseract: Python wrapper for Tesseract OCR
Pillow: Image processing library
tesseract-ocr: System OCR engine
Advanced Features
Custom OCR Configuration
You can modify the OCR configuration in the code:
Image Preprocessing
For better OCR results, consider adding image preprocessing:
Contributing
Fork the repository
Create a feature branch
Add tests for new functionality
Submit a pull request
License
MIT License - see LICENSE file for details.