📄 MCP PDF Server
A PDF file reading server based on FastMCP.
Supports PDF text extraction, OCR recognition, and image extraction via the MCP protocol, with a built-in web debugger for easy testing.
🚀 Features
-
read_pdf_text
Extracts normal text from a PDF (page by page). -
read_by_ocr
Uses OCR to recognize text from scanned or image-based PDFs. -
read_pdf_to_file
Converts PDF files to TXT files with optional OCR support.
📂 Project Structure
mcp-pdf-server/
├── pdf_server.py # Main server entry point
└── README.md # Project documentation
⚙️ Installation
Recommended Python version: 3.9+
pip install pymupdf mcp
Note: To use OCR features, you may need a MuPDF build with OCR support or external OCR libraries.
🤖 Configuration
{
"mcpServers": {
"pdf-reader": {
"command": "uvx",
"timeout": 60000,
"args": [
"mcp-pdf-reader"
]
}
}
}
🔦 Start the Server
Run the following command:
python pdf_server.py
You should see logs like:
INFO:mcp-pdf-server:Starting MCP PDF Server...
🛠️ API Tool List
| Tool | Description | Input Parameters | Returns |
|---|---|---|---|
read_pdf_text |
Extracts normal text from PDF pages | file_path, start_page, end_page |
List of page texts |
read_by_ocr |
Recognizes text via OCR | file_path, start_page, end_page, language, dpi |
OCR extracted text |
read_pdf_to_file |
Converts PDF files to TXT files | file_paths, use_ocr, language, dpi |
Dictionary of generated TXT file paths |
📝 Example Usage
Extract text from pages 1 to 5:
mcp run read_pdf_text --args '{"file_path": "pdf_resources/example.pdf", "start_page": 1, "end_page": 5}'
Perform OCR recognition on page 1:
mcp run read_by_ocr --args '{"file_path": "pdf_resources/example.pdf", "start_page": 1, "end_page": 1, "language": "eng"}'
Convert PDF files to TXT files:
mcp run read_pdf_to_file --args '{"file_paths": ["pdf_resources/example.pdf"], "use_ocr": "no"}'
Convert PDF files with OCR support:
mcp run read_pdf_to_file --args '{"file_paths": ["pdf_resources/example.pdf"], "use_ocr": "yes", "language": "eng", "dpi": 300}'
📢 Notes
- Files must be placed inside the
pdf_resources/directory, or an absolute path must be provided. - OCR functionality requires appropriate OCR support in the environment.
- When processing large files, adjust memory and timeout settings as needed.
📜 License
This project is licensed under the MIT License.
For commercial use, please credit the original source.
Metadata
Release files for mcp-pdf-reader 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_pdf_reader-0.1.7.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_pdf_reader-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / mcp_pdf_reader-0.1.7.tar.gz
| Download URL | mcp_pdf_reader-0.1.7.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d576ea2f3475b25f0f2498c1225aea016d96675db87963458bd21527a5b7d98d
|
|
BLAKE2b-256 checksum How to use checksums |
bb1959cbb9853c979cb96bca9ac2ec97a4a6ca4c8487b425c62f574781d8bab3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / mcp_pdf_reader-0.1.7-py3-none-any.whl
| Download URL | mcp_pdf_reader-0.1.7-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2914b9127961356534e5649cb35f43a5d41134c0f485e5fab20846491aa27f6
|
|
BLAKE2b-256 checksum How to use checksums |
165b96b0ff5e3be22a00e130d4545dafd7ef65f45b3a540dc1f5e52084a9da33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for mcp-pdf-reader 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.