MCP PDF Reader logo

MCP PDF Reader

Community
labeveryday

This mcp server will analyze and read pdf data.

Publisherlabeveryday
Repositorymcp_pdf_reader
LanguagePython
Forks
8
Stars
12
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    MCP PDF Reader exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    12 stars and 8 forks from the linked repository.

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:

bash
sudo apt update
sudo apt install tesseract-ocr tesseract-ocr-eng

macOS:

bash
brew install tesseract

Windows:

  1. Download from: https://github.com/UB-Mannheim/tesseract/wiki
  2. Install and add to PATH
  3. Or use: conda install -c conda-forge tesseract

Additional Language Packs (Optional)

bash
# For multiple languages
sudo apt install tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-spa

Installation

Quick Start with UV

  1. Install UV (if not already installed):
bash
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. Clone/Create the project:
bash
mkdir mcp-pdf-reader-server
cd mcp-pdf-reader-server
  1. Initialize and install with UV:
bash
# Copy the files (pdf_reader_server.py and pyproject.toml)
# Then install dependencies
uv sync
  1. Verify installation:
bash
uv run python -c "import pytesseract; print(pytesseract.get_tesseract_version())"

Alternative: Manual Setup

If you prefer traditional setup:

  1. Create virtual environment:
bash
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
bash
pip install fastmcp PyMuPDF pytesseract Pillow

Usage

Running the Server

With UV:

bash
uv run python pdf_reader_server.py

Or if you have the environment activated:

bash
python pdf_reader_server.py

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 file
  • page_range (object, optional): Dict with start and end page numbers

Example:

json
{
  "file_path": "/path/to/document.pdf",
  "page_range": {"start": 1, "end": 5}
}

2. extract_pdf_images

Extract all images from a PDF file.

Parameters:

  • file_path (string, required): Path to the PDF file
  • output_dir (string, optional): Directory to save images
  • page_range (object, optional): Page range to process

Example:

json
{
  "file_path": "/path/to/document.pdf",
  "output_dir": "/path/to/images/",
  "page_range": {"start": 1, "end": 3}
}

3. read_pdf_with_ocr

Extract text from both regular text and images using OCR.

Parameters:

  • file_path (string, required): Path to the PDF file
  • page_range (object, optional): Page range to process
  • ocr_language (string, optional): OCR language code (default: "eng")

Example:

json
{
  "file_path": "/path/to/document.pdf",
  "ocr_language": "eng+fra",
  "page_range": {"start": 1, "end": 10}
}

Supported OCR Languages:

  • eng - English
  • fra - French
  • deu - German
  • spa - Spanish
  • eng+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:

json
{
  "mcpServers": {
    "pdf-reader": {
      "command": "uv",
      "args": ["run", "python", "/path/to/your/pdf_reader_server.py"],
      "cwd": "/path/to/your/mcp-pdf-reader-server"
    }
  }
}

With Virtual Environment

json
{
  "mcpServers": {
    "pdf-reader": {
      "command": "/path/to/your/.venv/bin/python",
      "args": ["/path/to/your/pdf_reader_server.py"]
    }
  }
}

System Python

json
{
  "mcpServers": {
    "pdf-reader": {
      "command": "python",
      "args": ["/path/to/your/pdf_reader_server.py"],
      "env": {
        "PYTHONPATH": "/path/to/your/.venv/lib/python3.x/site-packages"
      }
    }
  }
}

Example Responses

Text Extraction Response

json
{
  "success": true,
  "file_path": "/path/to/document.pdf",
  "pages_processed": "1-3",
  "total_pages": 10,
  "pages_text": [
    {
      "page_number": 1,
      "text": "Page 1 content...",
      "word_count": 125
    }
  ],
  "combined_text": "All text combined...",
  "total_word_count": 1250,
  "total_character_count": 8750
}

OCR Response

json
{
  "success": true,
  "file_path": "/path/to/document.pdf",
  "pages_processed": "1-2",
  "ocr_language": "eng",
  "pages_data": [
    {
      "page_number": 1,
      "text": "Regular text from PDF...",
      "ocr_text": "Text extracted from images...",
      "images_with_text": [
        {
          "image_index": 1,
          "ocr_text": "Text from image 1",
          "confidence": "high"
        }
      ],
      "combined_text": "Combined text and OCR...",
      "text_word_count": 100,
      "ocr_word_count": 25
    }
  ],
  "summary": {
    "total_text_word_count": 200,
    "total_ocr_word_count": 50,
    "combined_word_count": 250,
    "images_processed": 3
  },
  "all_text_combined": "All extracted text..."
}

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

  1. Use page ranges for large documents
  2. Specify output directories for image extraction to avoid temp file buildup
  3. Choose appropriate OCR languages to improve accuracy and speed
  4. Preprocess images if OCR quality is poor (consider adding OpenCV)

Troubleshooting

Common Issues

  1. Tesseract not found:

    TesseractNotFoundError: tesseract is not installed
    • Install Tesseract OCR system package
    • Ensure it's in your PATH
  2. Permission errors:

    • Ensure the Python process has read access to PDF files
    • Ensure write access to output directories
  3. Poor OCR results:

    • Try different OCR language codes
    • Consider image preprocessing
    • Check if images are high enough resolution
  4. Memory errors:

    • Process smaller page ranges
    • Close other applications
    • Consider increasing available RAM

Debug Mode

Run with debug logging using UV:

bash
PYTHONUNBUFFERED=1 uv run python pdf_reader_server.py

Or with regular Python:

bash
PYTHONUNBUFFERED=1 python pdf_reader_server.py

Testing OCR

Test Tesseract directly:

bash
tesseract --list-langs
tesseract image.png output.txt

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:

python
ocr_text = pytesseract.image_to_string(
    pil_image, 
    lang=ocr_language,
    config='--psm 6 -c tessedit_char_whitelist=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '
)

Image Preprocessing

For better OCR results, consider adding image preprocessing:

python
# Add to requirements: opencv-python, numpy
import cv2
import numpy as np

# Preprocessing example
def preprocess_image(image):
    gray = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2GRAY)
    thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
    return Image.fromarray(thresh)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Submit a pull request

License

MIT License - see LICENSE file for details.

Use MCP PDF Reader MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP PDF Reader is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP PDF Reader as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP PDF Reader MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "labeveryday-mcp-pdf-reader": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP PDF Reader MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP PDF Reader MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP PDF Reader to help me with this task?
MCP PDF Reader
Sure. I read it.
Here is what I found using MCP PDF Reader.

Frequently asked questions

What is the MCP PDF Reader MCP server used for?

MCP PDF Reader is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP PDF Reader MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP PDF Reader with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP PDF Reader MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP PDF Reader connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP PDF Reader MCP to TypingMind?

MCP PDF Reader runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCP PDF Reader MCP provide in TypingMind?

MCP PDF Reader exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP PDF Reader MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP PDF Reader requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇