LM

labeveryday/mcp_pdf_reader

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

13 stars 8 forks 质量 55 趋势 20

这个mcp服务器将分析和读取pdf数据.

概览

一个用FastMCP所建的强大的模型上下文协议(MCP)服务器,提供全面的PDF处理能力,包括文本提取,图像提取,以及OCR在图像内读取文本. - :从 PDF 页面中提取文本内容 - : 从 PDF 文件中提取出所有图像 - : 用 Testeract OCR 从图像中读取文本 - : 获取详细的 PDF 结构和元数据 - : 处理特定页面范围 - : OCR 对多种语言的支持 你需要在你的系统中安装宇宙魔方OCR: 1. 下载自:https://github.com/UB-Mannheim/tesseract/wiki 2. 安装并添加到 PATH 3. 或使用: Conda 安装 -c conda-forge 语法 或者如果你已经激活了环境: 服务器将在 stdin/ stdout 上启动并聆听 MCP 请求 .

概述(AI 翻译)

一个用FastMCP所建的强大的模型上下文协议(MCP)服务器,提供全面的PDF处理能力,包括文本提取,图像提取,以及OCR在图像内读取文本.

□ 特性

  • ** 摘录**: 从 PDF 页面提取文本内容
  • 图像提取:从 PDF 文件提取出所有图像
  • OCR能力:使用宇宙魔方OCR从图像中读取文本
  • ** 综合分析**:获得详细的PDF结构和元数据
  • ** 页面范围支助**: 进程特定页面范围
  • 多种语言:OCR对多种语言的支持

□ 先决条件

++ 系统依赖

宇宙魔方 OCR 你需要在你的系统中安装宇宙魔方OCR:

** Ubuntu/Debian:**

** 马科斯:**

** 窗户:**

  1. 下载自:https://github.com/UB-Mannheim/tesseract/wiki
  2. 安装和添加到路径
  3. 或使用:conda install -c conda-forge tesseract

+++ 附加语言包(可选)

□ 安装

QQ 用紫外线快速启动

  1. ** 安装紫外线(如果尚未安装):**

  2. ** 计算/创建项目:**

  3. ** 启动并安装紫外线:**

  4. ** 核证装置:**

XQ: 手动设置

如果您喜欢传统设置 :

  1. 联合国.

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

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:

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

macOS:

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)

# 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):
# 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:
mkdir mcp-pdf-reader-server
cd mcp-pdf-reader-server
  1. Initialize and install with UV:
# Copy the files (pdf_reader_server.py and pyproject.toml)
# Then install dependencies
uv sync
  1. Verify installation:
uv run python -c "import pytesseract; print(pytesseract.get_tesseract_version())"

Alternative: Manual Setup

If you prefer traditional setup:

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

Usage

Running the Server

With UV:

uv run python pdf_reader_server.py

Or if you have the environment activated:

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:

{
  "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:

{
  "file_path": "/path/to/document.pdf",
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

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