文档阅读器MCP服务器
一个MCP(模型上下文协议)服务器,允许AI助手读取PDF、Word、Excel和PowerPoint文件,而无需打开上下文窗口。
](https://npmjs.com/package/pdf-ppt-mcp) 
______________________________________________________________________
为什么存在
大多数AI工具试图一次将整个文档转储到提示符中。此服务器通过以下方式解决了这个问题 语境高效阅读 通过公开以下工具:
- 获取文档 元数据优先 (页数、纸张名称)
- 阅读 一次一页/幻灯片/一页
- 搜索 在整个文档中,仅返回相关片段
这使您的上下文窗口保持干净,同时仍允许AI访问大型文档。
______________________________________________________________________
支持的文件类型
| 格式 | 扩展名 | 如何阅读 |
|---|---|---|
.pdf | 逐页(原生PDF分页) | |
| Word | .docx | 段落感知分块 |
| Excel | .xlsx, .xls | 逐页(每页完整CSV) |
| PowerPoint | .pptx, .ppt | 逐个幻灯片(真正的幻灯片提取) |
______________________________________________________________________
快速开始
使用npx立即运行(推荐)
npx -y pdf-ppt-mcp或全局安装
npm install -g pdf-ppt-mcp
mcp-document-server或者克隆并在本地运行
git clone https://github.com/abdo544445/pdf-ppt-mcp.git
cd pdf-ppt-mcp
npm install
npm run build
npm start______________________________________________________________________
集成指南
VS代码(临床/房间代码/副驾驶MCP)
添加到MCP配置文件(通常 ~/.cline/mcp_settings.json 或 .vscode/mcp.json):
{
"mcpServers": {
"document-reader": {
"command": "npx",
"args": ["-y", "pdf-ppt-mcp"]
}
}
}光标
打开 设置->MCP 并添加:
{
"mcpServers": {
"document-reader": {
"command": "npx",
"args": ["-y", "pdf-ppt-mcp"]
}
}
}反重力/克劳德桌面
在你的 claude_desktop_config.json:
{
"mcpServers": {
"document-reader": {
"command": "npx",
"args": ["-y", "pdf-ppt-mcp"]
}
}
}本地路径(如果您克隆了仓库)
{
"mcpServers": {
"document-reader": {
"command": "node",
"args": ["/absolute/path/to/pdf-ppt-mcp/build/index.js"]
}
}
}______________________________________________________________________
可用的MCP工具
1. get_document_info
总是先打这个电话。返回元数据,以便AI在尝试读取文档之前知道文档的大小。
输入:
| 参数 | 类型 | 说明 |
|---|---|---|
filePath | string | 文档的绝对路径 |
输出示例:
report.pdf — PDF document
Total pages: 42
data.xlsx — Excel workbook
Sheets (3): "Summary", "Q1 Data", "Q2 Data"
slides.pptx — PowerPoint presentation
Total slides: 12______________________________________________________________________
2. read_document_page
一次阅读一个特定的页面、块或表,以避免加载整个文档。
输入:
| 参数 | 类型 | 说明 |
|---|---|---|
filePath | string | 文档的绝对路径 |
pageOrSheet | string | PDF/Word/PPT:页面/块/幻灯片编号(例如。 "3"). Excel:工作表名称(例如。 "Sheet1") |
示例调用:
// Read page 5 of a PDF
{ "filePath": "/docs/report.pdf", "pageOrSheet": "5" }
// Read slide 2 of a PPTX
{ "filePath": "/docs/deck.pptx", "pageOrSheet": "2" }
// Read the "Sales" sheet of an Excel file
{ "filePath": "/docs/data.xlsx", "pageOrSheet": "Sales" }
// Read chunk 3 of a Word document
{ "filePath": "/docs/contract.docx", "pageOrSheet": "3" }______________________________________________________________________
3. search_document
在整个文档中搜索关键字。返回与周围上下文片段匹配的页面/幻灯片/块。
输入:
| 参数 | 类型 | 说明 |
|---|---|---|
filePath | string | 文档的绝对路径 |
query | string | 搜索词(不区分大小写) |
输出示例:
Found 2 match(es) for "revenue":
[Page 7]:
...total revenue for Q3 was $4.2M, representing a 12% increase over...
[Page 23]:
...projected revenue targets were exceeded in all regions except...______________________________________________________________________
4. list_directory
列出文件夹中所有支持的文档文件。有助于发现可用的文档。
输入:
| 参数 | 类型 | 说明 |
|---|---|---|
directoryPath | string | 目录的绝对路径 |
输出示例:
Found 4 document(s):
annual_report.pdf (2,341.2 KB)
budget_2025.xlsx (128.5 KB)
proposal.docx (54.8 KB)
presentation.pptx (8,902.1 KB)______________________________________________________________________
5. read_full_document
一次阅读整个文档。仅适用于小型文档。
警告: 使用read_document_page或search_document对于大型文档,避免填充上下文窗口。
输入:
| 参数 | 类型 | 说明 |
|---|---|---|
filePath | string | 文档的绝对路径 |
maxChunks | number | 要读取的最大页面/块数(默认值: 10,最大值: 50) |
______________________________________________________________________
人工智能助手的推荐使用模式
当AI助手使用此服务器时,建议的流程是:
1. list_directory("/path/to/folder") -> discover available documents
2. get_document_info("/path/to/doc.pdf") -> learn total pages
3. search_document("/path/to/doc.pdf", "key term") -> find relevant pages
4. read_document_page("/path/to/doc.pdf", "7") -> read specific page与加载整个文档相比,这种方法通常使用不到5%的上下文。
______________________________________________________________________
VS代码扩展(PDF/PPT MCP资源管理器)
此项目包括一个充当图形包装器的官方Visual Studio Code扩展。它可以无缝地直观地查找、管理和处理支持的文档,并自动将它们连接到您的AI助手。
扩展功能
- 文档资源管理器: 立即在新的侧边栏树视图中清晰地找到所有支持的文档(.pdf、.docx、.xlsx、.pptx、.csv)。
- 自动配置助手: 单击配置,将MCP服务器直接注入到跨VS Code和Cursor的Cline或RooCode JSON配置中。
- 复制AI路径: 只需单击一下,即可为您的AI助手复制精心制作的带有绝对路径的提示。
- 向AI询问文档: 右键单击可自动生成一个自定义提示,其中包含您对文档的具体问题。
- 对外开放: 直接从VS Code侧栏启动本机应用程序(Word、Excel、Acrobat)。
- 添加外部文件: 浏览您的操作系统,并立即将外部文档复制到您的活动工作区中,以便AI可以读取它们。
- 工作区管理: 删除文档或直接从扩展名在操作系统文件资源管理器中显示它们。
- 实时更新: 文件系统监视器会自动使您的侧边栏与实际项目目录保持同步。
______________________________________________________________________
建筑
服务器连接到您的AI助手(通过MCP协议),并将请求路由到引擎盖下的专门解析服务。
[ 🤖 AI Assistant ] [ 📄 Document Reader Server ]
(Claude, Cursor) │
│ (routes commands)
▼
[ MCP Tools ]
│
┌──────────────────────┬──────────────────────┼──────────────────────┐
▼ ▼ ▼ ▼
[ read_page ] [ search_doc ] [ get_info ] [ read_full ]
│ │ │ │
└──────────────────────┴────────┬─────────────┴──────────────────────┘
│
▼
[ ⚙️ Parsing Services ]
│
┌──────────────┬───────────┴───┬──────────────┐
▼ ▼ ▼ ▼
PDFService WordService ExcelService PptService
(pdf-parse) (mammoth) (xlsx) (officeparser)
│ │ │ │
└──────────────┴───────┬───────┴──────────────┘
│
▼
[ 📁 Local File System ]文件夹结构
pdf-ppt-mcp/
├── src/
│ ├── index.ts # MCP Server - tool definitions and routing
│ └── services/
│ ├── pdf.service.ts # PDF parsing (pdf-parse v2)
│ ├── word.service.ts # Word parsing (mammoth)
│ ├── excel.service.ts # Excel parsing (xlsx)
│ └── ppt.service.ts # PPT parsing (officeparser)
├── build/ # Compiled output (auto-generated)
├── package.json
├── tsconfig.json
└── README.md使用的库
| 图书馆 | 目的 |
|---|---|
@modelcontextprotocol/sdk | MCP服务器/客户端协议 |
pdf-parse | PDF文本提取(v2,逐页) |
mammoth | Word .docx 文本提取 |
xlsx | Excel .xlsx/.xls 阅读 |
officeparser | PowerPoint .pptx/.ppt 幻灯片提取 |
______________________________________________________________________
发展
# Clone the repo
git clone https://github.com/abdo544445/pdf-ppt-mcp.git
cd pdf-ppt-mcp
# Install dependencies
npm install
# Build TypeScript
npm run build
# Start the server (stdio mode for MCP clients)
npm start______________________________________________________________________
需求
- Node.js >= 20.16.0
- 兼容MCP的客户端(VS Code与Cline/RooCode、Cursor、Antigravity、Claude Desktop等)
______________________________________________________________________
路线图
- \[x\] 发布到npm——使用安装
npx -y pdf-ppt-mcp - \[x\] 基于GUI的文档选择的VS代码扩展包装器
- \[x\] 支持
.csv文件(直接读取) - \[x\] 支持密码保护的PDF
- \[x\] 用于扫描/基于图像的PDF的OCR
______________________________________________________________________
贡献
欢迎拉取请求。对于重大更改,请先打开一个问题。
______________________________________________________________________
许可证
麻省理工学院(c) abdo544445
