deck-contract
MCP server for AI-native editable presentations: surgically edit slide components by stable ID, with local rendering and self-checking overflow.
README
deck-contract
An open standard + reference MCP server for AI-native editable artifacts. An AI edits one component of a deck surgically (by stable id) instead of regenerating the whole slide. No font drift (style is theme-token-only), no overflow (constraints + a render-and-check loop). First domain: presentations. Designed to extend to docs / resume / landing / LaTeX through the same contract.
Inference runs on the user's own AI subscription via MCP (the tool pays $0 for tokens); rendering is local (Chromium, $0 COGS).
Architecture (functional core / imperative shell)
template package (data)
-> deck.json immutable tree, stable string ids
-> apply(deck, ops[]) pure, transactional (all-or-nothing), inverse for free
-> compileHtml(deck) PURE, zero I/O -> deterministic HTML/CSS
-> render (Day 2) Playwright -> PNG + machine-readable issues[]
-> loop: model -> apply_patch -> render -> until issues = []
-> export PDF
MCP, Playwright and git are swappable adapters at the edge; the core knows nothing about transport.
Packages
| package | role |
|---|---|
@deck/contract |
Zod schemas, contract version, issues[] enum. Zero deps. |
@deck/core |
immutable tree, stable id allocator, transactional apply+inverse, token validation |
@deck/compile |
compileHtml(deck) — pure, deterministic deck → HTML/CSS |
@deck/renderer |
LocalChromiumRenderer — headless Chromium → PNG + issues[] (overflow/out-of-bounds) |
@deck/loop |
render-and-check loop with monotone gate + anti-oscillation + bounded iters |
@deck/loader |
FileTemplateSource — resolve self-contained template packages from a folder/git |
@deck/mcp-server |
10 MCP tools over stdio (thin shell); handle-based state behind a DeckStore |
@deck/viewer |
local interactive viewer — click to select, edit text, mark an "AI target"; live reload |
Dependency rule: everything depends on contract; contract depends on nothing. The
domain ("slide", "title") must never leak into core/contract.
Load-bearing invariants (expensive to change later)
- Stable string ids are identity — ops address nodes by id, never by position.
- Token-only style — node styles are token refs only; raw hex/px are rejected at the schema boundary, so font drift has nothing to drift to.
compileHtmlis pure — no I/O, time, or randomness; same deck → byte-identical HTML.- Versioned format —
spec: "deck-contract/1", tolerant reader, open nodetype.
Develop
pnpm install
pnpm --filter @deck/renderer exec playwright install chromium # one-time
pnpm test # 38 tests: id stability, atomicity, inverse, token-only, determinism, render, convergence
pnpm preview # compile the sample deck -> examples/out/preview.html
pnpm render # surgical edit -> headless Chromium -> examples/out/slide-*.png
pnpm loop # run the fix loop on an overflowing deck -> monotone descent + before/after PNGs
pnpm agent # drive the MCP tools as a model would -> examples/out/deck-*.png + deck.pdf
pnpm viewer # open the interactive viewer on a working deck (http://localhost:4570)
Two ways to edit — you and the AI, one deck.json
The point is not full AI generation. The source of truth is one deck.json, and both
you and the model edit it through the same id-addressed ops:
- You, directly —
pnpm viewerrenders the live deck. Click any element to see its stable id; double-click a title/heading to edit text in place; edits write back and reload live. - You point, the AI acts — click an element and hit "Set as AI target". The model
(via
get_selection) reads exactly what you pointed at, thenapply_patchchanges it. Withopen_deckthe model edits the very file the viewer shows, so its changes appear live in front of you.
Use it in Claude Code / Cursor
A project-scoped .mcp.json is included. From a client that supports MCP, point it at
the stdio server:
{
"mcpServers": {
"deck-contract": { "command": "npx", "args": ["tsx", "packages/mcp-server/src/bin.ts"] }
}
}
Then the model has 10 tools: list_templates, load_template, open_deck,
get_selection, get_outline, get_node, apply_patch, insert_block, render,
export_deck. A typical turn: load_template (or open_deck to share the viewer's
file) → get_selection/get_outline → apply_patch (surgical edit) → render (see
the PNG + any overflow issues) → fix → export_deck (PDF). Inference runs on the
client's own model; this server only edits structure and renders locally.
Status
-
[x] Day 1 — contract, core (tree/ids/ops), pure compile, tests without a browser
-
[x] Day 2 —
LocalChromiumRenderer: warm browser, network-blocked, fonts awaited, deterministic overflow / out-of-bounds measurement, PNG screenshots -
[x] Day 3 — render-and-check loop (monotone gate, anti-oscillation, bounded iters); proven to converge on golden fixtures with a deterministic solver (406→192→48→0px)
-
[x] Day 4 — 8 MCP tools over stdio, PDF export, template loader + first
minimal-darkpackage, handle-based session state; full model-flow integration test green -
[x] Day 5 — interactive viewer (click-select, inline text edit, "AI target");
get_selection+open_deckso user and model edit one shared deck.json live
MVP complete: an AI can load a template, surgically edit one component, render and self-check for overflow, and export a PDF — and the user can see the deck, edit elements directly, or point the AI at exactly the element they want changed — all on the client's own model.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。