Install
openclaw skills install @afonsoft/drawio-architectureUse when generating or editing draw.io/diagrams.net architecture diagrams via MCP or native XML.
openclaw skills install @afonsoft/drawio-architectureCreate professional, editable architecture diagrams in draw.io's native .drawio XML format and integrate the official draw.io MCP server so diagrams open directly in the editor. This skill merges two proven sources:
.drawio XML for architecture, network, cloud, flowchart and ER diagrams (from Agents365-ai/drawio-skill and scarr05/claude-skills-pub).@drawio/mcp server so the agent opens diagrams inline/editor instead of dumping XML to a file (from jgraph/drawio-mcp, the vendor's own reference).npx can download and execute remote code. Do not run bare npx -y @drawio/mcp. Use npx -y @drawio/mcp@<VERSION> with an explicit version verified on npm or the project's lockfile. Verify the package name and publisher (JGraph / drawio) before installing.@drawio/mcp as a local stdio process. If you use DRAWIO_BASE_URL, point it to a draw.io instance you control and trust.https://mcp.draw.io/mcp is a remote MCP Apps endpoint operated by the draw.io vendor. It receives diagram XML and renders inline. Only use it when the vendor, TLS channel, and data sensitivity are acceptable for your diagrams. Do not send confidential or regulated architecture data to the hosted endpoint.drawio -x ...) runs the desktop application locally and does not upload diagrams unless you explicitly open a browser URL.The user asks for an architecture / system / service / network / cloud diagram, a flowchart, ER diagram, sequence / UML class, C4 model, or any draw.io/diagrams.net visualization.
The user wants diagrams to open in draw.io automatically (MCP) rather than be saved as a file for manual import.
You are setting up the draw.io MCP server for the current agent/IDE and need the exact config block per platform.
You want the agent to search the official shape library (AWS/Azure/GCP/Cisco/K8s/brand logos) without guessing shape= strings.
User asks or mentions this skill in English (e.g., "use /drawio-architecture", "run drawio-architecture").
O usuário pede ou menciona esta skill em português (ex.: "use /drawio-architecture", "execute drawio-architecture").
| Path | What it does | When to use |
|---|---|---|
| A. MCP (recommended for chat agents) | Agent calls an MCP tool (open_drawio_xml) → draw.io editor opens in a browser tab with the diagram. No file on disk required. | Agent is an MCP client (Claude Desktop/Code, VS Code Copilot, Cursor, OpenCode, Windsurf). Best for "show me the diagram" flows. |
| B. Local CLI | Agent writes a .drawio file, then drawio -x -f png ... exports PNG/SVG/PDF locally. | Headless/CI, need image deliverables, or no MCP available. Requires draw.io desktop CLI. |
Both paths share the same XML authoring rules in this skill — only the delivery step differs. You can generate XML with the rules below and feed it to either open_drawio_xml (path A) or a local file + CLI export (path B).
The server is distributed as npx @drawio/mcp (stdio). Pin an explicit version and run it locally:
npx -y @drawio/mcp@<VERSION>
Replace <VERSION> with the latest stable release verified on npm. Do not run bare npx -y @drawio/mcp because it resolves to the latest remote version at runtime.
Add it to your client's MCP config under mcpServers.drawio. For the concrete JSON block per platform plus self-hosting, see references/mcp-config.md (Claude Desktop, Claude Code, VS Code .vscode/mcp.json, Cursor ~/.cursor/mcp.json, OpenCode, Windsurf, and the DRAWIO_BASE_URL env for self-hosted instances).
There is also a hosted alternative (https://mcp.draw.io/mcp) that renders diagrams inline via the MCP Apps protocol (Claude.ai, VS Code, Cursor) — no install, but it is a different server type than the stdio one above and sends your diagram XML to the draw.io vendor's servers. Only use it for non-sensitive diagrams and when you trust the vendor endpoint.
Run the bundled helper to detect the agent/platform and append the correct config automatically:
python3 scripts/setup_drawio_mcp.py --detect
python3 scripts/setup_drawio_mcp.py --target claude-code --dry-run
python3 scripts/setup_drawio_mcp.py --target vscode --global
See scripts/setup_drawio_mcp.py for all --target values (claude-desktop, claude-code, vscode, cursor, opencode, windsurf, raw) and flags (--dry-run, --global, --force).
The server exposes these tools. Mention the tool name explicitly in prompts so the agent uses MCP rather than hand-writing a file ("Always use the draw.io MCP tools to create diagrams.").
open_drawio_xml — the main one for architecture diagramsOpens the editor with native draw.io/mxGraph XML. Parameters:
| Param | Type | Required | Notes |
|---|---|---|---|
content | string | Yes | Full <mxfile>…</mxfile> XML (author it per this skill) |
lightbox | boolean | No | Read-only view (default false) |
dark | string | No | "auto" / "true" / "false" (default "auto") |
routing | string | No | "libavoid" reroutes connectors around shapes (obstacle-avoiding orthogonal routing) before opening |
open_drawio_mermaidOpens the editor with a Mermaid.js diagram. Use for standard typed diagrams (flowchart, sequence, class, state, ER, gantt, mindmap, sankey…) where you don't need custom styling/icons — write Mermaid text, let draw.io render it editable. Params: content (yes), lightbox, dark.
open_drawio_csvOpens the editor with CSV converted to a diagram (org charts, tables). Params: content (yes), lightbox, dark.
search_shapesSearches the ~10,000-shape draw.io library (AWS, Azure, GCP, Cisco, Kubernetes, P&ID, electrical, BPMN…) and returns ready-to-use style strings for open_drawio_xml. Supplemented by the draw.io icon service for brand logos (react, slack, shopping cart). Params: query (space-separated keywords, yes), limit (default 10, max 50).
Use
search_shapesonly for diagrams needing industry-specific/branded icons (cloud architecture, network topology, P&ID, K8s, BPMN specifics, brand logos). Skip it for flowcharts/UML/ERD/org charts/mind maps that use basic shapes.
list_pages / get_page / set_pagePage-level access to a local multi-page .drawio/.xml file. Address pages by 0-based index, exact name, or id.
| Tool | Params | Result |
|---|---|---|
list_pages | path | [{index, id, name, approxSizeBytes}] |
get_page | path, page | The page's <mxGraphModel> XML |
set_page | path, page, content | Replaces that page (a single <mxGraphModel>); other pages untouched |
open_drawio_xml)You declare logical structure (nodes, edges, labels, containers). draw.io's router + optional post-layout handle placement. Two opt-in passes on open_drawio_xml:
routing: "libavoid" — keeps your node positions, re-routes edges orthogonally around shapes. Use for deliberately-laid-out architecture/network/deployment/swimlane diagrams where wires shouldn't cut through boxes.postLayout: "elk" — full re-layout (ELK layered); nodes are re-placed and edges routed. Best for directional/hierarchical flows (flowcharts, pipelines, decision flows). Set direction: "horizontal" for left-to-right. Do not combine with routing — pick one.For Mermaid: complex flowcharts (≥ ~20 nodes, ≥ 3 diamonds, feedback edges, or ≥ 3 endpoints) need postLayout: "elk"; simple flowcharts and all non-flowchart Mermaid types need none.
Resolve the binary name first (drawio is canonical on Homebrew/Linux .deb/.rpm/AUR; draw.io on older builds; full path on macOS .app/Windows .exe). Store every diagram artifact under docs/architecture/:
# Ensure the architecture docs folder exists
mkdir -p docs/architecture
# Preview PNG (NO -e; required for vision self-check; width-capped under 2576px)
drawio -x -f png --width 2000 -o docs/architecture/diagram.png docs/architecture/diagram.drawio
# Final PNG (WITH -e; double extension keeps it editable; run repair_png after)
drawio -x -f png -e -s 2 -o docs/architecture/diagram.drawio.png docs/architecture/diagram.drawio
# SVG / PDF (final, -e safe)
drawio -x -f svg -e --embed-svg-images -o docs/architecture/diagram.svg docs/architecture/diagram.drawio
drawio -x -f pdf -e -o docs/architecture/diagram.pdf docs/architecture/diagram.drawio
After every -e PNG export, fix draw.io's truncated IEND chunk:
python3 scripts/validate_drawio.py docs/architecture/diagram.drawio.png --repair-iend
If the CLI is unavailable, fall back to a browser URL (no upload — XML lives in the # fragment):
python3 scripts/setup_drawio_mcp.py --viewer-url docs/architecture/diagram.drawio # read-only
python3 scripts/setup_drawio_mcp.py --viewer-url --edit docs/architecture/diagram.drawio # editable editor URL
See
references/mcp-config.mdfor the full Linux headless (xvfb-run,--no-sandbox,--disable-gpu,HOME) guidance and the fallback chain.
.drawio XML rules (shared by both paths)These rules come from the vendor's own shared/xml-reference.md (the single source of truth for MCP prompts) plus the Agents365/claude-skills-pub authoring guides. Follow them whether the XML goes to open_drawio_xml or a local file.
<mxfile host="app.diagrams.net" modified="2026-01-01T00:00:00" agent="agent" version="24.0.0" type="device">
<diagram name="Page-1" id="page1">
<mxGraphModel dx="1200" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="850" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
</root>
</mxGraphModel>
</diagram>
</mxfile>
Rules: id="0" and id="1" are required root cells — never omit. User shapes start at id="2" with unique ids. Top-level shapes use parent="1". Set type="device" when the file is meant to be opened from disk.
x = col*180 + 40 (col 0 = 40, col 1 = 220, …)y = row*120 + 40 (row 0 = 40, row 1 = 160, …)140×60, diamond 140×80, circle 60×60, document 120×80, cylinder 100×70Place each node at a (col,row); the router handles spacing. Do not hand-add <Array as="points"> waypoints or exitX/entryY overrides unless you have specific geometric intent.
<!-- Rounded rectangle — services, modules -->
<mxCell id="2" value="Label" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="140" height="60" as="geometry"/>
</mxCell>
<!-- Diamond — decision -->
<mxCell id="3" value="Condition?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
<mxGeometry x="100" y="200" width="140" height="80" as="geometry"/>
</mxCell>
<!-- Cylinder — database -->
<mxCell id="4" value="DB" style="shape=cylinder3;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" vertex="1" parent="1">
<mxGeometry x="350" y="100" width="100" height="70" as="geometry"/>
</mxCell>
CRITICAL: every edge mxCell needs an expanded <mxGeometry relative="1" as="geometry" /> child. Self-closing edge cells do not render.
<mxCell id="e1" value="HTTP" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;" edge="1" parent="1" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
source/target. For clean orthogonal wires around boxes, set routing:"libavoid" (MCP) or apply the same spirit in CLI files.entityRelationEdgeStyle; UML class → straight (no edgeStyle); mind maps → curved=1; flowchart/architecture/network → orthogonalEdgeStyle.Yes, async, reads). Push longer detail into node text or a legend node.flowAnimation=1;.Use real parent-child containment (not shapes placed on top of bigger shapes).
| Type | Style | When |
|---|---|---|
| Group (invisible) | group;pointerEvents=0; | No border, no connections |
| Swimlane (titled) | swimlane;startSize=30; | Visible title bar, or container itself connects |
| Custom container | add container=1;pointerEvents=0; | Any shape as container |
<mxCell id="vpc" value="VPC" style="swimlane;startSize=24;fillColor=#dae8fc;strokeColor=#6c8ebf;html=1;" vertex="1" parent="1">
<mxGeometry x="0" y="0" width="720" height="360" as="geometry"/>
</mxCell>
<mxCell id="az1" value="AZ us-east-1a" style="swimlane;startSize=24;fillColor=#fff2cc;strokeColor=#d6b656;html=1;" vertex="1" parent="vpc">
<mxGeometry x="20" y="36" width="320" height="300" as="geometry"/>
</mxCell>
<mxCell id="web1" value="web-1" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="az1">
<mxGeometry x="30" y="40" width="120" height="60" as="geometry"/>
</mxCell>
Rules: children use coordinates relative to the parent. Edges between cells in different containers must have parent="1" (else they render inside a container and get clipped). Every container gets pointerEvents=0; unless it itself must be connectable (then swimlane handles it).
Source → Process → Target. Use postLayout:"elk" + direction:"horizontal" (MCP) or place columns left-to-right with the rigid grid.See references/architecture-patterns.md for full worked XML of: layered service architecture, microservices with an event bus, client/API/DB, and a C4-lite context diagram.
Use coordinated fill/stroke pairs. When 3+ roles appear, auto-generate a legend (see references/style-guide.md).
| Role | fillColor | strokeColor |
|---|---|---|
| Service / client | #dae8fc | #6c8ebf |
| Success / database | #d5e8d4 | #82b366 |
| Queue / decision | #fff2cc | #d6b656 |
| Gateway / API | #ffe6cc | #d79b00 |
| Error / alert | #f8cecc | #b85450 |
| External / neutral | #f5f5f5 | #666666 |
| Security / auth | #e1d5e5 | #9673a6 |
For AWS/Azure/GCP/Cisco/K8s, prefer official icons. With MCP, call search_shapes and paste the returned style. Hand-authored cheatsheet (AWS shape=mxgraph.aws4.resourceIcon;resIcon=…, Azure image=img/lib/azure2/…svg, GCP paths) is in references/cloud-icons.md.
html=1 to every cell style — plain text is unaffected, but HTML (<b>, <br>, <font>) renders only with it.
 (works with or without html=1) or <br> (needs html=1). Never \n.& < > ".adaptiveColors="auto" on <mxGraphModel>; strokeColor/fillColor/fontColor="default" auto-adapt. Use light-dark(light,dark) only when inverse is wrong.<object id=… tags="critical v2">; label replaces value.mxCell parent="0" with no vertex/edge.<object … component="X" status="Active" placeholders="1"> with label="%component% — %status%".<!-- -->) in diagram output — they waste tokens and can cause parse errors.ids.python3 scripts/validate_drawio.py docs/architecture/diagram.drawio.open_drawio_xml/_mermaid/_csv..drawio to docs/architecture/<diagram-name>.drawio, then export PNG/SVG/PDF to the same folder, optionally vision self-check.fillColor, move x/y, add/remove node/edge) until approved.| Symptom | Fix |
|---|---|
| Edge doesn't render | Edge cell is self-closing; add <mxGeometry relative="1" as="geometry" /> |
| Vision API 400 "Could not process image" | Exported with -e; re-export preview without -e. (-e PNG has truncated IEND — run repair) |
| Wire cuts through a box | Set routing:"libavoid" (MCP) or add a waypoint / increase spacing |
| Blank box instead of icon | Wrong shape=mxgraph.* name — use search_shapes / references/cloud-icons.md |
| Stacked edges at a node | Distribute exitX/exitY/entryX/entryY over the side |
| HTML shows as literal text | Missing html=1 in style |
| Cross-nested container clip | Edges between different containers need parent="1" |
| CJK/URL opens with "URI malformed" | Browser fallback must encodeURIComponent the XML (helper does this) |
references/mcp-config.md — exact MCP config JSON per platform + self-host + headless/CLI fallback + automated setup + verify stepsreferences/mcp-tools-reference.md — full MCP tools reference with parameters and examples (en) / mcp-tools-reference.pt-br.md (pt-BR)references/usage-guide.md — how to drive the skill once configured (en) / usage-guide.pt-br.md (pt-BR)references/usage-examples.md — end-to-end usage examples (en) / usage-examples.pt-br.md (pt-BR)references/architecture-patterns.md — full worked XML for layered / microservices / client-API-DB / C4-litereferences/cloud-icons.md — AWS / Azure / GCP icon cheatsheetreferences/style-guide.md — palette, typography, effects, legend generationscripts/setup_drawio_mcp.py — detect platform + write MCP config / generate viewer URLscripts/validate_drawio.py — XML well-formedness + structural lint + IEND repair