A Python-based MCP server that reads PDFs, supports OCR, and can extract images, with a web debugger for testing.
Configuration
View docs{
"mcpServers": {
"deepseekmine-mcp-pdf-reader": {
"command": "python",
"args": [
"txt_server.py"
]
}
}
}You can run a lightweight MCP server that reads PDFs by extracting text, applying OCR to image-based PDFs, and pulling images from pages. It includes a builtβin web debugger for easy testing, making it straightforward to verify each toolβs output before integrating into larger workflows.
You interact with the PDF reading MCP server by starting a local stdio MCP endpoint and then issuing tool calls from an MCP client. The server exposes three main tools you can run: read_pdf_text to extract normal text page by page, read_by_ocr to recognize text via OCR on scanned or image PDFs, and read_pdf_images to pull images from a specified PDF page.
python
- Install Python 3.9 or newer if you do not have it already.
- Install required Python packages:
pip install pymupdf mcp
- Start the server:
python txt_server.py
- Access the web debugger at:
http://127.0.0.1:6231
Notes
- To enable OCR features, ensure your MuPDF build includes OCR support or you have external OCR libraries available.Place PDF files you want to process inside the pdf_resources/ directory. You can also provide absolute file paths when calling tools. The web debugging interface helps you test each tool by selecting it from the left panel, entering parameters on the right panel, and clicking Run.
Web debugger URL: http://127.0.0.1:6231. Tools available: read_pdf_text, read_by_ocr, read_pdf_images. OCR support requires an environment with OCR capability. For large files, monitor memory usage and adjust accordingly.
If you do not see the server listening message, verify that you started the correct script (txt_server.py) and that Python is available in your system path. If OCR fails, confirm that OCR libraries are installed and that your MuPDF build supports OCR.
- Extract text from pages 1 through 5 from a PDF located at pdf_resources/example.pdf using read_pdf_text. - Perform OCR on page 1 of the same document with read_by_ocr. - Extract all images from page 3 with read_pdf_images.
Extracts normal text from PDF pages, returning text organized by page.
Recognizes text via OCR for scanned or image-based PDFs, with language and DPI options.
Extracts images from a specific PDF page, outputting images in Base64 encoding.