office-editor-mcp
Office Document Processing MCP Server
一个用于办公文档处理的 MCP(模型上下文协议)服务器,支持在 MCP 客户端中创建和编辑 Word、Excel 和 PowerPoint 文档,而无需离开 AI 助手环境。
概述
Office-Editor-MCP 实现了 Model Context Protocol 标准,将 Office 文档操作以工具和资源的形式暴露出来。它充当 AI 助手与 Microsoft Office 文档之间的桥梁,使您能够通过 AI 助手创建、编辑、格式化和分析各种 Office 文档。
Related MCP server: word-doc-mcp
功能特性
Word 文档操作
文档管理
创建带有元数据(标题、作者等)的新 Word 文档
提取文本内容并分析文档结构
查看文档属性和统计信息
列出目录中的可用文档
创建文档副本
内容创建
添加不同级别的标题
插入可自定义样式的段落
创建包含自定义数据的表格
添加按比例缩放的图片
插入分页符
文本格式化
格式化特定文本部分(粗体、斜体、下划线)
更改文本颜色和字体属性
对文本元素应用自定义样式
在整个文档中搜索并替换文本
Excel 操作
工作簿管理
创建新的 Excel 工作簿
打开现有的 Excel 文件
添加/删除/重命名工作表
数据处理
读写单元格内容
插入/删除行和列
排序和筛选数据
应用公式和函数
PowerPoint 操作
演示文稿管理
创建新的 PowerPoint 演示文稿
添加/删除/重新排列幻灯片
设置幻灯片主题和背景
内容编辑
添加文本和图形元素
插入表格和图表
添加动画和切换效果
高级功能
OCR 识别(从图像中提取文本)
文档比较(比较文档之间的差异)
文档翻译
文档加密和解密
表格数据导入/导出(数据库交互)
安装指南
前提条件
Python 3.10 或更高版本
pip 包管理器
仅当需要使用 Windows COM 功能(如 PDF 导出、动画、切换效果和旧版 Office 格式)时才需要 Microsoft Office
使用
ocr_recognize_text时需要 Tesseract OCR
基本安装
# Clone the repository
git clone https://github.com/theWDY/office-editor-mcp.git
cd office-editor-mcp
# Install dependencies
pip install -r requirements.txt该仓库提供了四个独立的 MCP 服务器:word_server.py、excel_server.py、powerpoint_server.py 和 general_server.py。只需配置你需要的服务器。仓库中已包含的 .cursor/mcp.json 提供了一个完整的四服务器示例。
配置
在 Cursor 中配置
方法一:UI 配置
打开 Cursor
转到 设置 > 功能 > MCP
点击“+ 添加新的 MCP 服务器”
填写配置信息:
名称:
Office Assistant(可按偏好修改)类型:选择
stdio命令:输入运行服务器的完整路径,例如:
python /path/to/office-editor-mcp/word_server.py注意:请替换为你的实际文件路径
方法二:JSON 配置文件(推荐)
在项目目录中创建
.cursor文件夹(如果不存在)在该文件夹中创建
mcp.json文件,内容如下:
{
"mcpServers": {
"office-assistant": {
"command": "python",
"args": ["/path/to/office-editor-mcp/word_server.py"],
"env": {"OFFICE_EDIT_PATH": "/path/to/output"}
}
}
}在 Claude for Desktop 中配置
编辑 Claude 配置文件:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
添加以下配置:
{
"mcpServers": {
"office-document-server": {
"command": "python",
"args": [
"/path/to/office-editor-mcp/word_server.py"
]
}
}
}重启 Claude 以应用配置。
由 general_server.py 处理的所有路径必须位于 OFFICE_EDIT_PATH 内。除非显式配置了 OFFICE_ALLOW_DESTRUCTIVE=true,否则移动和删除操作将被禁用。
新建的加密文件使用带随机盐和 Scrypt 密码派生函数的版本化 Fernet 容器。现有的加密文件仍然可读,并且可以重新加密以进行升级。批量操作限制为每个请求 100 个文件和 16 个工作进程。
使用示例
配置完成后,你可以向 AI 助手发出如下命令:
Word 文档操作
“创建一个名为 'quarterly_report.docx' 的新文档,并包含标题页”
“向文档添加一个标题和三个段落”
“插入一个包含销售数据的 4x4 表格”
“将第 2 段中的单词 'important' 设置为粗体和红色”
“搜索并将所有 'old term' 替换为 'new term'”
Excel 操作
“创建一个名为 'financial_analysis.xlsx' 的新 Excel 工作簿”
“在单元格 A1 中插入 'Quarterly Sales' 作为标题”
“创建一个包含部门销售数据的表格并计算总和”
“为销售数据创建柱状图”
“按降序对 B 列中的数据进行排序”
PowerPoint 操作
“创建一个名为 'project_presentation.pptx' 的演示文稿”
“添加一个标题为 'Project Overview' 的新幻灯片”
“在第 2 张幻灯片中插入公司徽标”
“为标题添加飞入动画”
API 参考
Word 文档操作
# Document Creation and Properties
create_document(filename, title=None, author=None)
get_document_info(filename)
get_document_text(filename)
get_document_outline(filename)
list_available_documents(directory=".")
copy_document(source_filename, destination_filename=None)
# Content Addition
add_heading(filename, text, level=1)
add_paragraph(filename, text, style=None)
add_table(filename, rows, cols, data=None)
add_picture(filename, image_path, width=None)
add_page_break(filename)
# Text Formatting
format_text(filename, paragraph_index, start_pos, end_pos, bold=None,
italic=None, underline=None, color=None, font_size=None, font_name=None)
search_and_replace(filename, find_text, replace_text)
delete_paragraph(filename, paragraph_index)
create_custom_style(filename, style_name, bold=None, italic=None,
font_size=None, font_name=None, color=None, base_style=None)Excel 操作
# Workbook Operations
create_workbook(filename)
open_workbook(filename)
save_workbook(filename, new_filename=None)
add_worksheet(filename, sheet_name=None)
list_worksheets(filename)
# Cell Operations
read_cell(filename, sheet_name, cell_reference)
write_cell(filename, sheet_name, cell_reference, value)
format_cell(filename, sheet_name, cell_reference, **format_args)PowerPoint 操作
# Presentation Operations
create_presentation(filename)
open_presentation(filename)
save_presentation(filename, new_filename=None)
add_slide(filename, layout=None)故障排除
常见问题
缺少样式
某些文档可能缺少标题和表格操作所需的样式
服务器将尝试创建缺失的样式或使用直接格式化
为获得最佳效果,请使用带有标准 Office 样式的模板
权限问题
确保服务器具有对文档路径的读写权限
使用
copy_document函数创建锁定文档的可编辑副本如果操作失败,请检查文件所有者和权限
图片插入问题
为图片文件使用绝对路径
验证图片格式兼容性(推荐使用 JPEG、PNG)
检查图片文件大小和权限
调试
通过设置环境变量启用详细日志记录:
export MCP_DEBUG=1 # Linux/macOS
set MCP_DEBUG=1 # Windows实现进度
✅ 构建 MCP 服务器基本框架
✅ 与 AI 助手成功集成
✅ 基本的 Word 文档操作
✅ 基本的 Excel 工作簿操作
✅ 基本的 PowerPoint 演示文稿操作
✅ 高级功能增强
✅ 性能优化
✅ 跨平台兼容性测试
贡献
欢迎贡献!请随时提交 Pull Request。
Fork 该仓库
创建你的功能分支(
git checkout -b feature/amazing-feature)提交你的更改(
git commit -m 'Add some amazing feature')推送到分支(
git push origin feature/amazing-feature)打开一个 Pull Request
许可证
本项目采用 MIT 许可证授权 - 有关详细信息,请参阅 LICENSE 文件。
致谢
感谢 Model Context Protocol 提供协议规范
感谢 python-docx 用于 Word 文档处理
感谢 openpyxl 用于 Excel 处理
感谢 python-pptx 用于 PowerPoint 处理
注意:此服务器会与您系统上的文档文件进行交互。在 AI 助手或其他 MCP 客户端中确认操作之前,请始终核实所请求的操作是否合适。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseBqualityBmaintenanceMCP server for Office document automation, enabling AI assistants to create, read, and clone Word/Excel/PPT templates while preserving formatting.41
- AlicenseAqualityCmaintenanceMCP server for creating and reading Word (.docx) documents with rich formatting support.2313MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for generating Word documents and Google Docs with structured formatting, templates, and rich text.MIT
- AlicenseNot gradedqualityCmaintenanceMCP server enabling AI to control WPS Office (Writer/Calc/Impress) for document creation, editing, export, and live typing.MIT
Related MCP Connectors
An MCP server that integrates with Discord to provide AI-powered features.
MCP server for generating rough-draft project plans from natural-language prompts.
Presentations.AI MCP server — create designed slide decks from a topic, text, or document.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/theWDY/office-editor-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server