一个由FastMCP驱动的服务器,用于通过编程方式创建、编辑和渲染PowerPoint(PPTX)演示文稿,具有幻灯片创建、内容插入和PNG渲染等功能。
multimedia-processingapp-automationdeveloper-tools
5.9k 查看 · 2026-07-07 更新
简介
一个由FastMCP驱动的服务器,用于通过编程方式创建、编辑和渲染PowerPoint(PPTX)演示文稿,具有幻灯片创建、内容插入和PNG渲染等功能。
简介
一个由FastMCP驱动的服务器,用于通过编程方式创建、编辑和渲染PowerPoint(PPTX)演示文稿,具有幻灯片创建、内容插入和PNG渲染等功能。
PPTX MCP 服务器
一个由 FastMCP 支持的服务器,用于以编程方式创建、编辑和渲染 PowerPoint (PPTX) 演示文稿。支持幻灯片创建、文本和形状插入、图像嵌入以及将幻灯片渲染为 PNG(使用 LibreOffice)。
功能
- 创建/清除演示文稿: 开始新的或重置现有的 PPTX 文件。
- 添加幻灯片: 插入具有可自定义布局的幻灯片。
- 文本与内容: 向幻灯片中添加标题、内容和自定义文本框。
- 形状: 插入各种 PowerPoint 形状(包括流程图元素)。
- 图像: 将图像嵌入到幻灯片中。
- 幻灯片描述: 获取幻灯片内容的文本摘要以便验证。
- 幻灯片渲染: 将幻灯片渲染为 PNG 图像(需要 LibreOffice)。
- 下载 PPTX: 下载生成的演示文稿文件。
要求
- Python 3.12+
- python-pptx
- Pillow
- FastMCP
- LibreOffice(用于幻灯片图像渲染;必须单独安装并确保在系统 PATH 中可用)
安装
-
安装 Python 依赖项: bash pip install -r requirements.txt
(或者查看
pyproject.toml了解依赖项) -
安装 LibreOffice(用于图像渲染):
- Linux:
sudo pacman -S libreoffice-fresh或sudo apt install libreoffice - macOS:
brew install --cask libreoffice - Windows: 从 libreoffice.org 下载
- Linux:
使用方法
启动服务器: bash python server.py
您可以使用环境变量设置服务器的主机名和端口:
HOST(默认:127.0.0.1)PORT(默认:8000)
例如,要在所有接口上运行并在端口 9000 上运行: bash HOST=0.0.0.0 PORT=9000 python server.py
或者(对于使用 FastMCP 的开发): bash fastmcp dev server.py
API 概览
服务器通过 FastMCP 提供工具和资源,包括:
create_or_clear_presentation(filename)add_slide(filename, layout_index)add_title_and_content(filename, slide_index, title, content)add_textbox(filename, slide_index, text, left_inches, top_inches, width_inches, height_inches, font_size_pt, bold)add_shape(filename, slide_index, shape_type_name, left_inches, top_inches, width_inches, height_inches, text)add_picture(filename, slide_index, image, left_inches, top_inches, width_inches, height_inches)get_slide_content_description(filename, slide_index)get_slide_image(filename, slide_index)(需要 LibreOffice)get_pptx_file(filename)
请参阅代码以获取完整的参数详情和可用形状类型。
演示文稿与模板
- 演示文稿保存在
presentations/目录中。 - 您可以在
presentations/templates/中添加自己的模板。
许可证
详见 LICENSE。
来源
- 来源:github
- 链接:https://github.com/samos123/pptx-mcp