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 分

    請在儲存庫或註冊中心條目中宣告授權條款。