PPTX MCP 服务器是一个基于 FastMCP 的服务器,可用于以编程方式创建、编辑和渲染 PowerPoint (PPTX) 演示文稿。它支持幻灯片创建、文本和形状插入、图片嵌入,还能将幻灯片渲染为 PNG 图像(借助 LibreOffice),功能强大且实用。
启动服务器:
python server.py
你可以通过环境变量设置服务器的主机和端口:
HOST(默认:127.0.0.1)PORT(默认:8000)例如,要在所有接口上运行并使用 9000 端口:
HOST=0.0.0.0 PORT=9000 python server.py
或(用于开发环境中的 FastMCP):
fastmcp dev server.py
pip install -r requirements.txt
(或查看 pyproject.toml 获取依赖信息)
sudo pacman -S libreoffice-fresh 或 sudo apt install libreofficebrew install --cask libreoffice# 启动服务器
python server.py
# 在所有接口上运行并使用 9000 端口
HOST=0.0.0.0 PORT=9000 python server.py
# 用于开发环境中的 FastMCP
fastmcp dev server.py
服务器通过 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/ 中添加自己的模板。