local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Integrates with Python's docx library to provide Word document processing capabilities including creating, editing, and managing documents, with support for formatting, tables, images, and layout controls.
Docx MCP 服务
基于FastMCP库的Docx文档处理服务,支持使用Cursor中的AI助手创建、编辑和管理Word文档。
特征
- 完整的文档操作:支持创建、打开、保存文档,以及添加、编辑和删除内容
- 格式:支持设置字体、颜色、大小、对齐方式和其他格式选项
- 表格处理:支持创建、编辑、合并和拆分表格单元格
- 图片插入:支持插入图片并设置其大小
- 布局控制:支持设置页边距、添加分页符等布局元素
- 查询功能:支持检索文档信息、段落内容和表格数据
- 方便的编辑:支持查找和替换功能
- 部分编辑:支持替换特定部分的内容,同时保留原始格式和样式
安装依赖项
确保安装了 Python 3.10+,然后安装以下依赖项:
Copy
用法
在 Cursor 中用作 MCP 服务
- 打开 Cursor 并转到“设置”
- 找到
Features > MCP Servers
部分 - 点击
Add new MCP server
- 填写以下信息:
- 名称:MCP_DOCX
- 类型:命令
- 命令:
python3 /path/to/MCP_dox/server.py
(替换为server.py
的实际路径)
- 单击
Add
以添加服务
添加后,你就可以在Cursor的AI助手中使用自然语言操作Word文档了,例如:
- “创建一个新的Word文档并将其保存到桌面”
- “添加 3 级标题”
- “插入一个 3x4 表格并填充数据”
- “将第二段设置为粗体并居中对齐”
支持的操作
该服务支持以下操作:
- 文档管理:
create_document
、open_document
、save_document
- 内容添加:
add_paragraph
、add_heading
、add_table
、add_picture
- 内容编辑:
edit_paragraph
、delete_paragraph
、delete_text
- 表操作:
add_table_row
、delete_table_row
、edit_table_cell
、merge_table_cells
、split_table
- 布局控制:
add_page_break
、set_page_margins
- 查询函数:
get_document_info
、get_paragraphs
、get_tables
、search_text
- 文件操作:
create_document
、open_document
、save_document
、save_as_document
、create_document_copy
- 章节编辑:
replace_section
、edit_section_by_keyword
- 其他函数:
find_and_replace
、search_and_replace
(具有预览功能)
工作原理
- 该服务使用 Python-docx 库来处理 Word 文档
- 它通过 FastMCP 库实现 MCP 协议,以便与 AI 助手进行通信
- 它处理请求并返回格式化的响应
- 支持完整的错误处理和状态报告
排版功能
该服务具有良好的排版理解能力:
- 文本层次结构:支持标题级别(1-9)和段落组织
- 页面布局:支持页边距设置
- 视觉元素:支持字体样式(粗体、斜体、下划线、颜色)和对齐方式
- 表格布局:支持创建表格、合并单元格、拆分表格、设置表格格式
- 分页控制:支持添加分页符
开发说明
server.py
- 使用 FastMCP 库实现 MCP 服务的核心
故障排除
如果您在使用 Cursor 时遇到问题,请尝试以下步骤:
- 确保正确安装了 Python 3.10+
- 确保 python-docx 和 mcp 库已正确安装
- 检查服务器路径是否正确
- 重新启动 Cursor 应用程序
笔记
- 确保 python-docx 和 mcp 库已正确安装
- 确保路径中的中文字符能够正确处理
- 使用绝对路径可以避免路径解析问题
执照
MIT 许可证
This server cannot be installed
基于 FastMCP 的强大 Word 文档处理服务,使 AI 助手能够创建、编辑和管理 docx 文件,并支持完整的格式设置。编辑内容时保留原始样式。
- Features
- Installation Dependencies
- Usage
- Supported Operations
- How It Works
- Typography Capabilities
- Development Notes
- Troubleshooting
- Notes
- License