From draw-io
Generates and validates draw.io XML diagrams enforcing 23 strict quality rules for structure, styles, fonts, edges, and layout. CLI validator for flowcharts, architecture, and sequence diagrams.
npx claudepluginhub ekusiadadus/draw-mcp --plugin draw-ioThis skill uses the workspace's default tool permissions.
This specification defines the rules for AI-generated draw.io XML files. It ensures consistent, high-quality output that renders correctly in draw.io desktop, web, and PNG export. Rules are categorized as:
Applies Acme Corporation brand guidelines including colors, fonts, layouts, and messaging to generated PowerPoint, Excel, and PDF documents.
Builds DCF models with sensitivity analysis, Monte Carlo simulations, and scenario planning for investment valuation and risk assessment.
Calculates profitability (ROE, margins), liquidity (current ratio), leverage, efficiency, and valuation (P/E, EV/EBITDA) ratios from financial statements in CSV, JSON, text, or Excel for investment analysis.
This specification defines the rules for AI-generated draw.io XML files. It ensures consistent, high-quality output that renders correctly in draw.io desktop, web, and PNG export. Rules are categorized as:
All rules are enforced by the draw-mcp-validate CLI tool with 23 validation rules.
mxfile > diagram > mxGraphModel > root > mxCell...
Every file MUST follow this hierarchy. The mxfile element is the root.
Two root cells MUST always be present:
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
Cell id="0" is the invisible root. Cell id="1" is the default layer with parent="0".
Every mxCell with a parent attribute MUST reference an existing cell id. Orphaned references cause rendering failures.
A cell MUST NOT have both vertex="1" and edge="1". It is either a shape or a connection, never both.
Edge mxGeometry MUST have relative="1":
<mxCell id="e1" edge="1" parent="1" source="a" target="b"
style="edgeStyle=orthogonalEdgeStyle;">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
All mxCell elements MUST have unique id attributes.
-- inside XML comments (illegal per XML spec)&, <, >, "Style strings use key=value; pairs with a trailing semicolon:
style="rounded=1;whiteSpace=wrap;html=1;fontFamily=Noto Sans JP;fontSize=18;"
Boolean style keys MUST use 0 or 1, never true or false:
<!-- CORRECT -->
style="rounded=1;html=1;"
<!-- WRONG -->
style="rounded=true;html=false;"
Every cell with a value attribute MUST include fontFamily=FontName; in its style:
<mxCell id="a" value="Label"
style="rounded=1;fontFamily=Noto Sans JP;fontSize=18;"
vertex="1" parent="1"/>
Minimum font size is 14px (MUST). Recommended size is 18px (SHOULD).
Use only valid draw.io style keys. Common typos (e.g., storkeColor for strokeColor) are detected and flagged.
Align node positions to a 10px grid (multiples of 10).
The final straight segment of an edge MUST be at least 20px for arrowheads to render cleanly.
Edges SHOULD be declared before vertices in XML for correct Z-order (arrows behind shapes):
<root>
<mxCell id="0"/><mxCell id="1" parent="0"/>
<!-- EDGES FIRST -->
<mxCell id="e1" edge="1" .../>
<!-- VERTICES AFTER -->
<mxCell id="a" vertex="1" .../>
</root>
Use edgeStyle=orthogonalEdgeStyle for right-angle connectors. Add rounded=1 for cleaner bends.
Use jettySize=auto for better port spacing on orthogonal edges.
For crossing edges, use jumpStyle=arc or jumpStyle=gap to show crossings clearly.
Add explicit waypoints when edges would overlap:
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="300" y="150"/>
</Array>
</mxGeometry>
Use exitX/exitY and entryX/entryY (values 0-1) to control which side of a node an edge connects to. Spread connections across different sides to prevent overlap.
Invisible grouping with no visual border:
<mxCell id="grp1" style="group;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="300" height="200" as="geometry"/>
</mxCell>
Visible title bar, ideal for service boundaries:
<mxCell id="svc1" value="User Service"
style="swimlane;startSize=30;fillColor=#dae8fc;strokeColor=#6c8ebf;fontFamily=Noto Sans JP;fontSize=16;"
vertex="1" parent="1">
<mxGeometry x="100" y="100" width="300" height="200" as="geometry"/>
</mxCell>
Swimlanes SHOULD specify startSize for the title bar height.
Any shape acting as a container:
style="rounded=1;container=1;pointerEvents=0;"
Containers (except swimlanes) SHOULD include pointerEvents=0; to prevent connection capture.
Children MUST use relative coordinates within their parent container:
<!-- Child at (20, 40) relative to container origin -->
<mxCell id="child" vertex="1" parent="svc1">
<mxGeometry x="20" y="40" width="120" height="60" as="geometry"/>
</mxCell>
Children SHOULD not extend beyond parent container bounds.
Consider adding collapsible=1 for interactive containers (INFO).
Layers are additional cells with parent="0" (like cell id="1"):
<mxCell id="0"/>
<mxCell id="1" parent="0"/> <!-- Default layer -->
<mxCell id="layer-bg" value="Background" parent="0"/> <!-- Custom layer -->
<mxCell id="layer-fg" value="Foreground" parent="0"/> <!-- Custom layer -->
Assign elements to layers via parent="layerId". Layer cells do not require fontFamily.
Set page="0" on mxGraphModel for transparent background in PNG export.
Always verify diagrams with PNG export:
drawio -x -f png -s 2 -t -o output.png input.drawio
For portable files, consider type="embed" on mxfile.
Noto Sans JP as default font for cross-platform compatibilitydefaultFontFamily="Noto Sans JP" on mxGraphModel# Validate a file (text output, warning+ severity)
draw-mcp-validate diagram.drawio
# JSON output
draw-mcp-validate diagram.drawio --format json
# Errors only
draw-mcp-validate diagram.drawio --severity error
# Multiple files
draw-mcp-validate *.drawio
| Module | Rules | Severity |
|---|---|---|
| structure | root-cells, hierarchy, vertex-edge-exclusivity, parent-reference, unique-ids | ERROR |
| style | trailing-semicolon (W), boolean-values (E), typo (W), font-family (E) | Mixed |
| edge | z-order (W), relative (E), arrowhead-segment (W), node-spacing (W) | Mixed |
| container | pointer-events (W), children-bounds (W), swimlane-start-size (W), collapsible (I) | Mixed |
| text | japanese-width (W), html-escape (W), font-size (E/W) | Mixed |
| export | page-setting (W), embed-diagram (I) | Mixed |
| Need | Approach |
|---|---|
| Custom styling, precise positioning, Japanese text | XML (this skill) |
| Simple flowchart, sequence, ER diagram | Mermaid.js via MCP |
| Inline preview in chat | MCP App Server (mcp.draw.io/mcp) |