@sin-gang-ya-rou-geng-hao-chih/pdf-mcp-server
v1.0.5
Published
Model Context Protocol (MCP) server for PDF processing with OCR support
Downloads
348
Maintainers
Readme
@sin-gang-ya-rou-geng-hao-chih/pdf-mcp-server
支援 OCR 功能的 PDF 處理 Model Context Protocol (MCP) 伺服器。此伺服器為 Cursor IDE 和其他 MCP 相容客戶端提供完整的 PDF 操作功能。
中文 | English
功能特點
- ✅ PDF 文字提取:從 PDF 檔案中提取文字內容
- ✅ OCR 支援:使用 Tesseract.js 對掃描的 PDF 進行文字辨識
- ✅ 元資料提取:取得 PDF 元資料(頁數、作者、標題等)
- ✅ 文字搜尋:在 PDF 文件中搜尋文字
- ✅ PDF 合併:將多個 PDF 檔案合併為一個
- ✅ PDF 拆分:將 PDF 拆分為多個檔案
- ✅ PDF 轉圖片:將 PDF 頁面轉換為圖片(PNG、JPG、WebP)
- ✅ 頁面提取:提取指定頁面到新 PDF
- ✅ 多語言 OCR:支援 15+ 種語言,包括中文、日文、韓文
系統需求
- Node.js >= 18.0.0
- 支援的作業系統:Windows、Linux、macOS
安裝
全域安裝(推薦用於 Cursor)
npm install -g @sin-gang-ya-rou-geng-hao-chih/pdf-mcp-server本地安裝
npm install @sin-gang-ya-rou-geng-hao-chih/pdf-mcp-server從源碼安裝
git clone https://github.com/j0482k6j041/pdf-mcp-server.git
cd pdf-mcp-server
npm install配置
Cursor IDE 配置
在 Cursor 的 MCP 設定檔(~/.cursor/mcp.json 或專案層級的 .cursor/mcp.json)中加入以下內容:
STDIO 模式(推薦)
{
"mcpServers": {
"@sin-gang-ya-rou-geng-hao-chih/pdf-mcp-server": {
"command": "pdf-mcp-server",
"args": [],
"env": {}
}
}
}SSE 模式(HTTP)
{
"mcpServers": {
"pdf-mcp-server": {
"url": "http://localhost:3335/sse",
"enabled": true
}
}
}環境變數
在專案根目錄建立 .env 檔案:
# 傳輸模式:stdio(預設)或 sse
TRANSPORT=stdio
# HTTP 伺服器設定(用於 SSE 模式)
PORT=3335
HOST=0.0.0.0
# 日誌級別:error, warn, info, debug
LOG_LEVEL=info
# SSE 連線的 Ping 間隔(毫秒)
PING_INTERVAL=60000可用工具
| 工具名稱 | 功能說明 |
|----------|----------|
| pdf_read_text | 讀取 PDF 並提取文字內容 |
| pdf_ocr | 對 PDF 進行 OCR 辨識(支援掃描檔) |
| pdf_metadata | 取得 PDF 元資料(頁數、作者、標題等) |
| pdf_search | 在 PDF 中搜尋指定文字 |
| pdf_merge | 合併多個 PDF 檔案 |
| pdf_split | 拆分 PDF 為多個檔案 |
| pdf_to_images | 將 PDF 頁面轉換為圖片 |
| pdf_page_count | 取得 PDF 頁數 |
| pdf_extract_pages | 提取指定頁面到新 PDF |
| pdf_ocr_languages | 取得支援的 OCR 語言列表 |
使用範例
讀取 PDF 文字
pdf_read_text({ filePath: "C:/Documents/report.pdf" })OCR 辨識(繁體中文)
pdf_ocr({
filePath: "scanned_document.pdf",
language: "chi_tra", // 繁體中文
pages: [1, 2, 3] // 可選:指定頁面
})搜尋文字
pdf_search({
filePath: "document.pdf",
searchText: "重要",
caseSensitive: false
})合併 PDF
pdf_merge({
filePaths: ["part1.pdf", "part2.pdf", "part3.pdf"],
outputPath: "combined.pdf"
})拆分 PDF
// 每頁分開
pdf_split({
filePath: "document.pdf",
outputDir: "C:/Output"
})
// 按範圍拆分
pdf_split({
filePath: "document.pdf",
outputDir: "C:/Output",
pageRanges: [[1, 5], [6, 10]]
})轉換為圖片
pdf_to_images({
filePath: "document.pdf",
outputDir: "C:/Images",
format: "png",
density: 300
})提取頁面
pdf_extract_pages({
filePath: "document.pdf",
pageNumbers: [1, 3, 5],
outputPath: "extracted.pdf"
})支援的 OCR 語言
| 代碼 | 語言 |
|------|------|
| eng | English(英文) |
| chi_tra | 繁體中文 |
| chi_sim | 简体中文 |
| jpn | 日本語 |
| kor | 한국어 |
| fra | Français(法文) |
| deu | Deutsch(德文) |
| spa | Español(西班牙文) |
| ita | Italiano(義大利文) |
| por | Português(葡萄牙文) |
| rus | Русский(俄文) |
| ara | العربية(阿拉伯文) |
| hin | हिन्दी(印地文) |
| tha | ไทย(泰文) |
| vie | Tiếng Việt(越南文) |
多語言 OCR
使用 + 組合多種語言:
pdf_ocr({
filePath: "document.pdf",
language: "eng+chi_tra" // 英文 + 繁體中文
})執行伺服器
STDIO 模式(預設)
pdf-mcp-serverSSE 模式
TRANSPORT=sse pdf-mcp-server或在 Windows 上:
$env:TRANSPORT="sse"; pdf-mcp-server開發
測試
npm test啟動開發伺服器
npm start依賴套件
- @modelcontextprotocol/sdk:MCP SDK 伺服器實作
- pdf-parse:PDF 文字提取
- pdf-lib:PDF 操作(合併、拆分、提取)
- tesseract.js:OCR 引擎
- sharp:圖片處理
- pdf2pic:PDF 轉圖片
授權
ISC License - 詳見 LICENSE 檔案
相關連結
聯絡資訊
如有問題或建議,請:
- 提交 Issue
- 或聯絡開發團隊
English
Features
- ✅ PDF Text Extraction: Extract text content from PDF files
- ✅ OCR Support: Recognize text from scanned PDFs using Tesseract.js
- ✅ Metadata Extraction: Get PDF metadata (pages, author, title, etc.)
- ✅ Text Search: Search for text within PDF documents
- ✅ PDF Merge: Combine multiple PDF files into one
- ✅ PDF Split: Split PDF into multiple files
- ✅ PDF to Images: Convert PDF pages to images (PNG, JPG, WebP)
- ✅ Page Extraction: Extract specific pages to a new PDF
- ✅ Multi-language OCR: Support for 15+ languages including Chinese, Japanese, Korean
System Requirements
- Node.js >= 18.0.0
- Supported OS: Windows, Linux, macOS
Installation
Global Installation (Recommended for Cursor)
npm install -g @sin-gang-ya-rou-geng-hao-chih/pdf-mcp-serverLocal Installation
npm install @sin-gang-ya-rou-geng-hao-chih/pdf-mcp-serverConfiguration
Cursor IDE Configuration
Add the following to your Cursor MCP settings (~/.cursor/mcp.json or project-level .cursor/mcp.json):
STDIO Mode (Recommended)
{
"mcpServers": {
"@sin-gang-ya-rou-geng-hao-chih/pdf-mcp-server": {
"command": "pdf-mcp-server",
"args": [],
"env": {}
}
}
}SSE Mode (HTTP)
{
"mcpServers": {
"pdf-mcp-server": {
"url": "http://localhost:3335/sse",
"enabled": true
}
}
}Available Tools
| Tool | Description |
|------|-------------|
| pdf_read_text | Extract text content from PDF |
| pdf_ocr | Perform OCR on PDF (supports scanned documents) |
| pdf_metadata | Get PDF metadata (pages, author, title, etc.) |
| pdf_search | Search for text in PDF |
| pdf_merge | Merge multiple PDF files |
| pdf_split | Split PDF into multiple files |
| pdf_to_images | Convert PDF pages to images |
| pdf_page_count | Get PDF page count |
| pdf_extract_pages | Extract specific pages to new PDF |
| pdf_ocr_languages | Get supported OCR languages |
Usage Examples
Read PDF Text
pdf_read_text({ filePath: "C:/Documents/report.pdf" })OCR with Chinese
pdf_ocr({
filePath: "scanned_document.pdf",
language: "chi_tra", // Traditional Chinese
pages: [1, 2, 3] // Optional: specific pages
})Search Text
pdf_search({
filePath: "document.pdf",
searchText: "important",
caseSensitive: false
})Merge PDFs
pdf_merge({
filePaths: ["part1.pdf", "part2.pdf", "part3.pdf"],
outputPath: "combined.pdf"
})Split PDF
// Split into single pages
pdf_split({
filePath: "document.pdf",
outputDir: "C:/Output"
})
// Split by page ranges
pdf_split({
filePath: "document.pdf",
outputDir: "C:/Output",
pageRanges: [[1, 5], [6, 10]]
})Convert to Images
pdf_to_images({
filePath: "document.pdf",
outputDir: "C:/Images",
format: "png",
density: 300
})Extract Pages
pdf_extract_pages({
filePath: "document.pdf",
pageNumbers: [1, 3, 5],
outputPath: "extracted.pdf"
})Supported OCR Languages
| Code | Language |
|------|----------|
| eng | English |
| chi_tra | Chinese Traditional (繁體中文) |
| chi_sim | Chinese Simplified (简体中文) |
| jpn | Japanese (日本語) |
| kor | Korean (한국어) |
| fra | French (Français) |
| deu | German (Deutsch) |
| spa | Spanish (Español) |
| ita | Italian (Italiano) |
| por | Portuguese (Português) |
| rus | Russian (Русский) |
| ara | Arabic (العربية) |
| hin | Hindi (हिन्दी) |
| tha | Thai (ไทย) |
| vie | Vietnamese (Tiếng Việt) |
Multi-language OCR
Combine languages with +:
pdf_ocr({
filePath: "document.pdf",
language: "eng+chi_tra" // English + Traditional Chinese
})Running the Server
STDIO Mode (Default)
pdf-mcp-serverSSE Mode
TRANSPORT=sse pdf-mcp-serverOr on Windows:
$env:TRANSPORT="sse"; pdf-mcp-serverDevelopment
Clone and Install
git clone https://github.com/j0482k6j041/pdf-mcp-server.git
cd pdf-mcp-server
npm installRun in Development
npm startRun Tests
npm testDependencies
- @modelcontextprotocol/sdk: MCP SDK for server implementation
- pdf-parse: PDF text extraction
- pdf-lib: PDF manipulation (merge, split, extract)
- tesseract.js: OCR engine
- sharp: Image processing
- pdf2pic: PDF to image conversion
License
ISC License - See LICENSE file
Repository
https://github.com/j0482k6j041/pdf-mcp-server
Issues
https://github.com/j0482k6j041/pdf-mcp-server/issues
