PDF阅读服务器

一个用于读取PDF的MCP服务器,提供学术感知的PDF资源、专业学术分析提示和增强的PDF处理工具。

  • by averagejoeslab
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 averagejoeslab/pdf-reader-mcp

使用说明

pdf阅读器MCP服务器

用于阅读PDF的MCP服务器

组件

资源

服务器提供具有学术意识的PDF资源,包括:

  • 自定义 file:// 用于访问单个PDF的URI方案
  • 学术结构检测和关键部分提取
  • 通过文档类型分类丰富的元数据
  • 为代理理解而优化的资源

学术提示

服务器提供专门的学术分析提示:

  • 学术论文综述:智能学术论文摘要
    • PDF位置的必需“file_path”参数
    • 可选的“焦点”论点(一般/方法/结果/影响)
    • 生成包含关键部分、引用和元数据的提示
  • 分析研究方法:深入的方法分析
    • PDF位置的必需“file_path”参数
    • 专注于研究设计、数据收集和统计方法

增强工具

基本PDF处理:

  • 加载pdf:加载并缓存PDF文件以供处理
  • 获取元数据:获取PDF元数据和文档信息
  • 提取图像:使用元数据提取嵌入图像
  • 渲染页面:将PDF页面渲染为高分辨率图像

学术提升:

  • 提取学术文本:文本提取,具有适当的阅读顺序和数学公式保存
  • 检测部分:确定学术部分(摘要、引言、方法、结果等)
  • 摘录摘要:具体提取摘要部分
  • 提取关键部分:优化关键部分以了解代理
  • 摘录引文:解析文本引用和参考文献列表
  • 块内容:将内容分解为对代理友好的语义块
  • 分析文档结构:综合学术文献分析

配置

此PDF阅读器MCP服务器提供全面的PDF处理功能,包括:

  • 从任何PDF中提取全文
  • 高分辨率图像提取
  • 表检测和提取
  • 注释和注释提取
  • PDF元数据检索
  • 页面渲染为图像
  • 文档结构分析

安装和设置

先决条件

  • Python 3.13或更高版本
  • uv 软件包管理器(安装 pip install uv)

再进行

uv sync

IDE集成

带MCP扩展的VSCode

  1. 安装 MCP VSCode扩展
  2. 打开VSCode设置(.vscode/settings.json)并添加:
{
  "mcp.servers": {
    "pdf-reader": {
      "url": "http://localhost:8000/sse",
      "description": "PDF reader with full extraction capabilities"
    }
  }
}

WindSurf IDE

  1. 打开WindSurf设置
  2. 导航到扩展→ MCP服务器
  3. 添加新的服务器配置:
{
  "name": "pdf-reader",
  "url": "http://localhost:8000/sse",
  "description": "Comprehensive PDF processing server"
}

光标IDE

  1. 打开光标设置(Cmd/Ctrl+,)
  2. 搜索“MCP”或导航到扩展→ MCP
  3. 添加服务器配置:
{
  "mcpServers": {
    "pdf-reader": {
      "url": "http://localhost:8000/sse",
      "description": "PDF reader with text, image, and table extraction"
    }
  }
}

克劳德桌面

在MacOS上: ~/Library/Application\ Support/Claude/claude_desktop_config.json 在Windows上: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "pdf-reader": {
      "url": "http://localhost:8000/sse",
      "description": "PDF reader with comprehensive extraction capabilities"
    }
  }
}

启动服务器

在任何IDE中使用PDF阅读器之前,请启动HTTP服务器:

# Navigate to the pdf-reader directory
cd /path/to/your/pdf-reader

# Start the server
uv run pdf-reader

服务器将于启动 http://localhost:8000 MCP SSE端点位于 /sse 所有IDE都可以连接到。

使用示例

在IDE中配置后,您可以使用带有自然语言命令的PDF阅读器:

基本PDF处理

"Load the research paper at /path/to/paper.pdf and extract all the text"
"Get metadata for the PDF document at /documents/report.pdf"
"Extract all images from the PDF on page 3"

高级分析

"Summarize the PDF document in technical style focusing on methodology"
"Analyze the structure of this PDF and tell me about its organization"
"Extract all tables from the document and show me the data"

视觉处理

"Render page 5 of the PDF as a high-resolution image"
"Extract all annotations and comments from this PDF"
"Show me all the images embedded in this document"

可用工具

工具 说明 参数
load-pdf 加载和缓存PDF file_path,可选 name
extract-text 提取文本内容 file_path,可选 page
extract-images 提取嵌入图像 file_path,可选 page
get-metadata 获取文档元数据 file_path
extract-tables 提取表格数据 file_path,可选 page
extract-annotations 摘录评论/亮点 file_path
render-page 将页面渲染为图像 file_path, page,可选 dpi

发展

建筑与出版

准备分发包裹:

  1. 同步依赖关系并更新锁文件:
uv sync
  1. 构建包分发:
uv build

这将在 dist/ 目录。

  1. 发布到PyPI:
uv publish

注意:您需要通过环境变量或命令标志设置PyPI凭据:

  • 令牌: --token 或 UV_PUBLISH_TOKEN
  • 或用户名/密码: --username/UV_PUBLISH_USERNAME 和 --password/UV_PUBLISH_PASSWORD

调试

由于MCP服务器在stdio上运行,调试可能具有挑战性。为了达到最佳调试效果 经验,我们强烈建议使用 MCP检查员.

您可以通过以下方式启动MCP检查器 npm 使用此命令:

npx @modelcontextprotocol/inspector uv --directory /Users/cloudchase/Desktop/AverageJoesLab/mcp-servers/pdf-reader run pdf-reader

启动后,检查器将显示一个URL,您可以在浏览器中访问该URL以开始调试。