Document Reader Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Document Reader Mcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
一个支持多种文档格式的 Model Context Protocol (MCP) 服务器,可以读取 Word、PDF、文本文件、RTF 等格式,并提供图片提取与分析功能。
# 方式1:使用安装脚本(推荐)
python install_deps.py
# 方式2:手动安装
pip install -r requirements.txtpython server.py在 Kiro IDE 中创建或编辑 .kiro/settings/mcp.json 文件:
方式1:简化配置(推荐)
{
"mcpServers": {
"document-reader": {
"command": "python",
"args": ["server.py"],
"cwd": "D:\\your-path\\document-reader-mcp",
"env": {
"PYTHONIOENCODING": "utf-8"
},
"disabled": false,
"autoApprove": [
"list_supported_formats",
"get_document_info",
"read_document",
"read_document_with_media"
]
}
}
}方式2:完整路径配置
{
"mcpServers": {
"document-reader": {
"command": "python",
"args": ["D:\\devolp\\code1\\document-reader-mcp-master\\document-reader-mcp\\server.py"],
"cwd": "D:\\devolp\\code1\\document-reader-mcp-master\\document-reader-mcp",
"env": {
"PYTHONPATH": "D:\\devolp\\code1\\document-reader-mcp-master\\document-reader-mcp",
"PYTHONIOENCODING": "utf-8"
},
"disabled": false,
"autoApprove": [
"list_supported_formats",
"get_document_info",
"read_document",
"read_document_with_media"
]
}
}
}配置说明:
cwd: 项目根目录路径PYTHONPATH: 确保模块导入正常(方式2需要)PYTHONIOENCODING: 确保中文字符正确显示autoApprove: 自动批准的安全工具列表,减少确认步骤# 测试图表分析
python simple_diagram_reader.py
# 测试核心功能
python test_core_features.py增强阅读文档,同时提取文字和图片内容
file_path: 文息
extract_documen提取文档中的图片和链接
file_path: 文档路径save_images: 是否保存图片到本地无需复杂配置
image_path: 图片路径特征
cx自动提取文字内容和所有图片,并进行结构分析。
当 AI-Agent 需要理解业
文件夹
analyze_s")
结构
├── server.py 主程序 析核心模块 ├── ins 依赖安装脚本 ├hon 依赖列表 └── extracted_ima
## 🔧 依赖说明
**核心依赖**:
- `mcp`: MCP 协议框架
- `pytho
- `PyPDF2`: PDF 文档处理
- `opencv-python`: 图像分析
- `numpy`: 数值计算
**可选依赖*
- `st
- `
## 设计理念
这个项目专注于**实用性**和***:
OCR 配置
- 基于图像结构分析理解图表
-传
- 为 AI-Agent 开发提供
## 📄 许可证
MIT License: {
"FASTMCP_LOG_LEVEL": "ERROR"
},
"disabled": false,
"autoApprove": ["list_supported_formats"]
}
}
}autoApprove: 自动批准的安全工具列表disabled: 设为 false 启用服务器cwd: 工作目录(本地安装时需要)PYTHONIOENCODING: 确保中文字符正确显示#### 读取Word文档
{
"tool": "read_document",
"arguments": {
"file_path": "report.docx"
}
}#### 读取PDF特定页面
{
"tool": "read_document",
"arguments": {
"file_path": "document.pdf",
"page_range": "1-5"
}
}#### 读取Excel文档
{
"tool": "read_document",
"arguments": {
"file_path": "data.xlsx"
}
}#### 读取Excel特定工作表
{
"tool": "read_document",
"arguments": {
"file_path": "data.xlsx",
"sheet_name": "Sheet1"
}
}#### 获取文档信息
{
"tool": "get_document_info",
"arguments": {
"file_path": "example.docx"
}
}#### 方式1:增强文档阅读(推荐)
{
"tool": "read_document_with_media",
"arguments": {
"file_path": "document.docx",
"include_media_info": true
}
}特点:
#### 方式2:专门媒体提取
{
"tool": "extract_document_media",
"arguments": {
"file_path": "document.docx",
"extract_images": true,
"extract_links": true,
"save_images": false
}
}特点:
#### 方式3:普通阅读(不解析图片)
{
"tool": "read_document",
"arguments": {
"file_path": "document.docx"
}
}特点:
当使用图片解析功能时,你会得到:
文档媒体信息 (example.docx):
摘要:
- 图片总数: 2
- 链接总数: 3
- 图片处理错误: 0
- 链接处理错误: 0
图片信息:
1. image1.png
- 格式: PNG
- 尺寸: (670, 346)
- 大小: 174900 字节
- 流程图分析:
- 文本: 检测到的文字内容
- 节点数: 5
- 连线数: 4
2. chart.jpg
- 格式: JPEG
- 尺寸: (800, 600)
- 大小: 245600 字节
链接信息:
1. https://www.example.com
- 域名: www.example.com
- 协议: https
- 状态: 可访问 (HTTP 200)#### 查看支持格式
{
"tool": "list_supported_formats",
"arguments": {}
}#### 批量处理示例
# 在Kiro中,你可以这样批量处理文档
documents = ["doc1.docx", "doc2.pdf", "doc3.txt"]
for doc in documents:
# 使用增强阅读获取完整信息
result = mcp_call("read_document_with_media", {
"file_path": doc,
"include_media_info": True
})
print(f"处理完成: {doc}")PDF文档支持灵活的页面范围选择:
"all" - 所有页面(默认)"1-5" - 第1到5页"1,3,5" - 第1、3、5页"1-3,7,10-12" - 第1-3页、第7页、第10-12页.kiro/settings/mcp.json{
"mcpServers": {
"document-reader": {
"command": "python",
"args": ["server.py"],
"cwd": "D:\\your-path\\document-reader-mcp",
"env": {
"PYTHONIOENCODING": "utf-8"
},
"disabled": false,
"autoApprove": [
"list_supported_formats",
"get_document_info"
]
}
}
}#### 在聊天中使用
请帮我读取这个Word文档的内容,并分析其中的图片信息:
文件路径:./reports/monthly-report.docxKiro会自动调用 read_document_with_media 工具。
#### 批量文档分析
请分析这个文件夹中所有Word文档的媒体信息:
- ./docs/report1.docx
- ./docs/report2.docx
- ./docs/presentation.docx#### 文档格式转换准备
我需要将这些PDF文档转换为Markdown,
请先帮我分析文档结构和媒体内容:
./pdfs/technical-guide.pdf#### 常见问题
cwd 路径是否正确server.py 文件存在"PYTHONIOENCODING": "utf-8"Pillow 库:pip install Pillowrequests 库:pip install requests#### 调试方法
{
"tool": "list_supported_formats",
"arguments": {}
}{
"tool": "list_supported_formats",
"arguments": {}
}返回结果会显示各个依赖库的安装状态。
#### 选择合适的工具
read_document(最快)read_document_with_mediaextract_document_media#### 大文件处理
{
"tool": "read_document",
"arguments": {
"file_path": "large-document.pdf",
"page_range": "1-10"
}
}对于大型PDF,使用页面范围限制可以显著提升性能。
#### 批量处理建议
get_document_info 先了解文件大小#### 1. 文档分析工作流
1. get_document_info - 了解文档基本信息
2. read_document - 快速获取文本内容
3. read_document_with_media - 深入分析(如需要)#### 2. 媒体资源管理
{
"tool": "extract_document_media",
"arguments": {
"file_path": "document.docx",
"extract_images": true,
"extract_links": true,
"save_images": true
}
}设置 save_images: true 可以将图片保存到本地,便于后续处理。
#### 3. 错误处理
list_supported_formats 确认依赖库状态| 操作 | 平均耗时 | 内存使用 |
|---|---|---|
| 读取文本文件 (1MB) | < 0.1秒 | 低 |
| 读取Word文档 (5MB) | < 0.5秒 | 中等 |
| 读取PDF文档 (10MB) | < 1秒 | 中等 |
| 图片提取 (含10张图) | < 2秒 | 较高 |
| 链接验证 (10个链接) | 2-5秒 | 低 |
mcp - MCP协议支持python-docx - Word文档处理PyPDF2 - PDF文档处理striprtf - RTF文档处理Pillow - 图片处理和分析requests - 链接验证(可选)# 安装所有依赖
pip install -r requirements.txt
# 或单独安装
pip install mcp python-docx PyPDF2 striprtf Pillow requests openpyxl pandas| 工具名称 | 读取文本 | 解析图片 | 提取链接 | 性能 | 适用场景 |
|---|---|---|---|---|---|
read_document | ✅ | ❌ | ❌ | 🚀🚀🚀 | 快速文本阅读 |
read_document_with_media | ✅ | ✅ | ✅ | 🚀🚀 | 完整文档分析 |
extract_document_media | ❌ | ✅ | ✅ | 🚀 | 专门媒体提取 |
get_document_info | ❌ | ❌ | ❌ | 🚀🚀🚀 | 文档信息查看 |
list_supported_formats | ❌ | ❌ | ❌ | 🚀🚀🚀 | 功能状态检查 |
| 格式 | 扩展名 | 文本读取 | 图片提取 | 链接提取 | 页面范围 |
|---|---|---|---|---|---|
| Word文档 | .docx | ✅ | ✅ | ✅ | ❌ |
| PDF文档 | ✅ | ❌ | ✅ | ✅ | |
| Excel文档 | .xlsx, .xls | ✅ | ✅ | ✅ | ❌ |
| 纯文本 | .txt, .md | ✅ | ❌ | ✅ | ❌ |
| RTF文档 | .rtf | ✅ | ❌ | ❌ | ❌ |
| 代码文件 | .py, .js, .html, .css | ✅ | ❌ | ✅ | ❌ |
| 场景 | 推荐工具 | 配置建议 |
|---|---|---|
| 快速浏览文档内容 | read_document | 无特殊配置 |
| 文档内容+媒体分析 | read_document_with_media | include_media_info: true |
| 媒体资源清单 | extract_document_media | save_images: true |
| 链接有效性检查 | extract_document_media | 安装 requests 库 |
| 大文件处理 | read_document | 使用 page_range |
| 批量文档处理 | 组合使用 | 先用 get_document_info |
read_document_with_media 工具extract_document_media 工具MIT License
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.