Word文档内容读取MCP服务
一个专门用于读取Word文档内容的MCP(Model Context Protocol)服务,提供五个核心的文档读取功能。
功能特性
- 文档信息获取: 获取Word文档的基本信息(标题、作者、创建时间等)
- 文本提取: 提取文档中的所有文本内容
- 大纲结构: 获取文档的标题层次结构
- 段落读取: 获取指定段落的文本内容
- 文本搜索: 在文档中搜索指定文本并返回位置信息
安装和配置
使用uv(推荐)
项目使用uv进行依赖管理,无需手动安装依赖:
# 进入项目目录
cd python/Word文档内容读取
# uv会自动管理所有依赖
MCP配置
将以下配置添加到Claude Desktop配置文件中:
{
"mcpServers": {
"Word文档内容读取": {
"timeout": 60,
"type": "stdio",
"command": "uvx",
"args": [
"word-document-reader-mcp@1.0.1"
],
"env": {}
}
}
}
注意: 请将 /path/to/Word文档内容读取 替换为项目的实际路径。
Claude Desktop配置文件位置
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/claude/claude_desktop_config.json
使用方法
配置完成后,在Claude中可以使用以下功能:
1. 获取文档信息
请获取文档 "example.docx" 的信息
2. 提取文档文本
请提取文档 "example.docx" 的所有文本内容
3. 获取文档大纲
请获取文档 "example.docx" 的大纲结构
4. 获取段落文本
请获取文档 "example.docx" 第3段的文本
5. 查找文本
在文档 "example.docx" 中查找 "重要信息"
可用工具
get_document_info_tool: 获取文档信息get_document_text_tool: 提取文档文本get_document_outline_tool: 获取文档大纲get_paragraph_text_from_document_tool: 获取段落文本find_text_in_document_tool: 查找文档文本
项目结构
word_document_reader/
├── __init__.py # 包初始化
├── main.py # MCP服务主程序
├── tools.py # 核心工具函数
└── utils.py # 辅助工具函数
依赖项
python-docx>=1.1.0: Word文档处理fastmcp>=2.8.1: MCP服务框架
错误处理
所有函数都包含完善的错误处理机制:
- 文件不存在时返回相应错误信息
- 无效参数时返回参数错误提示
- 处理异常时返回详细错误描述
注意事项
- 支持的文件格式:
.docx(如果传入的文件名没有扩展名,会自动添加.docx) - 段落索引从0开始计数
- 搜索功能支持区分大小写和全词匹配选项
- 返回的JSON数据使用UTF-8编码,支持中文显示
许可证
MIT License
Metadata
Release files for word-document-reader-mcp 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| word_document_reader_mcp-1.0.4.tar.gz | 8.8 kB | Without provenance | Details for word_document_reader_mcp-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| word_document_reader_mcp-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for word_document_reader_mcp-1.0.4-py3-none-any.whl |
Total release size: 18.2 kB
Release files / word_document_reader_mcp-1.0.4.tar.gz
| Download URL | word_document_reader_mcp-1.0.4.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54075aabd01f49e8626f63b3d29a658d8fae33151342fcdc66e40877b7a8c430
|
|
BLAKE2b-256 checksum How to use checksums |
118ce8eef2ba9f0d54e86f21b1e72a825a297bad96df1581e26d26e3fcda1043
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Release files / word_document_reader_mcp-1.0.4-py3-none-any.whl
| Download URL | word_document_reader_mcp-1.0.4-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f445418278036582297d7baed37335ccabb21f152a563a31de1578adefd10ace
|
|
BLAKE2b-256 checksum How to use checksums |
103bd2559ba5bdcedd62592f535984f54ac11b9b66a965720134f0404819ba7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Security for word-document-reader-mcp 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.