/ 目錄 / 演練場 / draw.io MCP
● 官方 jgraph ⚡ 即開即用

draw.io MCP

作者 jgraph · jgraph/drawio-mcp

First-party draw.io MCP — Claude authors and edits .drawio diagrams as XML, validates against the schema, and exports to PNG/SVG.

draw.io's official MCP lets Claude work with its native XML diagram format. Use it to generate architecture diagrams from prose, edit existing diagrams via instructions, validate XML, and export to SVG/PNG for embedding in PRs and docs.

為什麼要用

核心特性

即時演示

實際使用效果

就緒

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "drawio-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@jgraph/drawio-mcp"
      ]
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "drawio-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@jgraph/drawio-mcp"
      ]
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "drawio-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@jgraph/drawio-mcp"
      ]
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "drawio-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@jgraph/drawio-mcp"
      ]
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "drawio-mcp",
      "command": "npx",
      "args": [
        "-y",
        "@jgraph/drawio-mcp"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "drawio-mcp": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "@jgraph/drawio-mcp"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add drawio-mcp -- npx -y @jgraph/drawio-mcp

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: draw.io MCP

Generate an architecture diagram from a README

👤 Developers ⏱ ~15 min intermediate

何時使用: PR adds a new service; you want a diagram for the design doc.

步驟
  1. Describe
    Paste the README prose; ask for an architecture diagram.✓ 已複製
    → XML drawio generated
  2. Validate
    drawio_validate the XML.✓ 已複製
    → Schema OK
  3. Export
    Export to SVG; embed in the design doc.✓ 已複製
    → SVG ready to commit

結果: Diagram lives in repo as both .drawio (editable) and .svg (renderable).

組合

與其他 MCP 搭配,撬動十倍槓桿

drawio-mcp + filesystem

Save .drawio + .svg next to the doc that references them

Combine drawio-mcp with filesystem: Save .drawio + .svg next to the doc that references them✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
generate_diagram (see docs) NL → drawio XML 1 call
edit_diagram (see docs) Apply instructions to existing XML 1 call
validate (see docs) Schema-check XML 1 call
export (see docs) Render to PNG / SVG / PDF 1 call

成本與限制

運行它的成本

API 配額
N/A (local rendering)
每次呼叫 Token 數
XML is moderate size
費用
Free OSS
提示
Keep .drawio source in repo; commit .svg next to it for previews

安全

權限、密鑰、影響範圍

憑證儲存: No credentials
資料出站: None (local)

故障排查

常見錯誤與修復

Validation fails on generated XML

Ask the model to regenerate citing the schema; common issues: missing geometry parents

Exported SVG huge

Use --simplify; flatten transforms before export

替代方案

draw.io MCP 對比其他方案

替代方案何時用它替代權衡
Mermaid (text-only)Simple flow / sequence diagramsLess control over layout
Excalidraw MCPYou prefer hand-drawn aestheticDifferent file format

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills