Draw.io MCP Diagramming Skill
Create or update diagrams via the Draw.io MCP server. Before generating XML, read references/xml-authoring-rules.md — hard constraints, container rules, and edge routing guidance that prevent the most common rendering failures. For layout anti-pattern fixes, see references/layout-antipatterns.md. For cloud topology conventions, icon libraries, and worked examples, see references/azure.md and references/aws.md.
For diagrams that use only basic shapes (flowcharts, UML, ERD, org charts, mind maps, timelines, wireframes), skip icon discovery and proceed directly to drawio/create_diagram or drawio/open_drawio_mermaid.
When to Use
- The user asks to create or refine architecture diagrams (Azure, AWS, multi-cloud, or generic).
- The user wants draw.io/diagrams.net output from an MCP workflow.
- The user asks for Mermaid → draw.io conversion.
- The user asks for CSV → draw.io conversion (org charts, flowcharts from tabular data).
- The user needs Azure service icons in diagrams.
- The user needs AWS service icons in diagrams.
- The user reports that Azure or AWS icons/shapes are not appearing.
- The user asks for an auth or identity flow (OAuth 2.0, OIDC, JWT validation, SSO, login, token exchange, Entra, Cognito).
- The user asks for an API or microservice interaction diagram (request/response chain, service-to-service calls, API gateway flow).
- The user asks for a CI/CD pipeline or deployment workflow (build, test, deploy stages, GitHub Actions, Azure DevOps, approval gates).
- The user wants to edit an existing multi-page
.drawio file (Tool Server only).
Required Tooling
Draw.io provides two MCP server variants. The skill works with either; call the tools that match the configured server.
Option A — Hosted App Server (inline / "Open in draw.io" button)
- MCP tool:
drawio/create_diagram
- Workspace MCP config:
{
"servers": {
"drawio": {
"type": "http",
"url": "https://mcp.draw.io/mcp"
}
}
}
Supported inputs: xml (draw.io XML), mermaid (Mermaid.js text).
Optional layout passes: postLayout: "elk", routing: "libavoid".
Option B — stdio Tool Server (opens draw.io in browser)
- MCP tools:
drawio/open_drawio_xml, drawio/open_drawio_mermaid, drawio/open_drawio_csv, drawio/search_shapes, drawio/list_pages, drawio/get_page, drawio/set_page
- Workspace MCP config:
{
"servers": {
"drawio": {
"command": "npx",
"args": ["-y", "@drawio/mcp"]
}
}
}
Supported inputs: XML, Mermaid, CSV.
Optional layout pass: routing: "libavoid" on open_drawio_xml — requires @drawio/mcp v1.3.0 or later. On older versions the parameter is ignored, so pin with npx -y @drawio/mcp@latest if connector routing does not improve.
Use Option A if your host supports MCP Apps inline rendering (Claude.ai, Cursor ≥ 2.6) or if the "Open in draw.io" button workflow is acceptable. Use Option B for VS Code / GitHub Copilot or any standard MCP client.
Icon discovery tool (both servers)
- MCP tool:
drawio/search_shapes — search 10,000+ draw.io shapes and return ready-to-use style strings.
- Parameters:
query (space-separated keywords) and optional limit (default 10, max 50). Raise limit when a first search returns nothing usable, before concluding a shape does not exist.
Tool name detection
MCP hosts may register tools with a server prefix (e.g. mcp_drawio-mcp-ap_create_diagram and mcp_drawio-mcp-ap_search_shapes). If tool_search does not surface the drawio tools, inspect the available or deferred tools list and call the exact names shown there. Do not assume a tool is unavailable if it appears in the deferred list; use the exact registered name.
VS Code / GitHub Copilot: run shape searches sequentially
In VS Code and GitHub Copilot, parallel tool calls are cancelled if the user sends a new message while they are in flight. Always run drawio/search_shapes calls one at a time — never in parallel batches.
XML hard constraints, containers, and edge routing
The draw.io MCP server enforces strict XML rules, and the most common quality failures are flattened hierarchy and hand-routed edges. Before generating any XML, read references/xml-authoring-rules.md which covers:
- Hard constraints — forbidden constructs that cause the server to return a render error (XML comments, duplicate IDs, self-closing edge/geometry elements, unescaped characters)
- Container rules — nested
swimlane containment, relative child coordinates, and why cross-container edges must sit at parent="1"
- Edge routing — let
routing: "libavoid" or postLayout: "elk" compute paths; the narrow cases where manual connection points are justified
- Pre-generation edge checklist — run before writing edge XML for any infrastructure diagram
Recommended Workflow
Identify the input format and diagram type
- For flowcharts, sequence diagrams, ERD, mind maps, Gantt, timelines, kanban: prefer Mermaid if the Tool Server is available, or use the App Server's
mermaid parameter.
- For org charts or flowcharts from tabular data: use CSV with the Tool Server (
drawio/open_drawio_csv).
- For diagrams with named services, vendor shapes, or pictorial icons: use XML (
drawio/create_diagram or drawio/open_drawio_xml).
Use drawio/search_shapes for any non-geometric shape — it searches all 10,000+ shapes across every draw.io library and returns ready-to-use style strings.
- Use it for cloud services (Azure, AWS, GCP), network equipment (Cisco, Juniper), container/orchestration tools (Kubernetes, Docker), brand logos (Slack, GitHub), IT infrastructure shapes, and any other named component.
- Example queries:
"azure virtual machine", "aws lambda", "cisco router", "kubernetes pod", "slack", "docker".
- Use the returned style string directly in the XML cell — do not guess or fabricate style strings.
- Skip
search_shapes only for diagrams that use purely geometric shapes: rectangles, diamonds, circles, and arrows.
When to use search_shapes vs skip it — if a shape has a recognised name, brand, or product identity, always look it up via search_shapes first. Only skip it for standard geometric diagrams (flowcharts, UML, ERD, org charts, mind maps, timelines, wireframes) that need no pictorial icons. For sequence and flow diagrams, apply Sequence and Flow Diagram Patterns (see section below).
Nest groupings with real containers, not stacked rectangles — for any diagram with hierarchy (VNet → Subnet → resource, VPC → AZ → instance, Region → Environment → Service, swimlanes), make each level a swimlane;startSize=24; container, set parent="<container_id>" on children, and give children coordinates relative to their parent. Edges between cells in different containers must use parent="1" or they render inside the container and get clipped. Drawing a large rectangle and positioning shapes on top of it at absolute coordinates is the anti-pattern the draw.io XML reference explicitly calls out — it breaks move/resize, collapse, and layout passes.
Keep labels unique and sparse — if several edges say the same thing, collapse them into one labelled flow or a single note box. Do not repeat the same wording in the title, legend, lane name, and callout; each text element should have one job.
For cloud infrastructure diagrams, load the vendor reference — read references/azure.md for anything with VNets, subnets, or Azure icons, and references/aws.md for anything with VPCs, AZs, or AWS icons. Read both for multi-cloud diagrams. Each covers that vendor's icon library and caveats, container structure, colour palette, annotation boxes, a complete worked example, and a topology checklist.
Build the payload
- XML: valid
mxGraphModel using verified icons/style strings.
- Mermaid: valid Mermaid.js definition (App Server: pass as
mermaid; Tool Server: use drawio/open_drawio_mermaid).
- CSV: valid CSV content (Tool Server: use
drawio/open_drawio_csv).
Call the appropriate tool
- App Server:
drawio/create_diagram with xml or mermaid.
- Tool Server:
drawio/open_drawio_xml, drawio/open_drawio_mermaid, or drawio/open_drawio_csv.
Decide the layout pass before writing XML, then let it route the edges
routing: "libavoid" — keeps your hand-placed coordinates and only reroutes connectors around shapes. This is the default for topology, architecture, deployment, and container-based diagrams.
postLayout: "elk" — full re-layout that replaces your vertex positions. Use for directional/hierarchical XML (pipelines, decision flows). Add direction: "horizontal" when the flow reads left-to-right — it defaults to vertical, which is why left-to-right CI/CD pipelines come out stacked.
- Do not combine
postLayout and routing — ELK already routes its own edges. direction is XML-only and ignored for Mermaid (Mermaid takes direction from flowchart TD/LR).
- Do not hand-write
exitX/entryX or <Array as="points"> waypoints. The routing pass computes them, and manual values fight it. See references/xml-authoring-rules.md for the narrow exceptions.
If the user wants a file artifact, save as .drawio wrapped in <mxfile><diagram>...</diagram></mxfile>. Read references/standalone-file-requirements.md before writing any .drawio file by hand (or whenever the MCP tools are unavailable) — the MCP tools add as="geometry" and the mxGraphModel layout attributes for you, and without them every element collapses to the origin.
Keep labels concise and explicit (service name + role).
Prefer one icon per major component or service; use edges for flow semantics (ingress/egress/dependency/telemetry).
Input Format Quick Reference
Choose the input that matches the diagram type and configured server.
| Input |
Best for |
App Server |
Tool Server |
| XML |
Architecture/topology diagrams with vendor or pictorial icons, custom layouts |
drawio/create_diagram with xml |
drawio/open_drawio_xml |
| Mermaid |
Flowcharts, sequence, class, ER, state, mindmap, Gantt, timeline, kanban |
drawio/create_diagram with mermaid |
drawio/open_drawio_mermaid |
| CSV |
Org charts, flowcharts, simple diagrams from tabular data |
Not supported |
drawio/open_drawio_csv |
Use Mermaid for standard diagram types; use XML when the user needs pictorial or vendor-specific icons, precise positioning, complex containers, or custom styling. See references/REFERENCE.md for Mermaid/CSV examples and multi-page editing details.
Visual Quality Guardrails
Apply these defaults unless the user explicitly asks for a dense/technical view:
- Use 3-4 major lanes/zones max (for example Source → Process → Destination).
- Keep primary flow left-to-right with a single main path.
- Use stage numbering (
1, 2, 3, 4) instead of many edge labels.
- Keep one icon per major component; avoid icon-per-step layouts.
- Limit cross-lane dashed lines to one security/auth line and one optional telemetry line.
- Edge density: for nodes with 3+ outgoing edges, reduce duplicates first (for example one gateway → one aggregated backend edge). Then let
routing: "libavoid" separate what remains — only add explicit exitX/exitY if a specific edge is still ambiguous after routing.
- Keep text concise (single purpose per box) and avoid multiline overload.
- Keep edge labels short and unique; if adjacent edges repeat the same protocol/port wording, collapse them or move the shared detail to one annotation box.
- Avoid repeating the same label in the title, legend, lane name, and callout.
- Animated flow on connectors: adding
flowAnimation=1; to any edge style renders a moving dot that travels along the arrow, making directional flow immediately visible without extra labels — ideal for data-flow and pipeline diagrams. The animation is preserved in SVG export and the draw.io desktop app. By default, ask the user whether they want any flow arrows animated before generating the diagram — "Would you like any of the flow arrows animated to show traffic direction? If so, which ones?" Apply flowAnimation=1; only to the edges the user identifies. If the user has already indicated they want a static/clean diagram, skip the question.
- Prefer a "clean" variant first; add detail only if requested.
For worked examples of common layout problems (stacked edges, repeated labels, observability inside VNet, etc.), see references/layout-antipatterns.md.
Cloud Infrastructure Topology (Azure and AWS)
Vendor-specific topology guidance lives in per-cloud reference files. Load the one that matches the diagram — or both for multi-cloud:
- Azure — references/azure.md: read for any diagram with VNets, subnets, or Azure icons. Covers the azure2 and mscae icon libraries and their caveats, nested VNet → subnet container structure, colour and border conventions, traffic palette, annotation boxes, a complete worked example, and the Azure topology checklist.
- AWS — references/aws.md: read for any diagram with VPCs, AZs, or AWS icons. Covers the AWS4 stencil library and its caveats, nested VPC → AZ → subnet container structure, subnet-tier colour coding, NAT/IGW egress paths, security group annotation, a complete worked example, and the AWS topology checklist.
Shared rules that apply to both — containment, edge routing, and hard XML constraints — stay in references/xml-authoring-rules.md.
Sequence and Flow Diagram Patterns
Use this section for diagrams that show temporal flows — what happens in order — rather than infrastructure topology. No shape lookup via drawio/search_shapes is required.
When to Apply
| Diagram type |
Keywords |
Layout |
| Auth / authorisation flow |
OAuth, OIDC, JWT, SSO, login, token exchange, Entra, Cognito |
Swimlane interaction flow |
| API / microservice call chain |
REST, GraphQL, request/response, service-to-service, API gateway |
Swimlane or vertical flowchart |
| CI/CD pipeline |
pipeline, build, deploy, release, GitHub Actions, Azure DevOps, approval gate |
Horizontal pipeline flowchart |
Layout Approach
Swimlane interaction flow (auth / API flows with 2–5 actors):
- Use flat
swimlane lanes stacked vertically at parent="1", one actor per lane: swimlane;horizontal=0;startSize=110;fillColor=<pastel>;html=1; with geometry x=0, y=lane_index*150, width=CANVAS_W, height=150
- Step boxes are children of their lane (
parent="<lane_id>") with coordinates relative to the lane: x = 120 + col*180, y = 45, size 140x60 (140x80 for decision diamonds). The x=120 start clears the 110px title area
- Number steps (
1., 2., 3.) in the label so execution order is unambiguous
- Cross-lane edges must sit at
parent="1", not inside a lane, or they are clipped
- Use
edgeStyle=orthogonalEdgeStyle; and let the routing pass place the bends
- Canvas width:
max_col * 180 + 300; do not nest lanes inside a pool or vary lane heights
- Canvas height:
actor_count * 150 + 100
Horizontal pipeline flowchart (CI/CD):
- Stages flow left-to-right: Source → Build → Test → Staging → Approval → Production
- Use
rounded=1 rectangles for stages, rhombus shape for gate / decision points
- Colour-code each stage box using the Stage Colours table below
- Failure branch goes downward from the gate with a red edge to a Rollback/Notify step
- Pass
postLayout: "elk" with direction: "horizontal" — without direction the default vertical pass stacks the pipeline top-to-bottom
- Canvas:
pageWidth="1700" pageHeight="600"
Colour Conventions
Edge colours (consistent with topology palette):
| Meaning |
strokeColor |
Style |
| Primary request / call |
#0078D4 Azure blue |
solid, strokeWidth=2 |
| Success response / return |
#00897B Teal |
solid, strokeWidth=2 |
| Token / credential / redirect |
#F57C00 Amber |
dashed=1, strokeWidth=2 |
| Async / event-driven call |
#5C6BC0 Indigo |
dashed=1, strokeWidth=2 |
| Error / rejection / rollback |
#C62828 Red |
solid, strokeWidth=2 |
| Optional / conditional |
#666666 Grey |
dashed=1, strokeWidth=1 |
Participant lane colours (swimlane header + column background at opacity=30):
| Actor type |
fillColor |
strokeColor |
| User / browser / client |
#dae8fc |
#6c8ebf |
| Identity provider (Entra, Cognito, Okta) |
#e6f4ea |
#82b366 |
| API / backend service |
#fff3e0 |
#e6821e |
| Database / data store |
#f5f5f5 |
#666666 |
| Managed service / external system |
#f3e5f5 |
#7B1FA2 |
Stage fill colours (CI/CD pipeline):
| Stage |
fillColor |
fontColor |
| Source / Trigger |
#0078D4 |
#ffffff |
| Build |
#00897B |
#ffffff |
| Test / Quality Gate |
#F57C00 |
#ffffff |
| Deploy to Staging |
#5C6BC0 |
#ffffff |
| Approval Gate |
#795548 |
#ffffff |
| Deploy to Production |
#43A047 |
#ffffff |
| Rollback / Failure |
#C62828 |
#ffffff |
Flow Animation
flowAnimation=1; works on sequence/flow edges exactly as in topology diagrams. Apply to primary call paths or pipeline stage transitions. Always ask the user before applying.
Checklist (Sequence/Flow Diagrams)
Icon Discovery: Hard Gate and Fallback
This applies to all shapes — cloud services, network equipment, brand logos, and any pictorial icon.
drawio/search_shapes is the only accepted source — do not guess or fabricate style strings.
- If a style string cannot be confirmed, find an alternative via
drawio/search_shapes before generating.
- If a shape renders incorrectly, use
drawio/search_shapes for an alternative, substitute, and regenerate.
How to Discover Shapes
drawio/search_shapes searches all 10,000+ shapes across every draw.io library and returns ready-to-use style strings. Use it for any shape that has a name, brand, or product identity — not just cloud providers.
Example queries by category:
| Category |
Example queries |
| Azure |
"azure virtual machine", "azure key vault", "azure api management" |
| AWS |
"aws lambda", "aws s3", "aws ec2" |
| GCP |
"gcp compute engine", "gcp cloud storage" |
| Network equipment |
"cisco router", "cisco firewall", "juniper switch" |
| Containers / orchestration |
"kubernetes pod", "docker", "helm" |
| Brands / SaaS |
"slack", "github", "jira", "salesforce" |
| On-premises / IT |
"server", "database", "laptop", "printer" |
Always use the returned style value directly on the mxCell — never guess or fabricate a style string.
The style format varies by library:
# Image-based (Azure azure2, SVG files)
image;aspect=fixed;html=1;points=[];align=center;image=img/lib/azure2/<category>/<Name>.svg;
# Stencil-based (AWS4, shape library)
shape=mxgraph.aws4.<name>;fillColor=<color>;fontColor=#ffffff;strokeColor=none;
# Stencil-based (Cisco, Kubernetes, etc.)
shape=mxgraph.cisco.<category>.<name>;sketch=0;html=1;
# Icon-service (brand logos and concept icons, returned as an absolute URL)
shape=image;html=1;verticalLabelPosition=bottom;verticalAlign=top;image=https://<icon-service-host>/<icon>.svg;
When the built-in libraries have no strong match, search_shapes supplements results from the draw.io icon service (the same grouped icon search the editor sidebar uses) and returns them as shape=image styles with an absolute URL. These are valid results — use them as returned rather than rejecting them for not matching an img/lib/... path.
Fallback Strategy if Shapes Still Fail
If any shapes do not render correctly:
- Do not generate the diagram with an unresolved shape style.
- Use
drawio/search_shapes to find alternative verified style strings.
- Return the list of unresolved shapes and propose verified replacements.
- After replacements validate to
OK, then generate the diagram.
Exporting Diagrams
| Format |
How |
Notes |
| SVG |
File → Export As → SVG |
Recommended — preserves flowAnimation moving-dot effects and all icon rendering. Use for sharing or embedding. |
| PNG |
File → Export As → PNG |
Static snapshot. flowAnimation effects are not captured; icons and colours are preserved. |
| PDF |
File → Export As → PDF |
Best for printed or document-embedded diagrams. Static only. |
| .drawio file |
File → Save As |
Preserves all XML, animation settings, and style attributes for future editing. |
flowAnimation=1 is only visible when the diagram is open in draw.io desktop or rendered as SVG. It does not appear in PNG or PDF exports — inform the user of this if they ask why the animation isn't showing.
Troubleshooting Checklist
- Confirm the configured MCP server appears in
MCP: List Servers.
- Run
MCP: Reset Cached Tools if tool list is stale.
- XML comments (
<!-- -->) are forbidden — the MCP server rejects them. Remove all comments before submitting.
- Ensure XML is otherwise well-formed (no malformed tags, no duplicate IDs, no unescaped
</>/& in style strings).
- Z-order: when shapes are siblings at
parent="1", background rectangles must be defined before the icons they sit behind, or they render on top. Using real containers (swimlane, container=1) avoids the problem entirely — children always render above their parent.
html=1 in style is required for any cell whose value contains HTML tags (<b>, <br>, <i>). Newlines via 
 work without it.
sketch=0 in search results: if drawio/search_shapes returns a style string containing sketch=0, preserve it exactly — omitting it enables the hand-drawn sketch rendering mode for that shape.
- Icon sizes: use dimensions as returned by
search_shapes; they reflect the intended aspect ratio. When normalising a row of icons for visual consistency, 64×64 is a safe common size. Never change the aspect ratio of an icon that has aspect=fixed in its style.
- Azure / AWS icon rendering: vendor-specific style rules and fixes are in references/azure.md and references/aws.md.
- Reopen diagram in web draw.io if VS Code extension rendering differs.
- If an icon looks wrong, use
drawio/search_shapes for an alternative exact style string.
Prompt Templates and Checklists
See references/REFERENCE.md for diagram-type prompt presets and references/layout-antipatterns.md for the pre-flight layout checklist.
Definition of Done
- The correct input format and MCP tool were chosen (XML, Mermaid, or CSV; App Server or Tool Server).
- All icon/style strings confirmed via
drawio/search_shapes before generating; unconfirmed icons are not used.
- Diagram renders correctly; XML/Mermaid/CSV is valid and opens in draw.io.
- All named components identifiable via correct icons and clear labels.
- Layout pass chosen deliberately (
routing: "libavoid" for hand-placed/container layouts; postLayout: "elk" — with direction: "horizontal" for left-to-right flows — for directional diagrams; never both).
- All applicable topology checklist items passed (borders, subnets, traffic labels, legend, isolation box, zones, canvas size).
- All applicable sequence/flow checklist items passed (numbered steps, colour-coded edges, error paths, canvas size).
- Animation preference confirmed;
flowAnimation=1; applied only to user-identified edges.
- Nested groupings use real containers: each level a
swimlane, children parented to their container with relative coordinates, cross-container edges at parent="1".
- File artifact saved as
.drawio (wrapped in <mxfile>) if requested, following references/standalone-file-requirements.md.
- Edges declare only
source/target: no hand-written <Array as="points"> waypoints or exitX/entryX overrides unless a documented exception applies. See references/xml-authoring-rules.md.
- Layout anti-patterns checked against references/layout-antipatterns.md before finalising.
1---2name: drawio-mcp-diagramming3description: Create and edit diagrams using the Draw.io MCP server — any shape, any vendor. USE FOR: draw me a diagram, create an architecture diagram, add Azure/AWS/GCP/Cisco/Kubernetes icons to a diagram, convert Mermaid to draw.io, fix overlapping arrows, edit a .drawio file, network topology diagrams, CI/CD pipeline diagrams, auth flow diagrams. Supports XML, Mermaid, and CSV. Uses drawio/search_shapes to find any of 10,000+ shapes across all vendor and icon libraries. DO NOT USE FOR: Excalidraw output (use excalidraw-mcp-diagramming skill).4---5
6# Draw.io MCP Diagramming Skill
7
8Create or update diagrams via the Draw.io MCP server. Before generating XML, read [references/xml-authoring-rules.md](references/xml-authoring-rules.md) — hard constraints, container rules, and edge routing guidance that prevent the most common rendering failures. For layout anti-pattern fixes, see [references/layout-antipatterns.md](references/layout-antipatterns.md). For cloud topology conventions, icon libraries, and worked examples, see [references/azure.md](references/azure.md) and [references/aws.md](references/aws.md).
9
10For diagrams that use only basic shapes (flowcharts, UML, ERD, org charts, mind maps, timelines, wireframes), skip icon discovery and proceed directly to `drawio/create_diagram` or `drawio/open_drawio_mermaid`.
11
12## When to Use
13
14- The user asks to create or refine architecture diagrams (Azure, AWS, multi-cloud, or generic).
15- The user wants draw.io/diagrams.net output from an MCP workflow.
16- The user asks for **Mermaid → draw.io** conversion.
17- The user asks for **CSV → draw.io** conversion (org charts, flowcharts from tabular data).
18- The user needs Azure service icons in diagrams.
19- The user needs AWS service icons in diagrams.
20- The user reports that Azure or AWS icons/shapes are not appearing.
21- The user asks for an **auth or identity flow** (OAuth 2.0, OIDC, JWT validation, SSO, login, token exchange, Entra, Cognito).
22- The user asks for an **API or microservice interaction diagram** (request/response chain, service-to-service calls, API gateway flow).
23- The user asks for a **CI/CD pipeline or deployment workflow** (build, test, deploy stages, GitHub Actions, Azure DevOps, approval gates).
24- The user wants to **edit an existing multi-page `.drawio` file** (Tool Server only).
25
26## Required Tooling
27
28Draw.io provides two MCP server variants. The skill works with either; call the tools that match the configured server.
29
30### Option A — Hosted App Server (inline / "Open in draw.io" button)
31
32- MCP tool: `drawio/create_diagram`
33- Workspace MCP config:
34
35```json
36{
37 "servers": {
38 "drawio": {
39 "type": "http",
40 "url": "https://mcp.draw.io/mcp"
41 }
42 }
43}
44```
45
46Supported inputs: `xml` (draw.io XML), `mermaid` (Mermaid.js text).
47Optional layout passes: `postLayout: "elk"`, `routing: "libavoid"`.
48
49### Option B — stdio Tool Server (opens draw.io in browser)
50
51- MCP tools: `drawio/open_drawio_xml`, `drawio/open_drawio_mermaid`, `drawio/open_drawio_csv`, `drawio/search_shapes`, `drawio/list_pages`, `drawio/get_page`, `drawio/set_page`
52- Workspace MCP config:
53
54```json
55{
56 "servers": {
57 "drawio": {
58 "command": "npx",
59 "args": ["-y", "@drawio/mcp"]
60 }
61 }
62}
63```
64
65Supported inputs: XML, Mermaid, CSV.
66Optional layout pass: `routing: "libavoid"` on `open_drawio_xml` — **requires `@drawio/mcp` v1.3.0 or later**. On older versions the parameter is ignored, so pin with `npx -y @drawio/mcp@latest` if connector routing does not improve.
67
68> Use **Option A** if your host supports MCP Apps inline rendering (Claude.ai, Cursor ≥ 2.6) or if the "Open in draw.io" button workflow is acceptable. Use **Option B** for VS Code / GitHub Copilot or any standard MCP client.
69
70### Icon discovery tool (both servers)
71
72- MCP tool: `drawio/search_shapes` — search 10,000+ draw.io shapes and return ready-to-use style strings.
73- Parameters: `query` (space-separated keywords) and optional `limit` (default 10, max 50). Raise `limit` when a first search returns nothing usable, before concluding a shape does not exist.
74
75### Tool name detection
76
77MCP hosts may register tools with a server prefix (e.g. `mcp_drawio-mcp-ap_create_diagram` and `mcp_drawio-mcp-ap_search_shapes`). If `tool_search` does not surface the drawio tools, inspect the available or deferred tools list and call the exact names shown there. Do not assume a tool is unavailable if it appears in the deferred list; use the exact registered name.
78
79### VS Code / GitHub Copilot: run shape searches sequentially
80
81In VS Code and GitHub Copilot, parallel tool calls are cancelled if the user sends a new message while they are in flight. Always run `drawio/search_shapes` calls **one at a time** — never in parallel batches.
82
83### XML hard constraints, containers, and edge routing
84
85The draw.io MCP server enforces strict XML rules, and the most common quality failures are flattened hierarchy and hand-routed edges. Before generating any XML, read [references/xml-authoring-rules.md](references/xml-authoring-rules.md) which covers:
86
87- **Hard constraints** — forbidden constructs that cause the server to return a render error (XML comments, duplicate IDs, self-closing edge/geometry elements, unescaped characters)
88- **Container rules** — nested `swimlane` containment, relative child coordinates, and why cross-container edges must sit at `parent="1"`
89- **Edge routing** — let `routing: "libavoid"` or `postLayout: "elk"` compute paths; the narrow cases where manual connection points are justified
90- **Pre-generation edge checklist** — run before writing edge XML for any infrastructure diagram
91
92## Recommended Workflow
93
941. **Identify the input format and diagram type**
95 - For flowcharts, sequence diagrams, ERD, mind maps, Gantt, timelines, kanban: prefer **Mermaid** if the Tool Server is available, or use the App Server's `mermaid` parameter.
96 - For org charts or flowcharts from tabular data: use **CSV** with the Tool Server (`drawio/open_drawio_csv`).
97 - For diagrams with named services, vendor shapes, or pictorial icons: use **XML** (`drawio/create_diagram` or `drawio/open_drawio_xml`).
98
992. **Use `drawio/search_shapes` for any non-geometric shape** — it searches all 10,000+ shapes across every draw.io library and returns ready-to-use style strings.
100 - Use it for cloud services (Azure, AWS, GCP), network equipment (Cisco, Juniper), container/orchestration tools (Kubernetes, Docker), brand logos (Slack, GitHub), IT infrastructure shapes, and any other named component.
101 - Example queries: `"azure virtual machine"`, `"aws lambda"`, `"cisco router"`, `"kubernetes pod"`, `"slack"`, `"docker"`.
102 - Use the returned style string directly in the XML cell — do not guess or fabricate style strings.
103 - Skip `search_shapes` only for diagrams that use purely geometric shapes: rectangles, diamonds, circles, and arrows.
104
1053. **When to use `search_shapes` vs skip it** — if a shape has a recognised name, brand, or product identity, always look it up via `search_shapes` first. Only skip it for standard geometric diagrams (flowcharts, UML, ERD, org charts, mind maps, timelines, wireframes) that need no pictorial icons. For sequence and flow diagrams, apply Sequence and Flow Diagram Patterns (see section below).
106
1074. **Nest groupings with real containers, not stacked rectangles** — for any diagram with hierarchy (VNet → Subnet → resource, VPC → AZ → instance, Region → Environment → Service, swimlanes), make each level a `swimlane;startSize=24;` container, set `parent="<container_id>"` on children, and give children coordinates **relative to their parent**. Edges between cells in *different* containers must use `parent="1"` or they render inside the container and get clipped. Drawing a large rectangle and positioning shapes on top of it at absolute coordinates is the anti-pattern the draw.io XML reference explicitly calls out — it breaks move/resize, collapse, and layout passes.
108
1095. **Keep labels unique and sparse** — if several edges say the same thing, collapse them into one labelled flow or a single note box. Do not repeat the same wording in the title, legend, lane name, and callout; each text element should have one job.
110
1116. **For cloud infrastructure diagrams, load the vendor reference** — read [references/azure.md](references/azure.md) for anything with VNets, subnets, or Azure icons, and [references/aws.md](references/aws.md) for anything with VPCs, AZs, or AWS icons. Read both for multi-cloud diagrams. Each covers that vendor's icon library and caveats, container structure, colour palette, annotation boxes, a complete worked example, and a topology checklist.
112
1137. **Build the payload**
114 - XML: valid `mxGraphModel` using verified icons/style strings.
115 - Mermaid: valid Mermaid.js definition (App Server: pass as `mermaid`; Tool Server: use `drawio/open_drawio_mermaid`).
116 - CSV: valid CSV content (Tool Server: use `drawio/open_drawio_csv`).
117
1188. **Call the appropriate tool**
119 - App Server: `drawio/create_diagram` with `xml` or `mermaid`.
120 - Tool Server: `drawio/open_drawio_xml`, `drawio/open_drawio_mermaid`, or `drawio/open_drawio_csv`.
121
1229. **Decide the layout pass before writing XML, then let it route the edges**
123 - `routing: "libavoid"` — keeps your hand-placed coordinates and only reroutes connectors around shapes. This is the default for topology, architecture, deployment, and container-based diagrams.
124 - `postLayout: "elk"` — full re-layout that replaces your vertex positions. Use for directional/hierarchical XML (pipelines, decision flows). Add `direction: "horizontal"` when the flow reads left-to-right — it defaults to `vertical`, which is why left-to-right CI/CD pipelines come out stacked.
125 - Do **not** combine `postLayout` and `routing` — ELK already routes its own edges. `direction` is XML-only and ignored for Mermaid (Mermaid takes direction from `flowchart TD/LR`).
126 - Do **not** hand-write `exitX`/`entryX` or `<Array as="points">` waypoints. The routing pass computes them, and manual values fight it. See [references/xml-authoring-rules.md](references/xml-authoring-rules.md) for the narrow exceptions.
127
12810. If the user wants a file artifact, save as `.drawio` wrapped in `<mxfile><diagram>...</diagram></mxfile>`. **Read [references/standalone-file-requirements.md](references/standalone-file-requirements.md) before writing any `.drawio` file by hand** (or whenever the MCP tools are unavailable) — the MCP tools add `as="geometry"` and the `mxGraphModel` layout attributes for you, and without them every element collapses to the origin.
129
13011. Keep labels concise and explicit (service name + role).
131
13212. Prefer one icon per major component or service; use edges for flow semantics (ingress/egress/dependency/telemetry).
133
134## Input Format Quick Reference
135
136Choose the input that matches the diagram type and configured server.
137
138| Input | Best for | App Server | Tool Server |
139|---|---|---|---|
140| **XML** | Architecture/topology diagrams with vendor or pictorial icons, custom layouts | `drawio/create_diagram` with `xml` | `drawio/open_drawio_xml` |
141| **Mermaid** | Flowcharts, sequence, class, ER, state, mindmap, Gantt, timeline, kanban | `drawio/create_diagram` with `mermaid` | `drawio/open_drawio_mermaid` |
142| **CSV** | Org charts, flowcharts, simple diagrams from tabular data | Not supported | `drawio/open_drawio_csv` |
143
144Use Mermaid for standard diagram types; use XML when the user needs pictorial or vendor-specific icons, precise positioning, complex containers, or custom styling. See [references/REFERENCE.md](references/REFERENCE.md) for Mermaid/CSV examples and multi-page editing details.
145
146## Visual Quality Guardrails
147
148Apply these defaults unless the user explicitly asks for a dense/technical view:
149
150- Use 3-4 major lanes/zones max (for example Source → Process → Destination).
151- Keep primary flow left-to-right with a single main path.
152- Use stage numbering (`1`, `2`, `3`, `4`) instead of many edge labels.
153- Keep one icon per major component; avoid icon-per-step layouts.
154- Limit cross-lane dashed lines to one security/auth line and one optional telemetry line.
155- **Edge density**: for nodes with 3+ outgoing edges, reduce duplicates first (for example one gateway → one aggregated backend edge). Then let `routing: "libavoid"` separate what remains — only add explicit `exitX`/`exitY` if a specific edge is still ambiguous after routing.
156- Keep text concise (single purpose per box) and avoid multiline overload.
157- Keep edge labels short and unique; if adjacent edges repeat the same protocol/port wording, collapse them or move the shared detail to one annotation box.
158- Avoid repeating the same label in the title, legend, lane name, and callout.
159- **Animated flow on connectors**: adding `flowAnimation=1;` to any edge style renders a moving dot that travels along the arrow, making directional flow immediately visible without extra labels — ideal for data-flow and pipeline diagrams. The animation is preserved in SVG export and the draw.io desktop app. By default, ask the user whether they want any flow arrows animated before generating the diagram — *"Would you like any of the flow arrows animated to show traffic direction? If so, which ones?"* Apply `flowAnimation=1;` only to the edges the user identifies. If the user has already indicated they want a static/clean diagram, skip the question.
160- Prefer a "clean" variant first; add detail only if requested.
161
162For worked examples of common layout problems (stacked edges, repeated labels, observability inside VNet, etc.), see [references/layout-antipatterns.md](references/layout-antipatterns.md).
163
164## Cloud Infrastructure Topology (Azure and AWS)
165
166Vendor-specific topology guidance lives in per-cloud reference files. Load the one that matches the diagram — or both for multi-cloud:
167
168- **Azure** — [references/azure.md](references/azure.md): read for any diagram with VNets, subnets, or Azure icons. Covers the azure2 and mscae icon libraries and their caveats, nested VNet → subnet container structure, colour and border conventions, traffic palette, annotation boxes, a complete worked example, and the Azure topology checklist.
169- **AWS** — [references/aws.md](references/aws.md): read for any diagram with VPCs, AZs, or AWS icons. Covers the AWS4 stencil library and its caveats, nested VPC → AZ → subnet container structure, subnet-tier colour coding, NAT/IGW egress paths, security group annotation, a complete worked example, and the AWS topology checklist.
170
171Shared rules that apply to both — containment, edge routing, and hard XML constraints — stay in [references/xml-authoring-rules.md](references/xml-authoring-rules.md).
172
173
174## Sequence and Flow Diagram Patterns
175
176Use this section for diagrams that show **temporal flows** — what happens in order — rather than infrastructure topology. No shape lookup via `drawio/search_shapes` is required.
177
178### When to Apply
179
180| Diagram type | Keywords | Layout |
181|---|---|---|
182| Auth / authorisation flow | OAuth, OIDC, JWT, SSO, login, token exchange, Entra, Cognito | Swimlane interaction flow |
183| API / microservice call chain | REST, GraphQL, request/response, service-to-service, API gateway | Swimlane or vertical flowchart |
184| CI/CD pipeline | pipeline, build, deploy, release, GitHub Actions, Azure DevOps, approval gate | Horizontal pipeline flowchart |
185
186### Layout Approach
187
188**Swimlane interaction flow** (auth / API flows with 2–5 actors):
189- Use flat `swimlane` lanes stacked vertically at `parent="1"`, one actor per lane: `swimlane;horizontal=0;startSize=110;fillColor=<pastel>;html=1;` with geometry `x=0, y=lane_index*150, width=CANVAS_W, height=150`
190- Step boxes are children of their lane (`parent="<lane_id>"`) with coordinates relative to the lane: `x = 120 + col*180`, `y = 45`, size `140x60` (`140x80` for decision diamonds). The `x=120` start clears the 110px title area
191- Number steps (`1.`, `2.`, `3.`) in the label so execution order is unambiguous
192- Cross-lane edges must sit at `parent="1"`, not inside a lane, or they are clipped
193- Use `edgeStyle=orthogonalEdgeStyle;` and let the routing pass place the bends
194- Canvas width: `max_col * 180 + 300`; do not nest lanes inside a pool or vary lane heights
195- Canvas height: `actor_count * 150 + 100`
196
197**Horizontal pipeline flowchart** (CI/CD):
198- Stages flow left-to-right: Source → Build → Test → Staging → Approval → Production
199- Use `rounded=1` rectangles for stages, `rhombus` shape for gate / decision points
200- Colour-code each stage box using the Stage Colours table below
201- Failure branch goes downward from the gate with a red edge to a Rollback/Notify step
202- Pass `postLayout: "elk"` with `direction: "horizontal"` — without `direction` the default vertical pass stacks the pipeline top-to-bottom
203- Canvas: `pageWidth="1700" pageHeight="600"`
204
205### Colour Conventions
206
207**Edge colours** (consistent with topology palette):
208
209| Meaning | `strokeColor` | Style |
210|---|---|---|
211| Primary request / call | `#0078D4` Azure blue | solid, `strokeWidth=2` |
212| Success response / return | `#00897B` Teal | solid, `strokeWidth=2` |
213| Token / credential / redirect | `#F57C00` Amber | `dashed=1`, `strokeWidth=2` |
214| Async / event-driven call | `#5C6BC0` Indigo | `dashed=1`, `strokeWidth=2` |
215| Error / rejection / rollback | `#C62828` Red | solid, `strokeWidth=2` |
216| Optional / conditional | `#666666` Grey | `dashed=1`, `strokeWidth=1` |
217
218**Participant lane colours** (swimlane header + column background at `opacity=30`):
219
220| Actor type | `fillColor` | `strokeColor` |
221|---|---|---|
222| User / browser / client | `#dae8fc` | `#6c8ebf` |
223| Identity provider (Entra, Cognito, Okta) | `#e6f4ea` | `#82b366` |
224| API / backend service | `#fff3e0` | `#e6821e` |
225| Database / data store | `#f5f5f5` | `#666666` |
226| Managed service / external system | `#f3e5f5` | `#7B1FA2` |
227
228**Stage fill colours** (CI/CD pipeline):
229
230| Stage | `fillColor` | `fontColor` |
231|---|---|---|
232| Source / Trigger | `#0078D4` | `#ffffff` |
233| Build | `#00897B` | `#ffffff` |
234| Test / Quality Gate | `#F57C00` | `#ffffff` |
235| Deploy to Staging | `#5C6BC0` | `#ffffff` |
236| Approval Gate | `#795548` | `#ffffff` |
237| Deploy to Production | `#43A047` | `#ffffff` |
238| Rollback / Failure | `#C62828` | `#ffffff` |
239
240### Flow Animation
241
242`flowAnimation=1;` works on sequence/flow edges exactly as in topology diagrams. Apply to primary call paths or pipeline stage transitions. Always ask the user before applying.
243
244### Checklist (Sequence/Flow Diagrams)
245
246- [ ] Diagram type identified (auth flow / API flow / CI/CD pipeline)
247- [ ] Actors / participants labelled clearly
248- [ ] Steps numbered in execution order
249- [ ] Edge colours consistent with conventions above
250- [ ] Error / failure paths shown in red
251- [ ] Animation preference confirmed with user before generating
252- [ ] Canvas sized appropriately for participant count and step depth
253
254## Icon Discovery: Hard Gate and Fallback
255
256This applies to all shapes — cloud services, network equipment, brand logos, and any pictorial icon.
257
2581. **`drawio/search_shapes` is the only accepted source** — do not guess or fabricate style strings.
2592. If a style string cannot be confirmed, find an alternative via `drawio/search_shapes` before generating.
2603. If a shape renders incorrectly, use `drawio/search_shapes` for an alternative, substitute, and regenerate.
261
262## How to Discover Shapes
263
264`drawio/search_shapes` searches all 10,000+ shapes across every draw.io library and returns ready-to-use style strings. Use it for **any** shape that has a name, brand, or product identity — not just cloud providers.
265
266Example queries by category:
267
268| Category | Example queries |
269|---|---|
270| Azure | `"azure virtual machine"`, `"azure key vault"`, `"azure api management"` |
271| AWS | `"aws lambda"`, `"aws s3"`, `"aws ec2"` |
272| GCP | `"gcp compute engine"`, `"gcp cloud storage"` |
273| Network equipment | `"cisco router"`, `"cisco firewall"`, `"juniper switch"` |
274| Containers / orchestration | `"kubernetes pod"`, `"docker"`, `"helm"` |
275| Brands / SaaS | `"slack"`, `"github"`, `"jira"`, `"salesforce"` |
276| On-premises / IT | `"server"`, `"database"`, `"laptop"`, `"printer"` |
277
278Always use the returned `style` value directly on the `mxCell` — never guess or fabricate a style string.
279
280The style format varies by library:
281
282```text
283# Image-based (Azure azure2, SVG files)
284image;aspect=fixed;html=1;points=[];align=center;image=img/lib/azure2/<category>/<Name>.svg;
285
286# Stencil-based (AWS4, shape library)
287shape=mxgraph.aws4.<name>;fillColor=<color>;fontColor=#ffffff;strokeColor=none;
288
289# Stencil-based (Cisco, Kubernetes, etc.)
290shape=mxgraph.cisco.<category>.<name>;sketch=0;html=1;
291
292# Icon-service (brand logos and concept icons, returned as an absolute URL)
293shape=image;html=1;verticalLabelPosition=bottom;verticalAlign=top;image=https://<icon-service-host>/<icon>.svg;
294```
295
296When the built-in libraries have no strong match, `search_shapes` supplements results from the draw.io icon service (the same grouped icon search the editor sidebar uses) and returns them as `shape=image` styles with an absolute URL. These are valid results — use them as returned rather than rejecting them for not matching an `img/lib/...` path.
297
298## Fallback Strategy if Shapes Still Fail
299
300If any shapes do not render correctly:
301
302- Do **not** generate the diagram with an unresolved shape style.
303- Use `drawio/search_shapes` to find alternative verified style strings.
304- Return the list of unresolved shapes and propose verified replacements.
305- After replacements validate to `OK`, then generate the diagram.
306
307## Exporting Diagrams
308
309| Format | How | Notes |
310|---|---|---|
311| **SVG** | `File → Export As → SVG` | Recommended — preserves `flowAnimation` moving-dot effects and all icon rendering. Use for sharing or embedding. |
312| **PNG** | `File → Export As → PNG` | Static snapshot. `flowAnimation` effects are not captured; icons and colours are preserved. |
313| **PDF** | `File → Export As → PDF` | Best for printed or document-embedded diagrams. Static only. |
314| **.drawio file** | `File → Save As` | Preserves all XML, animation settings, and style attributes for future editing. |
315
316> `flowAnimation=1` is only visible when the diagram is open in **draw.io desktop** or rendered as **SVG**. It does not appear in PNG or PDF exports — inform the user of this if they ask why the animation isn't showing.
317
318## Troubleshooting Checklist
319
320- Confirm the configured MCP server appears in `MCP: List Servers`.
321- Run `MCP: Reset Cached Tools` if tool list is stale.
322- **XML comments (`<!-- -->`) are forbidden** — the MCP server rejects them. Remove all comments before submitting.
323- Ensure XML is otherwise well-formed (no malformed tags, no duplicate IDs, no unescaped `<`/`>`/`&` in style strings).
324- **Z-order**: when shapes are siblings at `parent="1"`, background rectangles must be defined **before** the icons they sit behind, or they render on top. Using real containers (`swimlane`, `container=1`) avoids the problem entirely — children always render above their parent.
325- **`html=1` in style** is required for any cell whose `value` contains HTML tags (`<b>`, `<br>`, `<i>`). Newlines via `
` work without it.
326- **`sketch=0` in search results**: if `drawio/search_shapes` returns a style string containing `sketch=0`, preserve it exactly — omitting it enables the hand-drawn sketch rendering mode for that shape.
327- **Icon sizes**: use dimensions as returned by `search_shapes`; they reflect the intended aspect ratio. When normalising a row of icons for visual consistency, 64×64 is a safe common size. Never change the aspect ratio of an icon that has `aspect=fixed` in its style.
328- **Azure / AWS icon rendering**: vendor-specific style rules and fixes are in [references/azure.md](references/azure.md) and [references/aws.md](references/aws.md).
329- Reopen diagram in web draw.io if VS Code extension rendering differs.
330- If an icon looks wrong, use `drawio/search_shapes` for an alternative exact style string.
331
332## Prompt Templates and Checklists
333
334See [references/REFERENCE.md](references/REFERENCE.md) for diagram-type prompt presets and [references/layout-antipatterns.md](references/layout-antipatterns.md) for the pre-flight layout checklist.
335
336## Definition of Done
337
338- The correct input format and MCP tool were chosen (XML, Mermaid, or CSV; App Server or Tool Server).
339- All icon/style strings confirmed via `drawio/search_shapes` before generating; unconfirmed icons are not used.
340- Diagram renders correctly; XML/Mermaid/CSV is valid and opens in draw.io.
341- All named components identifiable via correct icons and clear labels.
342- Layout pass chosen deliberately (`routing: "libavoid"` for hand-placed/container layouts; `postLayout: "elk"` — with `direction: "horizontal"` for left-to-right flows — for directional diagrams; never both).
343- All applicable topology checklist items passed (borders, subnets, traffic labels, legend, isolation box, zones, canvas size).
344- All applicable sequence/flow checklist items passed (numbered steps, colour-coded edges, error paths, canvas size).
345- Animation preference confirmed; `flowAnimation=1;` applied only to user-identified edges.
346- Nested groupings use real containers: each level a `swimlane`, children parented to their container with relative coordinates, cross-container edges at `parent="1"`.
347- File artifact saved as `.drawio` (wrapped in `<mxfile>`) if requested, following [references/standalone-file-requirements.md](references/standalone-file-requirements.md).
348- Edges declare only `source`/`target`: no hand-written `<Array as="points">` waypoints or `exitX`/`entryX` overrides unless a documented exception applies. See [references/xml-authoring-rules.md](references/xml-authoring-rules.md).
349- Layout anti-patterns checked against [references/layout-antipatterns.md](references/layout-antipatterns.md) before finalising.