JSON转PPTX转换服务

Slides MCP Server是一个将结构化JSON幻灯片转换为PowerPoint演示文稿(PPTX)的服务,通过LibreOffice实现转换功能。

  • by gavanduffy
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 gavanduffy/slides-mcp

使用说明

MCP服务器幻灯片

一种模型上下文协议(MCP)服务器,通过LibreOffice将结构化JSON幻灯片转换为PowerPoint演示文稿(PPTX)。

概述

此MCP服务器使LLM能够通过以下方式生成PowerPoint演示文稿:

  1. 将markdown大纲转换为结构化JSON(由LLM完成)
  2. 从JSON构建OpenDocument演示(ODP)文件
  3. 使用LibreOffice无头模式将ODP转换为PPTX
  4. 返回演示文件或base64编码数据

先决条件

  • Node.js 18或更高版本
  • LibreOffice(用于ODP到PPTX的转换)

安装LibreOffice

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install libreoffice-impress

macOS:

brew install --cask libreoffice

窗户: 从下载并安装 LibreOffice网站

安装

npm install
npm run build

用法

标准模式(适用于MCP客户端)

npm start:stdio

或者直接:

node dist/server/stdioServer.js

HTTP模式(用于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

许可证

麻省理工学院