Integration with PyPI for package distribution, allowing users to install the OfficeMCP server using pip or uv package managers.
Allows execution of Python code in the server context via the RunPython tool, enabling custom automation tasks and direct interaction with Office application COM objects.
Used to display the current PyPI package version badge in the README documentation.
OfficeMCP v1.0.5
通过AI模型控制微软应用程序最直观、最自由的方式。
办公室MCP
OfficeMCP 服务器专为 AI 设计,用于在 Windows 操作系统中通过 COM 接口自动化运行 Microsoft Office 应用程序(Word、Excel、PowerPoint、Access、OneNote、Visio、Project、WPS.word、Wps.powerpoint、wps.excel 等)。不适用于 Linux/MacOS。
警告
请注意,OfficeMCP 不限制 Python 的使用。特别是它有一个 RunPython(...) 工具可以执行由 AI 模型创建的 Python 代码。但这同时也是 OfficeMCP 最精彩的部分。我们无法保证您的 AI 模型不会对您的计算机造成任何损害。我们不承担任何责任。
系统要求
- Windows系统
- 已安装 Python 3.1 或更高版本
- uv 安装打开一个 shell 窗口并运行命令
pip安装uv
如何安装 OfficeMCP
安装OfficeMCP有两种方式或两种模式(也可以同时使用):
1. 使用OfficeMCP作为stdio服务器:
- 一个 OfficeMCP 服务器对应一个 mcp 客户端模式
- 将以下设置放入 vscode 的 MCP.json 文件或其他 AI IDE 的适当位置:
2. 使用OfficeMCP作为SSE服务器:
- 一个 OfficeMCP 服务器用于多 mcp 客户端模式
- 您可以根据需要更改端口和主机
- 这是使用 OfficeMCP 服务器的推荐方式。
步骤1:
在shell或power shell中运行一个命令:
uvx officemcp sse
Mcp 服务器 URL 将是:“ http://127.0.0.1:8888/sse ”或“ http://127.0.0.1:8888/sse ”默认工作文件夹是 D:@officemcp
或者类似下面的东西
uvx officemcp sse --端口 7777 --主机 127.0.0.8 --文件夹 D:\myfolder
“url”将是:“ http://127.0.0.8:7777/sse ”
第 2 步:
将以下设置放入 vscode 的 MCP.json 文件或其他 AI IDE 的适当位置:
或者
用法
在AI IDE上,您可以让AI模型通过OfficeMCP服务器控制Office应用程序:
- 你让AI模型打开一个新的Office应用程序。AI模型会向OfficeMCP服务器发送请求,OfficeMCP服务器会打开一个新的Office应用程序。
- 你让AI模型在当前的Office应用程序中做任何你想做的事情。AI模型会分析你的请求,并调用OfficeMCP服务器的工具来完成你的请求。
工具参考
工具:
- AvailabilityApps():检查您的计算机上是否安装了 Microsoft Office 应用程序。
- RunningApps():获取当前正在运行的 Office 应用程序列表。
- IsAppAvailable(...):检查是否安装了特定的 Office 应用程序。
- Launch(...):启动一个新的 Office 应用程序并设置其可见性。
- Visible(...):将指定 Office 应用程序的可见性设置为 True 或 False。
- Quit(...):退出指定的Office应用程序。
- Demonstrate():运行 OfficeMCP 自动化功能的演示。
- Speak(...):说出您传入的字符串。
- Beep(...):播放哔哔声。
- DefaultFolder(...):返回OfficeMCP根工作文件夹默认为(“D:\OfficeMCP”)
- IsFileExists(sub_path):检查 OfficeMCP 根文件夹中是否存在文件。
- DownloadImage(...):从给定的URL下载图像并将其保存到指定路径。
- RunPython(codes,data):在 OfficeMCP 服务器上下文中运行 python 代码。
- 这是OfficeMCP服务器中最强大的工具。AI可以使用此工具执行服务器支持的任何事情,包括自动化Office应用程序。
- 有一个对象“Officer”可以在python代码中使用,例如
Officer.Excel
保存当前的Excel com应用程序,还有Officer.Word,Officer.Powerpoint,Office.Visio,Officer.Access,Officer.OneNote,Officer.Visio,Officer.Project。Office.Kwps用于WPS word,Office.Ket用于WPS excell,Office.Kwpp用于WPS powerpoint。 - 有一个对象“output”作为RunPython(...)的返回,可以在python代码中使用,将自己的返回结果放入输出中,比如output="run python sccessed",然后RunPython将“run python sccessed”返回给AI模型。
- 您可以使用 Officer.Visio 创建一个新的 Visio 文档,然后使用 Officer.Visio.ActivePage 获取活动页面,并使用 Officer.Visio.ActivePage.DrawRectangle(...) 在页面上绘制一个矩形。
- 您可以使用 Officer.Excel 创建一个新的 Excel 文档,然后使用 Officer.Excel.ActiveSheet 获取活动工作表,使用 Officer.Excel.ActiveSheet.Cells(...) 获取单元格,使用 Officer.Excel.ActiveSheet.Cells(...).Value = "hello" 设置单元格值。
- 您可以使用 RunPython 工具运行代码来使用代码来控制它们。
- 将来会添加更多工具。
发展
This server cannot be installed
一个允许AI模型通过Windows上的COM接口自动化Microsoft Office应用程序(Word、Excel、PowerPoint等)的服务器,实现对Office功能的自然语言控制。
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that enables AI agents to interact with ClickUp workspaces, allowing task creation, management, and workspace organization through natural language commands.Last updated -255MIT License
- -securityFlicense-qualityA server that enables AI systems to browse, retrieve content from, and interact with web pages through the Model Context Protocol.Last updated -
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI assistants to create, read, edit, and format Microsoft Word documents through standardized tools and resources.Last updated -16139PythonMIT License
- AsecurityAlicenseAqualityA server that enables AI assistants to interact with the Omnisend marketing platform, supporting contact management, product management, and event tracking operations through natural language.Last updated -10TypeScriptApache 2.0