Skip to main content
Glama
hemanthx446

PowerPoint MCP Server

by hemanthx446

PowerPoint 模型上下文协议 (MCP) 服务器

一个基于 Python 的模型上下文协议 (MCP) 服务器,提供使用 fastmcp 和 python-pptx 创建、检查和编辑 PowerPoint 演示文稿的工具。

前置条件

  • Windows 操作系统

  • Python 3.12(已安装在 C:\Users\Lumbini_User\AppData\Local\Programs\Python\Python312)

  • 本地虚拟环境 .venv,已安装所需依赖项。

Related MCP server: Office-PowerPoint-MCP

暴露的工具

服务器注册并运行以下工具:

  1. create_presentation(path: str):在指定路径创建一个新的空白 PowerPoint 演示文稿。

  2. add_slide(path: str, layout_idx: int = 6):向 path 处的演示文稿添加一张新幻灯片,使用布局模板索引(例如 6 表示空白)。

  3. add_text(path, slide_idx, text, left_in, top_in, width_in, height_in, font_name, font_size_pt, bold, italic, color_hex, align):添加一个带有自定义格式文本的文本框。

  4. add_bullet_points(path, slide_idx, points, left_in, top_in, width_in, height_in, font_name, font_size_pt, color_hex):添加一个格式化的项目符号列表。

  5. add_shape(path, slide_idx, shape_type, left_in, top_in, width_in, height_in, fill_color_hex, line_color_hex, line_width_pt):插入几何形状,如矩形、椭圆、三角形等。

  6. add_picture(path, slide_idx, image_path, left_in, top_in, width_in, height_in):插入本地图片。

  7. add_table(path, slide_idx, rows, cols, left_in, top_in, width_in, height_in, data):插入并填充表格。

  8. get_presentation_info(path):返回所有幻灯片的详细结构、形状位置、文本和表格。

  9. search_replace_text(path, search_str, replace_str):在整个演示文稿中执行查找和替换,涉及文本框、形状和表格。

  10. delete_slide(path, slide_idx):删除指定索引处的幻灯片。

MCP 客户端配置

要向 MCP 主机(如 Claude Desktop 或 cursor)注册此服务器,请将以下条目添加到主机配置文件中:

{
  "mcpServers": {
    "powerpoint": {
      "command": "c:\\Users\\Lumbini_User\\Desktop\\PPT\\.venv\\Scripts\\python.exe",
      "args": [
        "c:\\Users\\Lumbini_User\\Desktop\\PPT\\ppt_mcp_server.py"
      ],
      "env": {}
    }
  }
}

本地开发与测试

  1. 激活虚拟环境:

    .venv\Scripts\Activate.ps1
  2. 直接运行服务器:

    python ppt_mcp_server.py

Related MCP Connectors

Related MCP Servers