PDF文档读取与搜索MCP服务

该服务是一个用于读取、渲染和搜索PDF文件的MCP服务器,支持提取文本、图片、目录和元数据,并可从页面范围生成PNG图像,适用于需要阅读数据手册和技术文档的大语言模型。

  • by I-CAN-hack
  • Python
  • 本地部署
  • 79 星标
  • 更新于
在 GitHub 查看 I-CAN-hack/pdf-mcp

使用说明

pdf-mcp

An MCP server for reading, rendering, and searching PDF files. Built with PyMuPDF 2.

Designed for use with LLMs that need to read datasheets and other PDFs containing diagrams, tables, and technical content.

Tools

Tool Description
get_pdf_info Get metadata about a PDF (page count, author, title, etc.)
get_table_of_contents Get the outline/bookmarks with page numbers for each section
get_page_text Extract text from a page range in json (default), text, markdown, or html format. Optionally exclude headers/footers
get_page_image Render a single page as a PNG image, returned as base64 or written to a temp file. Configurable DPI (default 150)
search_text Case-insensitive text search across the entire PDF, returning page numbers and surrounding context

All requests are stateless and take the PDF filename as a parameter.

Setup

Add the following to your .mcp.json:

{
  "mcpServers": {
    "pdf-mcp": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/I-CAN-hack/pdf-mcp.git", "pdf-mcp"]
    }
  }
}

Or for codex run codex mcp add pdf-mcp -- uvx --from git+https://github.com/I-CAN-hack/pdf-mcp.git pdf-mcp.

This will automatically install and run the server using uvx.

Development

# Install dependencies
uv sync

# Generate test PDFs
uv run python assets/generate.py

# Run tests
uv run pytest tests/ -v

# Run the server locally
uv run pdf-mcp