Pdf4vllm

io.github.PyJudge由 GitHub 账号 PyJudge 发布v1.0.2更新于 Oct 24, 2026

PDF reader for vision LLMs. Auto-detects text corruption and switches to image mode.

概览

AI 生成的概览

读取本地 PDF 文件,按顺序返回文本、表格和图像块,并在文本损坏时自动切换为图像模式。

可以做什么
这是一个面向视觉大模型的本地 MCP 服务器,用于提取 PDF 内容。它提供 list_pdfs(按 glob 模式查找文件)、read_pdf(按顺序返回页面内容块,包括文本、表格、图像)和 grep_pdf(在 PDF 内搜索文本)。提取模式包括 auto(先尝试文本,检测到损坏时改用图像)、text_only 和 image_only。它会保留阅读顺序、限制页数以避免上下文溢出,并过滤掉徽标、线条和页眉页脚。
适用场景
当助手需要读取编码损坏或排版混乱的本地 PDF,并希望根据质量选择干净文本或页面图像时适用。也适合跨 PDF 搜索,或把扫描页交给视觉模型而不让 token 数量失控。
运行要求
以 Python 包(pdf4vllm-mcp)形式在本地运行,可通过 pip 或 uvx 安装,也可从克隆的源码目录在客户端中配置。grep_pdf 工具还需要系统安装 pdfgrep 程序。未声明需要账号、API 密钥或网络访问;可选设置如 PDF_MAX_PAGES 和 PDF_PAGE_IMAGE_DPI 可通过环境变量或 config.json 配置。
安装前请注意
该服务器会读取本地文件系统中的文件,请只指向你愿意让助手访问的目录。grep_pdf 依赖外部 pdfgrep 可执行文件。未声明需要凭据、付款或写入操作。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Pdf4vllm,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

pdf4vllm

[License: MIT] [Python 3.10+] [PyPI] [Open in Gitpod]

PDF reading MCP server optimized for vision LLMs.

한국어

문제

방식문제점
텍스트 추출인코딩 깨짐 → 쓰레기 출력, 이미지-텍스트 순서 뒤섞임
이미지 변환토큰 폭발 (특히 페이지 많을 때)

해결

pdf4vllm은 PDF가 지저분하다고 가정합니다.

  • 텍스트 손상 자동 감지 → 이미지로 자동 전환
  • 읽기 순서 보존 (텍스트 → 표 → 이미지 블록 순서대로)
  • 페이지 제한으로 컨텍스트 오버플로우 방지
  • 불필요한 이미지 자동 필터링 (로고, 선, 헤더/푸터)

설치

bash
pip install pdf4vllm-mcp# 또는uvx pdf4vllm-mcp

Claude Desktop 설정

bash
git clone https://github.com/PyJudge/pdf4vllm-mcp.gitcd pdf4vllm-mcppython scripts/install_mcp.py

또는 직접 설정 (~/Library/Application Support/Claude/claude_desktop_config.json):

json
{  "mcpServers": {    "pdf4vllm": {      "command": "/python/경로",      "args": ["/pdf4vllm-mcp/경로/src/server.py"]    }  }}

도구

도구설명
list_pdfsPDF 파일 찾기 (glob 패턴 name_pattern 지원)
read_pdfPDF 내용 블록으로 추출
grep_pdfPDF 내 텍스트 검색 (pdfgrep 설치 필요)

추출 모드

모드설명
auto (기본)텍스트 추출 시도 → 손상 감지 시 이미지로 전환
text_only텍스트/표만 추출, 이미지 없음
image_only페이지를 이미지로만 렌더링

Problem

ApproachIssue
Text extractionEncoding corruption → garbage output, mixed text-image ordering
Image conversionToken explosion (especially with many pages)

Solution

pdf4vllm assumes PDFs are messy.

  • Auto-detects text corruption → switches to image automatically
  • Preserves reading order (text → table → image blocks in sequence)
  • Page limits prevent context overflow
  • Filters unnecessary images (logos, lines, headers/footers)
PDF Input    ↓Corruption Detection (pdfminer.six + pattern analysis)    ↓┌─────────────┬─────────────┐│  Corrupted  │    Clean    ││  → Image    │  → Text +   ││    only     │    Tables + ││             │    Images   │└─────────────┴─────────────┘    ↓Ordered Blocks (JSON)

Install

bash
pip install pdf4vllm-mcp# or run without installinguvx pdf4vllm-mcp

Claude Desktop Setup

bash
git clone https://github.com/PyJudge/pdf4vllm-mcp.gitcd pdf4vllm-mcppython scripts/install_mcp.py

Or manually edit ~/Library/Application Support/Claude/claude_desktop_config.json:

json
{  "mcpServers": {    "pdf4vllm": {      "command": "/path/to/python",      "args": ["/path/to/pdf4vllm-mcp/src/server.py"]    }  }}

Claude Code Setup

Create .mcp.json in your project:

json
{  "mcpServers": {    "pdf4vllm": {      "command": "uvx",      "args": ["pdf4vllm-mcp"]    }  }}

Tools

ToolDescription
list_pdfsFind PDF files with glob filtering (name_pattern)
read_pdfExtract PDF content as ordered blocks
grep_pdfSearch text in PDFs using pdfgrep (requires pdfgrep installed)

Extraction Modes

ModeDescription
auto (default)Try text extraction → switch to image if corrupted
text_onlyText/tables only, no images
image_onlyRender pages as images only

Output Format

json
{  "pages": [    {      "page_number": 1,      "content_blocks": [        {"type": "text", "content": "..."},        {"type": "table", "content": "| A | B |"},        {"type": "image", "content": "[IMAGE_0]"}      ]    }  ]}

When text is corrupted:

json
{  "page_number": 2,  "content_blocks": [],  "text_corrupted": true,  "page_image": "[IMAGE_1]"}

Configuration

config.json or environment variables:

json
{  "max_pages_per_request": 10,  "max_image_dimension": 842,  "page_image_dpi": 100}
bash
export PDF_MAX_PAGES=20export PDF_PAGE_IMAGE_DPI=150

Test Server

bash
pip install pdf4vllm-mcp[test]python test_server.py# → http://localhost:8000

License

MIT


GitHub · PyPI

来源:README.md,提交 0ea75c6

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.2最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。