html2pptx-mcp
Generate native, editable PowerPoint decks from a restricted HTML contract, with validation, contract introspection, and reverse-engineering of reference PPTX files.
Validate restricted HTML against the contract and return machine-readable errors, warnings, and fixes with zero side effects.
Convert single- or multi-page restricted HTML into
.pptxwith editable text boxes, shapes, tables, and images; supportsbase_dir, font embedding, and lossy-fix policy.Export the HTML contract as complete JSON or an LLM-friendly concise specification.
Outline a reference
.pptxto inspect theme palette/fonts and per-slide shapes with inferred roles.Reverse a reference
.pptxinto contract-compliant HTML, fully or selectively by pages/elements; writes output and can inline small snippets.Access MCP resources/prompts for contract specs and slide-design prompting, over stdio or streamable HTTP.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@html2pptx-mcpConvert slides.html into an editable PowerPoint at out/deck.pptx."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
html2pptx-mcp
用受限 HTML 契约生成原生可编辑的 PowerPoint(.pptx),并提供 MCP 服务接口。
现状:
0.1.0a1预览版——转换器、MCP 服务(5 工具)、参考 pptx 逆转与字体子集内嵌均可用。
安装
# 发布后:一行接入任意 MCP 客户端(无需克隆仓库)
uvx html2pptx-mcp
# 或 pip 安装
pip install html2pptx-mcpRelated MCP server: dial-pptx-mcp
为什么不是「HTML 直接转 PPT」
自由 HTML/CSS 到 PPTX 的有损转换,会让你在浏览器里看到的和交付出去的不是同一个东西。 本项目反过来:先用契约把可表达的写法收窄到能一一映射到 DrawingML 的子集,契约之外的 写法一律报错并给出可用写法,而不是静默丢弃。
产物是真正的 PPT 对象(文本框、形状、表格、图片),可以在 PowerPoint 里继续编辑,不是截图。
架构
受限 HTML --lower--> Slide IR(JSON) --emit--> .pptx
\-> 诊断报告(error / fix / warning,全部机器可读)契约是数据:属性、标签、取值、修复规则、错误码写在
convert/data/*.json;解析器按 kind 注册, CI 双向对账,杜绝「文档说有、实现没做」。IR 是第二个契约:HTML 只是一个前端;发射器只认 IR,后续 native 工具 / 模板系统复用同一层。
单次遍历:校验与生成共用一条 lowering 路径,不会出现「校验通过但生成不一致」。
快速开始(开发)
快速开始
需要 Python 3.11+ 与 uv。
uv sync --extra dev
uv run pytest
uv run ruff check .
uv run mypy命令行
# 校验(不读图片、不生成文件)
uv run html2pptx-cli validate examples/html/04_bad.html
# 生成单页 / 多页
uv run html2pptx-cli build examples/html/01_title.html -o out/01.pptx
uv run html2pptx-cli build examples/html/01_title.html examples/html/03_data.html \
-o out/deck.pptx --report out/report.json
# 导出契约 / 回读产物几何
uv run html2pptx-cli contract --format json
uv run html2pptx-cli inspect out/deck.pptx退出码:0 通过;2 存在契约错误(--strict 时警告也算失败);1 文件或内部错误。
Python API
from pathlib import Path
from html2pptx_mcp.convert import CompileOptions, compile_html
result = compile_html(
Path("examples/html/01_title.html").read_text(encoding="utf-8"),
options=CompileOptions(base_dir=Path("examples/html")),
)
if result.ok:
result.save("out/01.pptx")
else:
for error in result.report.errors:
print(error.code, error.message, error.hint)compile_html 接受单份 HTML 或多份(按顺序拼页),返回结果对象而不是抛异常;
validate_html 与它共用同一次遍历,只是不执行发射。
MCP 服务
uv run html2pptx-mcp # stdio(默认)
uv run html2pptx-mcp --transport streamable-http --host 127.0.0.1 --port 8000客户端(stdio)配置:
{
"mcpServers": {
"ppt": {
"command": "uv",
"args": ["run", "--directory", "/path/to/ppt", "html2pptx-mcp"]
}
}
}类型 | 名称 | 说明 |
Tool |
| 零副作用校验,返回 errors / warnings / fixes |
Tool |
| 生成并写出 pptx;失败时以 |
Tool |
| 导出契约( |
Resource |
| 完整契约 JSON |
Resource |
| 给模型看的精简规范 |
Prompt |
| 契约规范 + 任务要求,拼成可直接使用的提示词 |
试用采集
python scripts/trial.py --dir <候选 HTML 目录> --json-out <报告路径>统计一次通过率、错误码分布、自动修复条数与 token 估算。候选稿应在没跑过校验的
前提下一次性生成,否则指标失真。首轮自测见 docs/temp/trial/试用报告.md。
视觉对比
python scripts/compare_visual.py --dir tests/fixtures/review --out test/review对每页 HTML:Edge 无头截图(基准)vs PowerPoint COM 渲染(产物),输出逐像素差异
(diff>16 占比、均值)、差异热点图与上下并排图;report.json 汇总。依赖本机
Edge 与 PowerPoint;几何与样式一致性由 pytest 冒烟保证,本脚本回答「看起来像不像」。
仓库结构
路径 | 职责 |
| MCP 适配层:tools / resources / prompt |
|
|
| 受限 HTML 契约:模型、加载、引用校验(数据在 |
| Slide IR:可序列化的中间表示,发射器的唯一输入 |
| 诊断账本:error / warning / fix,级别与 lossless 由契约决定 |
| CSS 单值解析(纯函数,无 I/O) |
| DOM + 样式 → Slide IR,唯一的校验判定点 |
| 简单表格解析(列宽 / 表头 / 单元格) |
| SVG 子集(rect / circle / line)解析 |
| IR → python-pptx / DrawingML |
| 文本溢出估算(hmtx/hhea 真实字体度量,可注入) |
| 系统字体定位与度量(家族别名 → 文件,含中文别名) |
| 字体子集内嵌(fntdata 部件 + embeddedFontLst) |
| 资源定位与路径沙箱 |
| 参考 pptx 逆转:outline 盘点 + 按页/按元素选择性还原为契约 HTML |
| 成对测试产物(同名 |
| 契约样例(标题页 / 图文页 / 数据页 / 违规样本) |
| 规范与总方案;契约参考在 |
能力边界
不做:动画、页面切换、SmartArt、音视频、OLE;这些对象即使出现在第三方 deck 里也只 做原样保留,不编辑(打开/编辑第三方 deck 不在本阶段范围)。
流式布局只支持单行 flex 子集:
display:flex+row/column+justify-content+align-items+gap+flex简写(无 wrap、无*-reverse、无嵌套文档流);其余元素仍须绝对定位并写全盒。表格是简单表:不支持合并单元格、嵌套表格;单元格只承载纯文本。
SVG 只有三个图元:
rect/circle/line;path、文本、渐变一律拒绝。不读网络图片:只接受
base_dir内的相对路径与data:image/*;base64;URL 取图 属服务化阶段的安全项。预览不是交付判据:
textfit是估算器,真实换行由 PowerPoint 决定;排版请以 PowerPoint 打开结果为准。单一画布:1280×720(16:9),其他尺寸属后续扩展;一份 HTML 一页。
文档
许可证
Apache-2.0,见 LICENSE。
Available Tools
5 toolsconvert_htmlC
把受限 HTML 编译为原生可编辑 .pptx 并写入 output_path。
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes | ||
| base_dir | No | ||
| embed_fonts | No | ||
| lossy_fixes | No | apply | |
| output_path | Yes | ||
| font_strategy | No | auto |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations at all, the description carries the full behavioral burden yet discloses very little. It doesn't say whether the conversion is lossy (the lossy_fixes param suggests it is), how font embedding behaves, what happens if the HTML violates the contract, or whether output_path is overwritten.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single tight sentence with the action and the output destination front-loaded. Nothing is wasted, though there is also very little substance.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema covers return values, but for an unannotated file-writing tool with 6 undocumented parameters, the description is far too thin. Critical context about the HTML contract, lossy conversion, and font handling is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0% across 6 parameters, and the description only names output_path. The non-obvious parameters — lossy_fixes ('apply'), font_strategy ('auto'), embed_fonts, base_dir — receive no explanation anywhere, leaving the agent unable to choose values correctly.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource pair: compile restricted HTML into a native editable .pptx and write it to output_path. The word 'restricted' hints at a contract, but the description never distinguishes this from validate_html or get_contract, which are the obvious siblings in the pipeline.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no explicit when-to-use guidance and no mention of the validate_html / get_contract siblings that clearly gate this conversion. An agent must infer that HTML should be validated first and that 'restricted' refers to a contract.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_contractB
导出契约:format=llm 为精简规范,format=json 为完整契约。
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | llm |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It never states that this is a read/export operation with no side effects, says nothing about permissions, size of output, or what the two formats contain beyond a one-word contrast (精简规范 vs 完整契约).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single tight sentence with the resource front-loaded and the two format options immediately after. Efficient, though it is perhaps too terse for an unannotated tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return-value detail need not be in the description, and the format semantics are covered. But with no annotations for a 1-param export tool, the description leaves gaps about what the contract contains and whether the call has any side effects.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0% and the format property has no enum or description, so the definition is the only place that explains format=llm (condensed spec) vs format=json (full contract). That is meaningful added value beyond the schema, though it omits the default value and any constraints.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and object (导出契约 / export the contract) and explains the two formats, but never says what 'contract' actually is — schema contract, tool contract, or something else — so the purpose remains fuzzy. The sibling tools (validate_html, convert_html, ppt_*) offer no contrast to orient the agent.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies when to pick format=llm (condensed spec) vs format=json (full contract), which is useful implied usage guidance. However, it does not state conditions, exclusions, or alternatives explicitly, and the default (llm) is only visible in the schema.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
ppt_outlineB
盘点参考 pptx:主题色板/字体体系 + 每页形状清单与角色初判(标题/背景/徽章/图片…);选择性逆转的选片依据。
| Name | Required | Description | Default |
|---|---|---|---|
| pptx_path | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. "盘点" and the extractive outputs (palette, fonts, shape inventory) strongly imply a read-only analysis, but the description never explicitly states that it is non-mutating, requires a valid local file, or has any side effects. It does at least disclose what the tool produces.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single compact sentence, front-loaded with the core action "盘点参考 pptx" and then the extracted artifacts. The parenthetical examples and the trailing reversal rationale are dense but each clause adds information; no filler sentences.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return structure need not be explained. However, for a tool with no annotations and 0% schema description coverage, the description should clarify that it is read-only and what the pptx_path must be. It covers the analysis outputs well but leaves these operational gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the schema only provides the name "pptx_path" with no description. The description adds a little meaning by framing it as a "参考 pptx" (reference deck), but it does not explain path format, extension requirements, or whether the file must be local. For a single self-evidently named parameter, this is minimally acceptable.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb+resource: inventorying a reference pptx, and enumerates what the outline covers (theme palette/fonts, per-page shape list, preliminary role identification). It also links the output to slide selection for the reversal workflow, which helps distinguish it from siblings like ppt_reverse, though it doesn't explicitly name the sibling.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
"选择性逆转的选片依据" implies this tool is used upstream of the reversal step to choose slides, giving some usage context. However, there is no explicit when-to-use/when-not guidance, no prerequisites (e.g., file must exist locally), and no explicit routing away from siblings such as ppt_reverse or convert_html.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
ppt_reverseB
把参考 pptx 逆转为受限 HTML(契约子集)供复用。pages/elements 缺省=全逆转,给其一即选择性逆转;产物落盘,片段不大于 12KB 时内联回传。
| Name | Required | Description | Default |
|---|---|---|---|
| pages | No | ||
| out_dir | Yes | ||
| elements | No | ||
| pptx_path | Yes | ||
| include_html | No | auto | |
| placeholder_text | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description does disclose important behavior: output is written to disk, and fragments no larger than 12KB are returned inline. It does not discuss overwrite behavior, permissions, or whether out_dir contents may be replaced, which matters for a file-writing tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded, covering the core operation, selection behavior, and output handling in two sentences. The term "契约子集" is somewhat opaque, but there is no wasted text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The core operation and output behavior are adequately described, and an output schema exists for return values. Still, for a six-parameter tool with no annotations and 0% schema coverage, the missing explanations for include_html and placeholder_text leave meaningful gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It clarifies pages/elements selection semantics, but leaves include_html (default "auto") and placeholder_text entirely unexplained, and does not add detail for pptx_path or out_dir beyond their names.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a specific verb and resource: reverse a reference pptx into restricted HTML (a contract subset) for reuse. It implicitly distinguishes from siblings like ppt_outline and validate_html, though it does not explicitly name alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explains that omitting pages/elements performs a full reversal while supplying one enables selective reversal, which is useful usage context. However, it gives no guidance on when to use this tool versus convert_html, validate_html, or get_contract.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
validate_htmlC
校验受限 HTML 是否符合契约;返回 errors/warnings/fixes 的 JSON 报告。
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes | ||
| lossy_fixes | No | apply | |
| font_strategy | No | auto |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations exist, so the description carries the full burden. It discloses the report shape (errors/warnings/fixes) but says nothing about whether validation mutates the input — notably the 'lossy_fixes' parameter defaults to 'apply', implying changes may be applied, which the description never explains.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single front-loaded sentence with no filler; the purpose and return shape come first. Slightly terse given how much behavior (fixes, font strategy) is left unexplained.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The output schema covers return values, but with no annotations and 0% parameter description coverage, the description leaves the mutation semantics of lossy_fixes and the meaning of font_strategy unaddressed. For a 3-param validation tool with side-effect ambiguity, this is insufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must compensate, but it only hints that the html input is 'restricted'. The lossy_fixes and font_strategy parameters — including their defaults and enum-free allowed values — are completely unaddressed in both schema and description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb+resource: validating restricted HTML against a contract, plus what the report contains (errors/warnings/fixes). It is clear what the tool does, but it never names or contrasts itself with the sibling convert_html, so differentiation is left to inference.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to validate versus when to use convert_html, get_contract, or the ppt tools, and no stated preconditions. The agent must infer usage from the description alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.4.0- First observed
convert_html - First observed
get_contract - First observed
ppt_outline - First observed
ppt_reverse - First observed
validate_html
TDQS
Scored across 5 tools
Each tool has a clearly distinct role: contract retrieval, HTML validation, HTML-to-PPTX conversion, PPTX outline inspection, and PPTX-to-HTML reversal. validate_html and convert_html both involve HTML but are separated by validation versus compilation, so misselection risk is low.
All names use snake_case and are generally readable, but the pattern is not fully uniform: validate_html/convert_html/get_contract are verb-first, while ppt_outline and ppt_reverse are object-first. The deviation is minor and still predictable.
Five tools is well-scoped for an HTML-to-PPTX conversion server. Each tool covers a necessary stage in the workflow without redundant or filler operations.
The surface covers the full lifecycle: retrieve the contract, validate input, convert to editable PPTX, inspect reference decks, and reverse decks back into HTML. No obvious dead ends for the stated purpose.
Maintenance
Related MCP Connectors
Generate, edit, merge, translate and PDF-convert PowerPoint (.pptx) over MCP. 8 tools.
Generate PDF, Word (.docx) and PowerPoint (.pptx) documents from Markdown over MCP.
- StorydocOAuthcom.storydoc
Generate and manage Storydoc presentations from any MCP-compatible client.
Create, edit, export and manage presentations. Requires a paid PPT.AI API merchant account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceConverts slide-oriented HTML into editable PowerPoint files via an MCP server, using Chromium for layout measurement and supporting editable text, shapes, images, and raster fallbacks.-
- AlicenseCqualityAmaintenanceRemote multi-tenant MCP server for generating PowerPoint presentations from corporate templates, preserving theme and branding. Integrates with EPAM AI DIAL file storage and Quick Apps for template input and deck export.531MIT
- AlicenseAqualityAmaintenanceEnables creating and editing PowerPoint .pptx files without corruption, with native editable SVG shapes, glued connectors, table surgery, threaded comments, live editing, and a comprehensive 138-tool MCP server surface.25174 PyPI1AGPL 3.0
- AlicenseAqualityBmaintenanceEnables creating PowerPoint presentations by rendering HTML/CSS slides as full-slide images and exporting them to .pptx files, with a preview tool for visual checking before finalizing.219 npmMIT