演示文稿生成服务

通过MCP协议提供AI辅助的演示文稿生成服务,支持从结构化内容创建PowerPoint幻灯片,并提供多种模板、布局和样式选择。

  • by kevinten-ai
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 kevinten-ai/mcp-presentation

使用说明

演示文稿生成器MCP服务器

AI-assisted presentation generation via MCP.
Create PowerPoint slides from structured content with templates, layouts, and styling.
Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible client.

中文文档

特性

  • 4工具 — create_slides, add_slide, export_to_pdf, create_thumbnail
  • 3个模板 --简约(干净)、企业(专业)、创意(大胆)
  • 4种布局 --title_and_content、title_only、image_full、两列
  • 真实.pptx输出 --可在PowerPoint、Google幻灯片、Keynote中完全编辑
  • PDF导出 --通过LibreOffice一键转换
  • 缩略图预览 --将第一张幻灯片渲染为PNG
  • 内置指南 --MCP资源,包括模板文档和使用技巧
  • 自动保存时间戳到输出目录

建筑学

User Prompt → AI Assistant (Claude / Cursor) → MCP Server → python-pptx
                                                   ↓
                                             Save .pptx / .pdf / .png

运作原理

服务器使用 python-pptx 从结构化JSON输入以编程方式构建PowerPoint文件。每张幻灯片都是由空白布局上的形状(文本框、矩形、图像)构建的,可以完全控制位置和样式。

工具 输入 输出 引擎
create_slides 标题+幻灯片JSON+模板 .pptx 文件 python pptx
add_slide 现有.pptx+幻灯片数据 已更新 .pptx python pptx
export_to_pdf .pptx 文件 .pdf 文件 LibreOffice命令行界面
create_thumbnail .pptx 文件 .png 图片 枕头

快速开始

1.配置MCP

Claude Code (CLI)
claude mcp add --transport stdio mcp-presentation \
  -- uv --directory /path/to/mcp-presentation run presentation-gen
Claude Desktop / Cursor (JSON config)
{
  "mcpServers": {
    "mcp-presentation": {
      "command": "uv",
      "args": ["--directory", "/path/to/mcp-presentation", "run", "presentation-gen"]
    }
  }
}

2.使用它 --问问你的人工智能助手:

"Create a 5-slide presentation about AI trends in 2026 using the corporate template"

演示文稿将保存到 output/ 将目录转换为.pptx文件。

工具

create_slides——构建完整的演示文稿

从结构化内容创建完整的PowerPoint。

create_slides(
  title="Q1 2026 Report",
  slides=[
    {"title": "Overview", "content": "Revenue up 25%\nNew markets entered\nTeam grew to 50", "layout": "title_and_content"},
    {"title": "Key Metrics", "content": "Revenue: $10M|Customers: 500", "layout": "two_column"},
    {"title": "Thank You", "layout": "title_only"}
  ],
  template="corporate"
)

add_slide--附加到现有演示文稿

将单张幻灯片添加到已存在的.pptx文件中。

add_slide(
  pptx_path="/path/to/presentation.pptx",
  title="New Section",
  content="Additional content here",
  layout="title_and_content"
)

export_to_pdf--转换为pdf

使用LibreOffice将.pptx文件转换为PDF。

export_to_pdf(pptx_path="/path/to/presentation.pptx")

需要安装LibreOffice。安装: brew install --cask libreoffice (macOS)或 sudo apt install libreoffice (Ubuntu)。

create_thumbnail--生成预览图像

将第一张幻灯片渲染为PNG缩略图。

create_thumbnail(pptx_path="/path/to/presentation.pptx", width=1280)

模板

模板 样式 背景 标题样式 最适合
minimal 干净、现代 白色 深色文字,重量轻 技术文档、报告
corporate 专业 白色+蓝色标题 蓝色条形白色 商务甲板、提案
creative 大胆、多彩 紫色渐变 白色、大而大胆 Pitch、创意内裤

幻灯片布局

布局 描述 内容格式
title_and_content 标题在顶部,项目符号内容在下面 常规文本, \n 子弹
title_only 大居中标题+可选字幕 仅标题,内容作为字幕
image_full 带标题栏的全出血图像 提供 image_path,标题为标题
two_column 标题+两列并排 用 |

JSON输入示例

{
  "title": "Project Alpha",
  "slides": [
    {
      "title": "Introduction",
      "content": "What is Project Alpha?\nWhy it matters\nTimeline overview",
      "layout": "title_and_content"
    },
    {
      "title": "Comparison",
      "content": "Before:\nSlow process\nManual steps\nHigh error rate|After:\nAutomated pipeline\n10x faster\n99.9% accuracy",
      "layout": "two_column"
    },
    {
      "title": "",
      "image_path": "/path/to/chart.png",
      "layout": "image_full"
    },
    {
      "title": "Questions?",
      "content": "team@example.com",
      "layout": "title_only"
    }
  ],
  "template": "corporate"
}

MCP资源

服务器公开了AI助手可以自动读取的内置文档:

资源URI 描述
guide://templates 模板比较、幻灯片布局和示例JSON
guide://tools 工具使用、工作流程和提示

环境变量

变量 必填 默认 描述
PRESENTATION_OUTPUT_DIR 没有 ./output 保存生成文件的目录

自定义输出目录

--env PRESENTATION_OUTPUT_DIR=/absolute/path/to/your/presentations

文件保存时带有时间戳: presentation_20260331_143022.pptx.

故障排除

错误参考

错误 根本原因 解决方案
Missing required parameter: title 没有为create_slides提供标题 传递 title 字符串
Missing required parameter: slides 未提供幻灯片阵列 通过 slides 幻灯片对象数组
Presentation not found pptx_path无效 检查文件路径是否存在
Invalid slides JSON 格式错误的幻灯片数组 确保幻灯片是有效的JSON数组

PDF导出错误

错误 根本原因 解决方案
LibreOffice is not installed 软件不在PATH中 安装: brew install --cask libreoffice (macOS)或 sudo apt install libreoffice (Ubuntu)
LibreOffice conversion failed 损坏的.pptx或LibreOffice问题 验证.pptx在PowerPoint中是否正确打开

缩略图错误

错误 根本原因 解决方案
Presentation has no slides 空.pptx文件 确保演示文稿至少有一张幻灯片
字体渲染问题 找不到系统字体 安装Helvetica(macOS)或DejaVu Sans(Linux)

先决条件

  • Python 3.10+
  • 紫外线 --安装方式 curl -LsSf https://astral.sh/uv/install.sh | sh
  • LibreOffice (可选,用于PDF导出)-- brew install --cask libreoffice

本地开发

git clone https://github.com/kevinten-ai/mcp-presentation.git
cd mcp-presentation

# Install dependencies
uv sync

# Run the server directly
uv run presentation-gen

使用MCP检查器进行调试

npx @modelcontextprotocol/inspector uv --directory /path/to/mcp-presentation run presentation-gen

相关项目

许可证

麻省理工学院——见 许可证 了解详情。