diag-weaver
This server manages a local live draw.io diagram canvas via MCP: it opens the editor, loads diagrams, reads them, applies small structured edits, snapshots/restores versions, and exports files.
editor_ensure: Open/connect the local draw.io canvas in the browser lazily, without creating store directories.
diagram_replace: Replace the whole diagram from Mermaid or draw.io XML and optionally apply a draw.io layout.
diagram_read: Read the current diagram as a compact summary (grouped by page) or as full XML; uses live canvas or saved current.drawio.
diagram_patch: Apply structured edits — add_node, add_edge, set_label — without requiring coordinates, confined to one page.
diagram_snapshot: Save the current diagram to a labeled snapshot in the user data directory.
diagram_restore: Restore a labeled snapshot, or list snapshots when no label is provided.
diagram_export: Write the current diagram to an explicit filesystem path as .drawio (or inferred png/svg if supported by the canvas).
Provides a live draw.io diagram canvas with tools to create, read, patch, snapshot, restore, and export .drawio diagrams, enabling agents to collaboratively edit diagrams that users can also manipulate in the browser.
Allows Mermaid diagram descriptors to be loaded into the live draw.io canvas, converting Mermaid text into an editable diagram.
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., "@diag-weaver snapshot the current diagram as 'baseline'"
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.
diag-weaver
图编辑器为核,MCP 为手。用户继续用 Cursor / Claude Code 里已经在用的 Agent;本项目只提供 活画布 + 少量 tools + 简单快照。
用户 ──UI──┐
├──► 图编辑器 ──autosave / snapshot──► 版本库
Agent ──MCP┘不做独立对话 Agent,不内嵌 LLM,不扫整个工作区当第二个大脑。
第一期形态
真源:draw.io XML / 画布(官方 embed mode:
embed=1&proto=json,autosave,layout,Mermaiddescriptor)。编辑器宿主:本机
127.0.0.1HTTP 页里的 iframe。接口是EditorHost;第一期是BrowserHost。以后换成 IDE Webview / MCP Apps 时 不改 MCP 工具名。存储:用户数据目录下的
current.drawio+snapshots/<时间>-<标签>.drawio。默认 Windows%APPDATA%\diag-weaver。进程握手、tools/list、空diagram_read不会 mkdir,也不会在 Agent cwd 建graph-store。工具面刻意少:
editor_ensure、diagram_replace、diagram_read、diagram_patch、diagram_snapshot、diagram_restore、diagram_export。多页图安全:
diagram_read的 summary 按页分组(summary.pages,另有跨页平铺的cells);diagram_patch始终只作用于一个页,多页图必须显式传page(1 起的页号或页名),补丁查找与插入都限定在目标页内,跨页同名 id 不会误伤。指定id时按原样写入;该 id 已在目标页存在才会报错,另一页上的同名 id 不占名额。同一批操作里先删掉的 id 可以再加回来。结构化补丁:
diagram_patch支持add_node/add_edge/set_label/remove_node/remove_edge。删节点会级联删掉其子 cell,以及挂在这些 cell 上的边;删元素请用remove_*而不是整图diagram_replace,以保留用户手工布局。
社区复用:画布用官方 embed.diagrams.net,不自研 mxGraph,不把 lgazo 的 30+ 格子级工具暴露给 Agent。lgazo / 官方 @drawio/mcp 负责「遥控格子 / 打开看看」;这里负责同一张图的本地生命周期(可见、可手改、可快照、不污染工作区)。
Related MCP server: Excalidraw MCP Server
安装与 MCP 配置
用 pnpm(生成物在 dist/,不入库)。测 MCP 时走「构建 + 注册到全局 bin」,pnpm 12 已去掉 pnpm link --global,用 pnpm add -g . 达到同样效果:
pnpm install
pnpm test
pnpm run linkpnpm run link = pnpm build + pnpm add -g .。之后本机任意目录都能调 diag-weaver。卸掉:pnpm run unlink。若命令找不到,先 pnpm setup 并把 pnpm bin -g 加进 PATH。
Cursor MCP 配置(全局注册之后):
{
"mcpServers": {
"diag-weaver": {
"command": "diag-weaver"
}
}
}不想装全局时,先 pnpm build,再用仓库脚本启动(把路径换成你的绝对路径):
{
"mcpServers": {
"diag-weaver": {
"command": "pnpm",
"args": ["--dir", "D:/Projects/diag-weaver", "start"]
}
}
}改源码后跑 pnpm build 即可,全局 bin 是 link 到本仓库的。改了 package.json 的 bin 或依赖再 pnpm run link。开发时可 pnpm dev(tsx 跑源码)。接上浏览器后可用 node scripts/smoke-embed.mjs 走一遍 Mermaid → 活画布。环境变量:
变量 | 作用 |
| 覆盖快照根目录(仍默认不在 cwd) |
| 编辑器 HTTP 端口,默认 |
| 设为 |
编辑器是懒启动的:进程启动只建立 MCP stdio 通道,不绑端口、不建目录;首次 editor_ensure 或 diagram_replace 才监听本机 HTTP 页、在 stderr 打印编辑器 URL 并打开浏览器。用户在画布上拖节点后,Agent 再 diagram_read 应能看到新位置。
只有 diagram_export 在被明确给出路径时才往工作区写文件:默认导出 .drawio XML;也支持活画布渲染的 png / svg 图片(需要画布已连接,format 可显式指定,缺省按扩展名 .png / .svg 推断),方便把架构图直接插进 README / 文档。
明确不做
编辑器内聊天窗口 / 自配 API Key
Draft / Stage / Commit、游标、
graph_nudge_*把 Graph JSON 当真源再 roundtrip
第一期绑死某个 IDE 的 Webview
许可
MIT。draw.io 编辑器由 iframe 加载官方 embed 服务,不 vendoring 其源码。
Available Tools
7 toolsdiagram_exportA
Write the current diagram to an explicit filesystem path as .drawio. Relative paths resolve against the process cwd. Will not write unless path is provided.
Inputs: path (required).
diagram_patchA
Apply a few structured edits (add_node, add_edge, set_label). Do not supply x/y; draw.io layout places new cells. Coordinates belong to the editor, not the model.
Inputs: operations (required), layout.
diagram_readA
Read the current diagram. Default is a compact cell summary for the agent. Pass format=xml for the full draw.io XML. Uses the live canvas if connected, otherwise the saved current.drawio. Does not create directories.
Inputs: format.
diagram_replaceA
Replace the whole diagram with Mermaid or draw.io XML. Loads into the live canvas and lets draw.io layout. Prefer this over many tiny geometry edits.
Inputs: content (required), format, layout.
diagram_restoreA
Restore a labeled snapshot onto the canvas. Omit label to list snapshots. Restore copies the snapshot to current and loads it; there is no separate checkout/rollback.
Inputs: label.
diagram_snapshotA
Copy the current diagram to a labeled snapshot under the user data directory (not the agent cwd).
Inputs: label (required).
editor_ensureA
Open the local draw.io canvas in the browser if needed and wait until it is connected. Does not create store directories.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Most tools have clearly distinct purposes: read, replace, patch, snapshot, restore, export, and ensure editor. The only mild ambiguity is editor_ensure versus diagram_read, both related to canvas state, but their descriptions make the separation clear.
Six of seven tools follow the diagram_verb pattern (diagram_read, diagram_replace, diagram_patch, etc.). editor_ensure breaks the pattern with a different prefix and verb style, but the inconsistency is minor and the names remain readable.
Seven tools is a well-scoped set for a diagram editing server. Each tool covers a distinct operation without unnecessary bloat, and the count feels appropriate for the domain.
The toolset covers the core diagram lifecycle: read, modify, replace, snapshot, restore, and export. Minor gaps exist, such as no explicit snapshot deletion or fine-grained style/position editing, but agents can accomplish the main workflows without dead ends.
Maintenance
Related MCP Connectors
Create and edit architecture diagrams from your AI agent; get an SVG and a live editable canvas.
Create, edit and organize hand-drawn diagrams (flowcharts, ER, architecture) from any AI agent.
Create, read and live-edit visual boards, Kanban plans, Gantt timelines and diagrams with AI agents.
Flowcharts that people and agents edit together on one live canvas, exported as Mermaid.
Related MCP Servers
- AlicenseBqualityAmaintenanceEnables AI agents to programmatically create, modify, and analyze Draw.io diagrams through the Model Context Protocol. Supports generating architectural diagrams, flowcharts, and visualizations with bidirectional communication between AI systems and Draw.io.13102 npm1,498MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to programmatically control a live Excalidraw canvas with element-level CRUD operations and real-time synchronization. It supports iterative diagramming through scene descriptions, screenshots, and advanced layout tools for collaborative AI-human workflows.3,181 npm2MIT
- FlicenseNot gradedqualityFmaintenanceEnables AI assistants to create, read, and manage Draw.io diagrams programmatically through natural language interactions.1-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, read, update, and delete Draw.io diagrams, allowing automated generation of architectural diagrams, flowcharts, and visual documentation.102 npmMIT