该项目借助模型控制协议(MCP),提供了一个可与 Claude Desktop 协同工作的 PowerPoint 自动化服务器。它能让 Claude 与 Microsoft PowerPoint 进行交互,实现创建演示文稿、添加幻灯片、修改内容等一系列任务。
本项目可让 Claude Desktop 与 Microsoft PowerPoint 实现交互,完成多种自动化操作。按以下步骤操作,即可快速开启使用之旅。
uv add fastmcp pywin32
要将 Claude Desktop 配置为使用此 MCP 服务器,请在 %APPDATA%\Claude\claude_desktop_config.json 中添加以下内容:
{
"mcpServers": {
"ppts": {
"command": "uv",
"args": ["run", "path/to/main.py"]
}
}
}
如果你使用的是虚拟环境或其他 Python 可执行文件(如 uv):
{
"mcpServers": {
"ppts": {
"command": "C:\\Path\\To\\Python\\Scripts\\uv.exe",
"args": ["run", "C:\\Path\\To\\Project\\main.py"]
}
}
}
配置完成后,你可以使用 Claude Desktop 来控制 PowerPoint。示例交互如下:
能否为我打开 PowerPoint?
请创建一个新的 PowerPoint 演示文稿。
在演示文稿中添加一张新幻灯片。
在幻灯片1上添加一个包含文本 "Hello World" 的文本框。
将演示文稿保存到 C:\Users\username\Documents\presentation.pptx
服务器提供了以下 PowerPoint 自动化功能:
initialize_powerpoint(): 连接到 PowerPoint 并使其可见get_presentations(): 列出所有已打开的演示文稿open_presentation(path): 打开一个来自文件的演示文稿get_slides(presentation_id): 获取演示文稿中的所有幻灯片get_slide_text(presentation_id, slide_id): 获取幻灯片的内容文本update_text(presentation_id, slide_id, shape_id, text): 更新形状中的文本save_presentation(presentation_id, path): 保存演示文稿close_presentation(presentation_id, save): 关闭演示文稿create_presentation(): 创建一个新的演示文稿add_slide(presentation_id, layout_type): 添加一张新幻灯片add_text_box(presentation_id, slide_id, text, left, top, width, height): 添加一个文本框set_slide_title(presentation_id, slide_id, title): 设置幻灯片的标题pywin32 和 fastmcp Python 包欢迎贡献!请随时提交 Pull Request。
MIT License