这是一个由FastMCP驱动的服务器,用于程序化地创建、编辑和渲染PowerPoint(PPTX)演示文稿。支持幻灯片创建、文本和形状插入、图片嵌入以及将幻灯片渲染为PNG图像(使用LibreOffice)。
安装Python依赖项:
pip install .
(从pyproject.toml安装依赖项)
可选:安装python-dotenv以设置开发环境变量:
pip install python-dotenv
安装LibreOffice(用于图像渲染):
sudo pacman -S libreoffice-fresh 或 sudo apt install libreofficebrew install --cask libreoffice启动服务器:
python server.py
对于带有环境变量的开发:
您可以使用环境变量设置服务器的主机和端口:
HOST(默认:127.0.0.1)PORT(默认:8000)例如,要在所有接口上运行并使用端口9000:
HOST=0.0.0.0 PORT=9000 python server.py
或者
在项目根目录下创建或编辑.env文件:
例如,要在所有接口上运行并使用端口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/中添加自己的模板。详情见LICENSE。