drawio-mcp README

The project's README from github.com/jgraph/drawio-mcp. As one markdown file: README.md.

Draw.io MCP Server

The official draw.io MCP (Model Context Protocol) server that enables LLMs to create and open diagrams in the draw.io editor.

Four Ways to Create Diagrams

This repository offers four approaches for integrating draw.io with AI assistants. Pick the one that fits your setup:

MCP App Server MCP Tool Server Assistant Plugins Project Instructions
How it works Renders diagrams inline in chat Opens diagrams in your browser Generates .drawio files, optional PNG/SVG/PDF export or browser URL Claude generates draw.io URLs via Python
Diagram output Interactive viewer embedded in conversation draw.io editor in a new tab .drawio, .drawio.png / .svg / .pdf, or browser URL Clickable link to draw.io
Requires installation No (hosted at mcp.draw.io) Yes (npm package) One-line plugin install (draw.io Desktop only for PNG/SVG/PDF export) No — just paste instructions
Supports XML, CSV, Mermaid XML only ✅ All three XML only (native format) ✅ All three
Editable in draw.io Via "Open in draw.io" button ✅ Directly ✅ Directly Via link
Works with Claude.ai, VS Code, Cursor, any MCP Apps host Claude Desktop, Cursor, any MCP client Claude Code, Codex CLI, GitHub Copilot Claude.ai (with Projects)
Best for Inline previews in chat Local desktop workflows Local development workflows Quick setup, no install needed

MCP App Server

The MCP App server renders draw.io diagrams inline in AI chat interfaces using the MCP Apps protocol. Instead of opening a browser tab, diagrams appear directly in the conversation as interactive iframes.

The official hosted endpoint is available at:

https://mcp.draw.io/mcp

Add this URL as a remote MCP server in Claude.ai, Cursor, or any MCP Apps-compatible host — no installation required. In Cursor (≥ 2.6), diagrams render inline in the Agent chat (one-click install); on older builds, use the stdio @drawio/mcp tool server instead.

You can also run the server locally via Node.js or deploy your own instance to Cloudflare Workers.

Tools:

Full documentation →

Note: Inline diagram rendering requires an MCP host that supports the MCP Apps extension. In hosts without MCP Apps support, the tool still works but returns the XML as text.


MCP Tool Server

The original MCP server that opens diagrams directly in the draw.io editor. Supports XML, CSV, and Mermaid.js formats with lightbox and dark mode options. Published as @drawio/mcp on npm.

Quick start: npx @drawio/mcp

Setup instructions are available for Claude Desktop, Claude Code, VS Code (GitHub Copilot), and Cursor (with one-click install).

Full documentation →


Assistant Plugins (Claude Code, Codex CLI, GitHub Copilot)

The drawio skill packaged as a plugin for AI coding assistants (under plugins/): it generates native .drawio files, with optional export to PNG, SVG, or PDF (with embedded XML so the exported file remains editable in draw.io) — or a browser URL that opens the diagram directly in app.diagrams.net. No MCP setup required. The same skill ships for three hosts:

Claude Code (full documentation →) — install from this repo's marketplace:

/plugin marketplace add jgraph/drawio-mcp
/plugin install drawio@drawio

Or load it directly from a local clone with claude --plugin-dir ./plugins/claude-code.

Codex CLI (full documentation →) — install from the same marketplace repo:

codex plugin marketplace add jgraph/drawio-mcp
codex plugin add drawio@drawio

GitHub Copilot CLI (full documentation →) — install from the same marketplace repo:

copilot plugin marketplace add jgraph/drawio-mcp
copilot plugin install drawio@drawio

Other Copilot surfaces (VS Code agent mode, the coding agent, code review) load the same skill from a repo's .github/skills/ directory instead — see the plugin README.

By default, the plugin writes a .drawio file and opens it in draw.io. Mention a format in your request to change the output:


Alternative: Project Instructions (No MCP Required)

An alternative approach that works without installing anything. Add instructions to a Claude Project that teach Claude to generate draw.io URLs using Python code execution. No MCP server, no desktop app — just paste and go.

Full documentation →


Diagram layouts

Two optional, independent layout passes can run after the AI generates a diagram — one re-arranges the nodes, the other only reroutes the edges. Which are available depends on the approach:

Layout pass What it does App Server (create_diagram) Tool Server (open_drawio_xml) Assistant Plugins Project Instructions
ELK auto-layout (postLayout: "elk") Re-arranges nodes into a clean layered layout; routes the edges as part of it ✅ — ✅ via draw.io Desktop CLI (--layout) —
libavoid routing (routing: "libavoid") Keeps node positions; reroutes connectors orthogonally around the shapes ✅ ✅ from v1.3.0 ✅ via draw.io Desktop CLI (--layout libavoid) —

Data Residency & Offline Use

If you're deploying in an environment with strict data restrictions, here is exactly where diagram data goes for each approach.

No component sends your diagram to a cloud rasterizer. convert.diagrams.net (or any cloud export endpoint) is not called anywhere in this repository, and there is no "local dependency missing → fall back to cloud" path. PNG/SVG/PDF export happens only in the assistant plugins, which shell out to your locally installed draw.io Desktop CLI (located via which drawio); if it isn't installed, the .drawio file is kept and nothing is sent.

Does your diagram leave the machine?

Approach Diagram leaves the machine?
MCP App Server — hosted (mcp.draw.io) Yes — it is sent to the draw.io server as the MCP request. Self-host instead (below) to keep it local.
MCP App Server — self-hosted (local Node or your own Cloudflare) No — processed by your server and embedded in HTML that renders client-side.
MCP Tool Server (@drawio/mcp) No — carried in the URL #fragment, which browsers do not transmit to the server.
Assistant Plugins (Claude Code, Codex CLI, GitHub Copilot) No — written locally and exported by your local draw.io Desktop CLI.

By default the servers do not write diagram content to their logs — only request metadata (method, session, status, timing). The Cloudflare-hosted App Server logs response bodies only when run with DEBUG=true.

Reducing external requests

Even when the diagram itself stays local, the rendering loads draw.io's web-app / viewer code from app.diagrams.net and viewer.diagrams.net by default. These fetch application code and assets — not your diagram — but they are still outbound requests. To reduce or remove them:

Your LLM is a separate consideration

The diagram is generated by the LLM. If you use a hosted model, the diagram content is produced in that provider's cloud regardless of where this MCP server runs. End-to-end isolation requires a locally hosted model as well.

Verifying

The only reliable way to confirm a deployment makes no outbound calls is to run it with network egress blocked (or watch the browser's Network tab) and verify it still renders. We recommend this for any strict-isolation deployment.


XML Reference (Single Source of Truth)

The draw.io XML generation reference — covering edge routing, containers, layers, tags, metadata, dark mode, style properties, and XML well-formedness — lives in a single canonical file:

shared/xml-reference.md

All four approaches above use this file as their single source of truth for LLM prompts:

Approach How it accesses the reference
MCP App Server Reads the file at startup / build time and includes it in the tool description
MCP Tool Server Reads the file at startup (from repo or bundled copy via prepack)
Assistant Plugins (Claude Code, Codex CLI, GitHub Copilot) Reference the GitHub raw URL
Project Instructions Users copy its contents into their Claude Project

When updating XML generation guidance, edit only shared/xml-reference.md — changes propagate to all consumers automatically.


Shape Search Index

The search_shapes tool is powered by a pre-built index of all draw.io shapes. The index is generated from the live draw.io client (https://app.diagrams.net/js/app.min.js) by running all sidebar palette initializations in Node.js via jsdom and capturing the shape data.

Icons from the draw.io icon service (icons.diagrams.net — the same grouped icon search the editor sidebar uses) are not part of this index: search_shapes queries the service live when the local index has no strong match for a query, returning the icons as shape=image styles. Set DRAWIO_ICON_SERVICE_URL to a self-hosted service to override the endpoint, or to off to disable icon supplementation.

shape-search/search-index.json is committed to the repository and is automatically refreshed on every draw.io release via the Update Shape Search Index GitHub Action — no manual step is required to stay in sync with the latest shapes.

To regenerate the index manually (e.g. when iterating on the generator itself):

cd shape-search
npm install
npm run generate

# Rebuild the MCP App Server worker to embed the updated index
cd ../mcp-app-server
npm run build:worker

The generator fetches app.min.js directly from the public draw.io web app, so no local checkout of the draw.io source is needed.


Development

# MCP App Server
cd mcp-app-server
npm install
npm start

# MCP Tool Server
cd mcp-tool-server
npm install
npm start

drawio-mcp (jgraph/drawio-mcp)

Searching Database…

这是什么?官方的 draw.io MCP 服务器:它能让大语言模型和 AI 助手创建图表并在 draw.io 编辑器中打开,从聊天窗口里的内嵌预览到磁盘上的 .drawio 文件都可以。
它是单一的服务器,还是有多种方式接入我的 AI 助手?共有四种接入方式:一个 MCP App 服务器,可以在聊天中内嵌渲染图表;一个 MCP 工具服务器,会在你的浏览器中打开图表;面向 AI 编程助手的插件,用来写入 .drawio 文件;以及直接粘贴的项目说明,什么都不用安装。
我怎么把它跑起来?在 Claude.ai、Cursor 或任何支持 MCP Apps 的宿主中,把托管的 mcp.draw.io URL 添加为远程 MCP 服务器——无需安装。或者用 'npx @drawio/mcp' 运行工具服务器,也可以一行命令从仓库的市场安装一个插件。
我可以把它接入哪些 AI 工具?App 服务器可在 Claude.ai、VS Code 和 Cursor 中使用;工具服务器可在 Claude Desktop、Cursor 和任何 MCP 客户端中使用;插件面向 Claude Code、Codex CLI 和 GitHub Copilot;说明模式只需要一个 Claude Project。
聊天里的内嵌预览听起来不错——是不是在所有宿主里都能用?不行。内嵌渲染需要支持 MCP Apps 的宿主,比如 Claude.ai 或 Cursor 2.6+。在其他环境下工具仍然可用,但返回的是纯 XML 文本形式的图表,所以那种情况下你应该改用会在浏览器中打开图表的工具服务器。
我的图表数据会离开我的电脑吗?通常不会:工具服务器把图表放在浏览器的 URL fragment 里,浏览器从不传输这部分内容;插件也全部在本地运行,通过你自己的 draw.io Desktop CLI 导出。只有托管的 App Server 会把数据发送出去——如果在意这一点,可以自行部署。
它实际能画什么——只是普通的方框,还是 AWS、UML 这类真正的图标?是真正的图标:searchshapes 可以搜索所有 draw.io 图库里 10,000 多个形状——AWS、Azure、GCP、Kubernetes、UML、BPMN、Cisco、电气符号等等——还有一个实时图标服务可获取品牌 logo,返回的样式字符串可以直接粘贴到你的 XML 里。
我可以用哪些格式来描述图表?XML、CSV 和 Mermaid.js。工具服务器和项目说明这三种都接受;App 服务器和插件则使用 draw.io XML——这是原生格式,能保持完全可编辑。
它能自己整理凌乱的布局吗?有两种可选的处理方式:ELK 自动布局会把节点重新排列成整洁的分层布局;libavoid 则只让你的连接线以直角方式绕开你特意摆放的形状。二选一,不要两个都用——ELK 本身已经会自己布线了。
这些功能里有没有需要安装 draw.io Desktop 的?MCP 服务器和 URL 输出都不需要——只有插件的 PNG/SVG/PDF 导出需要,它会调用你本地的 draw.io Desktop CLI。额外的好处是:导出的文件内嵌了 XML,所以在 draw.io 中依然可以编辑。
Creator
jgraph
Size
11.5 MB
Stars
5.6K
Updated
CommitOct 16
Age
8mo
Commits · 90 Days