关于 MCP Document Reader
MCP Document Reader 是一个 MCP 文档读取服务,可读取 DOCX、PDF、TXT 与 Excel 文件,使 AI 助手能够读取本地文档内容。它适合在 Trae IDE 或 Claude Desktop 中使用,也可作为 Python 库调用。
主要功能
- 01支持 XLSX、XLS、DOCX、PDF 与 TXT
- 02统一的 read_document 工具接口
- 03按文件扩展名自动选择读取器
- 04可作为 Python 库使用
适用场景
- 01让 AI 助手读取本地 Word 或 PDF 报告
- 02在对话中分析 Excel 表格数据
- 03将文档内容提供给 AI 进行摘要
MCP 相关
该服务以 MCP 服务形式提供名为 read_document 的工具,接收文件路径参数并返回文档内容。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
MCP 文档阅读器
MCP(Model Context Protocol)文档阅读器——一款强大的 MCP 工具,可读取多种格式的文档,让 AI Agent 真正“阅读”您的文档。
功能
- 多格式支持:支持 4 种主流文档格式:Excel(XLSX/XLS)、DOCX、PDF 和 TXT
- MCP 协议:符合 MCP 标准,可作为 Trae IDE 等 AI 助手的工具使用
- 轻松集成:配置简单,即配即用
- 可靠运行:已在 Trae IDE 中成功测试并运行
- 文件系统支持:直接从文件系统读取文档
📚 文档
用户指南 · API 参考 · 贡献指南 · 更新日志 · 许可证
架构
graph TB
A[AI Assistant / User] -->|Call read_document| B[MCP Document Reader]
B -->|Detect file type| C{File Type?}
C -->|.docx| D[DOCX Reader]
C -->|.pdf| E[PDF Reader]
C -->|.xlsx/.xls| F[Excel Reader]
C -->|.txt| G[Text Reader]
D -->|Extract text| H[Return Content]
E -->|Extract text| H
F -->|Extract text| H
G -->|Extract text| H
H -->|Text content| A
style A fill:#e1f5ff
style B fill:#fff4e1
style C fill:#f0f0f0
style D fill:#e8f5e9
style E fill:#e8f5e9
style F fill:#e8f5e9
style G fill:#e8f5e9
style H fill:#fff9c4
支持的格式
| 格式 | 扩展名 | MIME 类型 | 功能 |
|---|---|---|---|
| Excel | .xlsx, .xls | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | 工作表和单元格数据提取 |
| DOCX | .docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | 文本和结构提取 |
| application/pdf | 文本提取 | ||
| 文本 | .txt | text/plain | 纯文本读取 |
安装
使用 pip(推荐)
pip install mcp-documents-reader
从源代码安装
git clone https://github.com/xt765/mcp_documents_reader.git
cd mcp_documents_reader
pip install -e .
MCP 工具
此服务提供以下工具:
read_document
通过统一的接口读取任何受支持类型的文档。
参数:
filename(字符串,必填):文档文件路径,支持绝对路径或相对路径。
配置
在 Trae IDE / Claude Desktop 中使用
将以下内容添加到您的 MCP 配置文件中:
选项 1:使用 PyPI(推荐)
{
"mcpServers": {
"mcp-document-reader": {
"command": "uvx",
"args": [
"mcp-documents-reader"
]
}
}
}
选项 2:使用 GitHub 仓库
{
"mcpServers": {
"mcp-document-reader": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/xt765/mcp_documents_reader",
"mcp_documents_reader"
]
}
}
}
选项 3:使用 Gitee 仓库(在中国访问更快)
{
"mcpServers": {
"mcp-document-reader": {
"command": "uvx",
"args": [
"--from",
"git+https://gitee.com/xt765/mcp_documents_reader",
"mcp_documents_reader"
]
}
}
}
使用方法
作为 MCP 工具使用
完成配置后,AI 助手可以直接调用以下工具:
# Read a DOCX file
read_document(filename="example.docx")
# Read a PDF file
read_document(filename="example.pdf")
# Read an Excel file
read_document(filename="example.xlsx")
# Read a text file
read_document(filename="example.txt")
作为 Python 库使用
from mcp_documents_reader import DocumentReaderFactory
# Using factory (recommended)
reader = DocumentReaderFactory.get_reader("document.pdf")
content = reader.read("/path/to/document.pdf")
# Check if format is supported
if DocumentReaderFactory.is_supported("file.xlsx"):
reader = DocumentReaderFactory.get_reader("file.xlsx")
content = reader.read("/path/to/file.xlsx")
工具接口详情
read_document
读取任何受支持的文档类型。
参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| filename | string | ✅ | 文档文件路径,支持绝对路径或相对路径 |
依赖项
核心依赖项
mcp>= 1.26.0 - MCP 协议实现python-docx>= 1.2.0 - DOCX 文件读取pypdf>= 6.8.0 - PDF 文件读取(替代 PyPDF2)openpyxl>= 3.1.5 - Excel 文件读取
开发依赖项
pytest>= 8.0.0 - 测试框架pytest-asyncio>= 0.24.0 - 异步测试支持pytest-cov>= 6.0.0 - 覆盖率报告basedpyright>= 0.28.0 - 类型检查ruff>= 0.8.0 - 代码检查与格式化
许可证
MIT 许可证
参与贡献
欢迎提交问题和拉取请求!
相关项目
- MCP Document Converter - 支持多种格式转换的 MCP 文档转换器
- Model Context Protocol - Model Context Protocol 官方文档
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。