PPT Generator MCP
MCP server that converts HTML templates into deliverable pages (PPT/proposals/solutions) with 7 atomic tools for template selection, content filling, icon rendering, image generation, page assembly, and quality validation.
README
PPT Generator MCP
将 HTML 模板转化为可交付页面(PPT/标书/方案)的 MCP Server。提供 7 个原子工具,可由编排层 Agent(Claude Code / OpenCode / 自定义 Agent)调度,组合文生文 LLM + 文生图 API,完成模板选择 → 内容填充 → 图标渲染 → 配图生成 → 页面组装 → 质量验证的完整链路。
快速开始
前置条件
- Node.js ≥ 22
- (可选)OpenAI API Key — 启用 LLM 扩写和 DALL-E 文生图
- (可选)Anthropic API Key — 使用 Claude 模型扩写
安装
git clone <repo-url> ppt-generator-mcp
cd ppt-generator-mcp
npm install
跑通 Demo
npm run demo
这会用内置的绿化养护标书示例内容填充模板,在 output/ 生成一页完整的 A4 横向 HTML 页面。
一键集成 Agent
Claude Code
在项目根目录的 .mcp.json(已配置):
{
"mcpServers": {
"ppt-generator": {
"command": "npx",
"args": ["tsx", "src/server.ts"],
"cwd": "${workspaceFolder}"
}
}
}
重启 Claude Code 后,Agent 可直接调用 list_templates、load_template 等工具。
OpenCode / 自定义 Agent
在 OpenCode 的 MCP 配置中添加:
{
"mcpServers": {
"ppt-generator": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/src/server.ts"]
}
}
}
或手动启动 stdio 传输:
npm start
使用 MCP Inspector 调试
npx @modelcontextprotocol/inspector npx tsx src/server.ts
架构
编排层 (Claude Code / OpenCode / 自定义 Agent)
│ MCP Protocol (stdio)
▼
┌─────────────────────────────────────────────────┐
│ src/server.ts MCP Server(7 工具注册) │
│ src/lib/ │
│ ├── template-parser.ts 模板扫描 / 占位符解析 │
│ └── llm-client.ts OpenAI + Anthropic 客户端 │
│ src/tools/ │
│ ├── fill-placeholders.ts 文生文填充(核心) │
│ ├── generate-image.ts DALL-E 文生图 │
│ ├── render-icons.ts <icon> → SVG <img> │
│ ├── assemble-page.ts 组装 HTML + 复制 CSS │
│ └── validate-page.ts 残留占位符 / HTML 合法性检查 │
└─────────────────────────────────────────────────┘
7 个 MCP 工具
| # | 工具 | 输入 | 输出 | API 依赖 |
|---|---|---|---|---|
| 1 | list_templates |
templatesDir? |
模板元数据列表 | 无 |
| 2 | load_template |
slug |
HTML + 占位符清单 + 图标清单 | 无 |
| 3 | fill_placeholders |
html + content + llmConfig? |
填充后 HTML + 详情 + 残留清单 | OpenAI / Anthropic(expand 模式) |
| 4 | generate_image |
html/prompt + imageConfig |
图片路径 + HTML | OpenAI DALL-E |
| 5 | render_icons |
html + iconBasePath |
HTML(icon → img) | 无 |
| 6 | assemble_page |
html + config |
输出文件路径 + HTML | 无 |
| 7 | validate_page |
html + checks |
验证结果 + 问题清单 | 无 |
标准调度流程
编排层 Agent 按以下顺序调用 7 个工具,完成一页 PPT:
1. list_templates → 浏览模板库,按 usecase/format 选择合适模板
2. load_template → 加载 HTML,获取占位符和图标清单
3. fill_placeholders → 用 direct 文本或 LLM 扩写填充所有占位符
4. render_icons → 将 <icon name="x"> 替换为 SVG <img>
5. generate_image → 将 <figures> 提示词替换为 DALL-E 生成的图片
6. assemble_page → 移除注释、复制 CSS、写入输出文件
7. validate_page → 检查残留占位符、图片引用、HTML 合法性
编排示例(伪代码)
# Agent 伪代码 — 展示编排层如何调用 MCP 工具
templates = mcp.call("list_templates")
tpl = pick_best(templates, usecase="标书技术方案", format="A4横向")
parsed = mcp.call("load_template", slug=tpl.slug)
# parsed.placeholders → [{tag: "component-title", count: 5}, ...]
content = build_content_from_user_document(user_doc, parsed.placeholders)
# content.direct = {"component-title": [...], "paragraph": [...], ...}
filled = mcp.call("fill_placeholders", html=parsed.html, content=content)
icons = mcp.call("render_icons", html=filled.html, iconBasePath=tpl.iconDir)
images = mcp.call("generate_image", html=icons.html, imageConfig={...})
page = mcp.call("assemble_page", html=images.html,
config={outputPath: "output/page-1.html", templateDir: tpl.dir})
result = mcp.call("validate_page", html=page.html, checks=["no-xml-tags", ...])
assert result.valid
6 个内置模板
| # | Slug | 风格 | 布局 |
|---|---|---|---|
| 1 | green-infographic-bid-a4-landscape |
正文+组件配对 | 5组 text-card(span-8) + 可视化组件(span-4) |
| 2 | ...-visual |
少文字视觉为主 | 大图 + 双栏简述 + 图标流程 + 能力面板 |
| 3 | ...-text-image |
多文+图片 1:1 | 4行 text(span-6) ⇄ image(span-6) 交错 |
| 4 | ...-table-image |
表格+图片 | 大表格(span-8) + 图片(span-4) + 时间线 |
| 5 | ...-table-text |
表格+文字 | 评分矩阵(span-7) + 文字解读(span-5) |
| 6 | ...-table-text-image |
表格+文字+图片 | 文字(span-5) + 图片(span-3) + 表格(span-4) |
模板格式
模板是含 XML 占位符的 HTML 文件。占位符由 MCP 工具解析和替换:
<!-- 模板头部 XML 注释:元数据 -->
<!-- @name 绿色信息图型标书页(A4横向) @slug green-infographic-... -->
<title><page-title>第N页|页面主题标题</page-title></title>
...
<h4 class="component-title"><component-title>卡片标题</component-title></h4>
<p><paragraph>正文段落内容。</paragraph></p>
<img src="..."><icon name="calendar">图标描述</icon>
<figures>文生图提示词</figures>
LLM 替换规则:
<xxx>示例文字</xxx>→ 去除标签,替换文字<icon name="x">描述</icon>→<img src="./assets/icons/x.svg"><figures>提示词</figures>→<img src="生成的图片">- 属性中的占位值 → 替换为实际值
- 最终不得残留任何
<xxx>XML 标签
添加新模板
- 在
templates/下创建新目录 - 编写 HTML 模板,使用 XML 占位符标记可变内容
- 添加 XML 注释头部(
@name、@slug、@usecase等) - HTML
<meta>标签携带相同元数据 - 配套 CSS 和 assets(图标、图片)
- 运行
npm run demo验证模板可被正确解析
目录结构
├── src/
│ ├── server.ts # MCP Server 入口
│ ├── lib/
│ │ ├── template-parser.ts # 模板扫描、元数据解析、占位符提取
│ │ └── llm-client.ts # OpenAI / Anthropic 统一客户端
│ └── tools/
│ ├── fill-placeholders.ts # 文生文填充(direct + LLM 扩写)
│ ├── generate-image.ts # DALL-E 文生图
│ ├── render-icons.ts # <icon> → <img> SVG 渲染
│ ├── assemble-page.ts # 组装 HTML、复制 CSS、写文件
│ └── validate-page.ts # 残留占位符 / HTML 合法性检查
├── templates/
│ └── green-infographic/ # 绿色信息图模板
│ ├── green-infographic-bid-a4-landscape.html # 模板 HTML
│ ├── green-infographic-theme.css # 主题 CSS
│ ├── assets/icons/ # SVG 图标(Tabler Icons)
│ └── README.md # 模板文档
├── tests/
│ └── demo.ts # 端到端 Demo
├── .mcp.json # Claude Code MCP 配置
├── package.json
└── tsconfig.json
配置
环境变量
| 变量 | 用途 |
|---|---|
OPENAI_API_KEY |
OpenAI API Key(文生文 + DALL-E 文生图) |
ANTHROPIC_API_KEY |
Anthropic API Key(文生文) |
ENABLE_IMAGE_GEN |
设为任意值启用 DALL-E 文生图(demo 中) |
MCP Server 配置
.mcp.json 已预配置,支持的 Agent 框架:
- Claude Code — 自动发现
.mcp.json - OpenCode — 在配置中引用
command: "npx"+args: ["tsx", "src/server.ts"] - 自定义 Agent — 通过 stdio 启动
npm start,发送 JSON-RPC 消息
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。