MCP服务器幻灯片
一种模型上下文协议(MCP)服务器,通过LibreOffice将结构化JSON幻灯片转换为PowerPoint演示文稿(PPTX)。
概述
此MCP服务器使LLM能够通过以下方式生成PowerPoint演示文稿:
- 将markdown大纲转换为结构化JSON(由LLM完成)
- 从JSON构建OpenDocument演示(ODP)文件
- 使用LibreOffice无头模式将ODP转换为PPTX
- 返回演示文件或base64编码数据
先决条件
- Node.js 18或更高版本
- LibreOffice(用于ODP到PPTX的转换)
安装LibreOffice
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install libreoffice-impressmacOS:
brew install --cask libreoffice窗户: 从下载并安装 LibreOffice网站
安装
npm install
npm run build用法
标准模式(适用于MCP客户端)
npm start:stdio或者直接:
node dist/server/stdioServer.jsHTTP模式(用于web集成)
npm start:http服务器将于启动 http://localhost:3000 (或指定的端口 PORT 环境变量)。
配置
要与Claude Desktop等MCP客户端一起使用,请在MCP配置中添加:
{
"mcpServers": {
"slides-mcp": {
"command": "node",
"args": ["/path/to/slides-mcp/dist/server/stdioServer.js"]
}
}
}看 mcp-config-example.json 举一个完整的例子。
MCP工具: json_to_pptx
输入架构
{
"slideshow": {
"meta": {
"title": "Presentation Title",
"author": "Author Name (optional)"
},
"masters": [
{
"name": "Master Name",
"backgroundColor": "#ffffff (optional)"
}
],
"images": [
{
"id": "img1",
"dataBase64": "base64-encoded-image-data",
"mimeType": "image/png"
}
],
"slides": [
{
"id": "slide1 (optional)",
"title": "Slide Title (optional)",
"elements": [
{
"type": "text",
"placeholder": "title or content (optional)",
"text": "Text content",
"bullet": false,
"level": 0
},
{
"type": "image",
"imageRef": "img1",
"x": 2,
"y": 3,
"width": 10,
"height": 8
}
],
"notes": {
"plainText": "Speaker notes",
"paragraphs": ["Para 1", "Para 2"]
}
}
]
},
"options": {
"returnBase64": false
}
}输出
- 文件模式 (默认):返回生成的PPTX文件的路径
- Base64模式:返回base64编码的PPTX数据
示例
看 example-slideshow.json 查看幻灯片JSON结构的完整示例。
发展
构建
npm run build观看模式
npm run watch运行测试
npm test棉绒
npm run lint码头工人
构建Docker镜像
docker build -f docker/Dockerfile -t slides-mcp .使用HTTP传输运行
docker run -p 3000:3000 slides-mcp使用stdio传输运行
docker run -i slides-mcp node dist/server/stdioServer.js建筑
User markdown
→ LLM parsing prompt
→ slideshow JSON
→ MCP tool json_to_pptx(slideshow JSON)
→ ODP package
→ LibreOffice headless
→ PPTX file项目结构
src/
schema/
slideshowSchema.ts # Zod schema and types
odp/
index.ts # ODP orchestrator
contentXml.ts # Slide content generation
stylesXml.ts # Master styles and formatting
metaXml.ts # Document metadata
manifestXml.ts # ODP package manifest
images.ts # Image embedding
zip.ts # ODP ZIP packaging
libreoffice/
convert.ts # ODP to PPTX converter
tools/
jsonToPptx.ts # MCP tool implementation
server/
serverCore.ts # Core MCP server logic
stdioServer.ts # Stdio transport
httpServer.ts # HTTP transport许可证
麻省理工学院
