Integrations

drawio-architecture

Try it

Use when generating or editing draw.io/diagrams.net architecture diagrams via MCP or native XML.

What it does

Draw.io Architecture Diagrams + MCP Integration

The skill document

Draw.io Architecture Diagrams + MCP Integration

Create 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:

  1. Authoring knowledge — how to write correct .drawio XML for architecture, network, cloud, flowchart and ER diagrams (from Agents365-ai/drawio-skill and scarr05/claude-skills-pub).
  2. MCP integration — how to configure and call the official @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).

When to use

  • 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.

When NOT to use

  • A casual hand-drawn / whiteboard look → excalidraw or tldraw.
  • Diagrams-as-code that live in git and render in Markdown → mermaid (general) or plantuml (UML).
  • Freeform infinite-canvas sketching → tldraw.

Two delivery paths (pick one, or combine)

PathWhat it doesWhen 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 CLIAgent 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).


PATH A — MCP server: configure + use

A.1 Configure the server

The server is distributed as npx @drawio/mcp (stdio). The single universal invocation is:

npx -y @drawio/mcp

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.

Automated setup helper

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).

A.2 MCP tools reference

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 diagrams

Opens the editor with native draw.io/mxGraph XML. Parameters:

ParamTypeRequiredNotes
contentstringYesFull XML (author it per this skill)
lightboxbooleanNoRead-only view (default false)
darkstringNo"auto" / "true" / "false" (default "auto")
routingstringNo"libavoid" reroutes connectors around shapes (obstacle-avoiding orthogonal routing) before opening

open_drawio_mermaid

Opens 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_csv

Opens the editor with CSV converted to a diagram (org charts, tables). Params: content (yes), lightbox, dark.

search_shapes

Searches 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_shapes only 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_page

Page-level access to a local multi-page .drawio/.xml file. Address pages by 0-based index, exact name, or id.

ToolParamsResult
list_pagespath[{index, id, name, approxSizeBytes}]
get_pagepath, pageThe page's `` XML
set_pagepath, page, contentReplaces that page (a single ``); other pages untouched

A.3 Layout & routing passes (MCP 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.


PATH B — Local CLI export (fallback / deliverables)

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). Then:

# Preview PNG (NO -e; required for vision self-check; width-capped under 2576px)
drawio -x -f png --width 2000 -o diagram.png input.drawio

# Final PNG (WITH -e; double extension keeps it editable; run repair_png after)
drawio -x -f png -e -s 2 -o diagram.drawio.png input.drawio

# SVG / PDF (final, -e safe)
drawio -x -f svg -e --embed-svg-images -o diagram.svg input.drawio
drawio -x -f pdf -e -o diagram.pdf input.drawio

After every -e PNG export, fix draw.io's truncated IEND chunk:

python3 scripts/validate_drawio.py 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 input.drawio        # read-only
python3 scripts/setup_drawio_mcp.py --viewer-url --edit input.drawio # editable editor URL

See references/mcp-config.md for the full Linux headless (xvfb-run, --no-sandbox, --disable-gpu, HOME) guidance and the fallback chain.


AUTHORING — .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.

File skeleton


  
    
      
        
        
      
    
  

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.

Rigid grid (use for every diagram)

  • Column x = col*180 + 40 (col 0 = 40, col 1 = 220, …)
  • Row y = row*120 + 40 (row 0 = 40, row 1 = 160, …)
  • Node sizes: rectangle 140×60, diamond 140×80, circle 60×60, document 120×80, cylinder 100×70

Place each node at a (col,row); the router handles spacing. Do not hand-add `` waypoints or exitX/entryY overrides unless you have specific geometric intent.

Core shapes (vertex)

<!-- Rounded rectangle — services, modules -->

  


<!-- Diamond — decision -->

  


<!-- Cylinder — database -->

  

Edges (connectors)

CRITICAL: every edge mxCell needs an expanded `` child. Self-closing edge cells do not render.


  

  • Do not hand-route — just declare source/target. For clean orthogonal wires around boxes, set routing:"libavoid" (MCP) or apply the same spirit in CLI files.
  • Consistent edge style per diagram: ER → entityRelationEdgeStyle; UML class → straight (no edgeStyle); mind maps → curved=1; flowchart/architecture/network → orthogonalEdgeStyle.
  • Keep edge labels short (1–3 words: Yes, async, reads). Push longer detail into node text or a legend node.
  • Animated data-flow: add flowAnimation=1;.

Containers & nested architecture

Use real parent-child containment (not shapes placed on top of bigger shapes).

TypeStyleWhen
Group (invisible)group;pointerEvents=0;No border, no connections
Swimlane (titled)swimlane;startSize=30;Visible title bar, or container itself connects
Custom containeradd container=1;pointerEvents=0;Any shape as container

  


  


  

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).

Layered architecture (top → bottom) and left-to-right flow

  • Layered (TB): Users/Clients → API/Interface → Business Logic → Data/Storage. Each layer = a swimlane or rounded container; components inside; arrows show flow; add a legend; add a metadata footer.
  • Left-to-right (LR): 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.

Color palette (semantic)

Use coordinated fill/stroke pairs. When 3+ roles appear, auto-generate a legend (see references/style-guide.md).

RolefillColorstrokeColor
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

Cloud provider icons

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 labels, dark mode, tags, layers, metadata

  • Always add html=1 to every cell style — plain text is unaffected, but HTML (, , ``) renders only with it.
  • Line breaks: &#xa; (works with or without html=1) or &lt;br&gt; (needs html=1). Never \n.
  • XML-escape attribute values: &amp; &lt; &gt; &quot;.
  • Dark mode: set adaptiveColors="auto" on ``; strokeColor/fillColor/fontColor="default" auto-adapt. Use light-dark(light,dark) only when inverse is wrong.
  • Tags (cross-cutting filters): wrap cell in ``; label replaces value.
  • Layers (toggle visibility): mxCell parent="0" with no vertex/edge.
  • Metadata + placeholders: `` with label="%component% — %status%".

CRITICAL: XML well-formedness

  • NEVER include XML comments (<!-- -->) in diagram output — they waste tokens and can cause parse errors.
  • Escape special chars in attribute values; always use unique ids.
  • Validate before delivery: python3 scripts/validate_drawio.py diagram.drawio.
  1. Clarify (1–3 questions if missing): diagram type, output mode (MCP open vs file+CLI vs image), scope/fidelity, specific technologies.
  2. Configure MCP if not already (path A.1 / helper) — or resolve the draw.io CLI binary (path B).
  3. Plan shapes, relationships, layout (LR/TB), grouping (tier/container), icon needs.
  4. Author the XML with the rules above (or write Mermaid for a standard typed diagram).
  5. Deliver: MCP → call open_drawio_xml/_mermaid/_csv; CLI → write .drawio, export, optionally vision self-check.
  6. Iterate with targeted XML edits (change fillColor, move x/y, add/remove node/edge) until approved.

Common mistakes

SymptomFix
Edge doesn't renderEdge cell is self-closing; add ``
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 boxSet routing:"libavoid" (MCP) or add a waypoint / increase spacing
Blank box instead of iconWrong shape=mxgraph.* name — use search_shapes / references/cloud-icons.md
Stacked edges at a nodeDistribute exitX/exitY/entryX/entryY over the side
HTML shows as literal textMissing html=1 in style
Cross-nested container clipEdges between different containers need parent="1"
CJK/URL opens with "URI malformed"Browser fallback must encodeURIComponent the XML (helper does this)

References (this skill)

  • references/mcp-config.md — exact MCP config JSON per platform + self-host + headless/CLI fallback + automated setup + verify steps
  • references/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-lite
  • references/cloud-icons.md — AWS / Azure / GCP icon cheatsheet
  • references/style-guide.md — palette, typography, effects, legend generation
  • scripts/setup_drawio_mcp.py — detect platform + write MCP config / generate viewer URL
  • scripts/validate_drawio.py — XML well-formedness + structural lint + IEND repair

External references (sources analyzed)

Related skills

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván555 installs18 stars

Query Twitter/X profiles, tweets, follower events, and KOL data through the 6551 REST API.

by infra403840 installs27 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván854 installs69 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai21 installs8 stars

More from afonsoft

Browse all skills

Single owner of everything under docs/architecture/ — ADRs, architecture and design documents, and architecture diagrams. Routes each deliverable to the right engine: /mermaid-architecture for Markdown-native diagrams, /drawio-architecture for editable .drawio diagrams, and the optional third-party archify skill for interactive standalone HTML diagrams (installed on demand via `npx skills add tt-a1i/archify`, only with explicit user approval). Use whenever architecture documentation, ADRs, or architecture diagrams must be created or updated.

by Iván

Central entry point of the afonsoft agent harness. Use when starting a new project, resuming an existing one, planning features/Epics/releases, or running any multi-step agent-driven work. Validates and reconciles SPECs (SDD), audits the codebase and harness for gaps (security, architecture, performance, hygiene), proposes improvements, fragments work into GitHub Issues, delegates implementation/QA/review to specialized skills, and re-validates everything until delivery. Also use to review unapproved SPECs, reconcile open GitHub Issues with code, or run a final gap check before closing a release.

by afonsoft1 installs

Use when the user asks to connect an AI agent to external apps via Composio, or when Composio CLI or MCP setup fails.

by afonsoft2 installs

Use when initializing or migrating an AI agent harness in a repository.

by afonsoft1 installs

Use when turning approved plans, specs, PRDs, or Epics into trackable GitHub Issues.

by afonsoft1 installs

Use when building a new MCP server in TypeScript, Python, or C# that exposes tools to LLMs.

by afonsoft2 installs