Skip to content

Latest commit

 

History

History
129 lines (97 loc) · 6.77 KB

README.md

File metadata and controls

129 lines (97 loc) · 6.77 KB

Draw.io Plugin for Codex

A Codex CLI plugin that generates native .drawio files. Codex authors each diagram as Mermaid (converted to editable draw.io shapes and laid out by the draw.io desktop CLI or, without it, by draw.io's converter in a headless Chrome, Edge or Chromium) or as draw.io XML directly — with optional ELK auto-layout for XML, export to PNG/SVG/PDF (with embedded XML so the file remains editable in draw.io), or a browser URL that opens the diagram directly in app.diagrams.net. No MCP setup required.

This is the Codex port of the Claude Code plugin; it ships the same drawio skill. Only the host wrapping (manifest schema, invocation, logo) differs — the draw.io guidance itself is the shared single source of truth in shared/.

How It Works

When you ask Codex to create a diagram, it will:

  1. Choose how to author it — Mermaid for standard types (flowchart, sequence, class, state, ER, gantt, mindmap…), or draw.io XML for custom styling, precise positioning, specific shape libraries, or when nothing can convert Mermaid
  2. Produce a native .drawio file — convert the Mermaid with the desktop CLI (without it, with the bundled scripts/mermaid-to-drawio.js), or write the XML directly (optionally running an ELK --layout pass so you don't hand-place cells)
  3. Handle the requested output:
    • PNG / SVG / PDF — export using the draw.io desktop CLI
    • url — compress the XML with Node.js's built-in zlib and open https://app.diagrams.net/#R... in your browser (keeps the .drawio file as a local copy)
    • (default) — leave the .drawio file as-is
  4. Open the result

Prerequisites

  • Codex CLI installed
  • draw.io Desktop installed — required for ELK layout and PNG/SVG/PDF export. Not needed for .drawio or url output: without it, Mermaid is converted in an installed Chrome, Edge or Chromium (or opened as a link that draw.io converts in the browser), and XML needs nothing, which Codex can produce with no desktop app

Installation

Via the drawio marketplace (recommended)

Add this repository as a Codex plugin marketplace, then install the plugin:

codex plugin marketplace add jgraph/drawio-mcp
codex plugin add drawio@drawio

The Codex marketplace manifest lives at .agents/plugins/marketplace.json at the repo root and points at this directory (./plugins/codex/drawio). The rest of the plugin's metadata is inherited from .codex-plugin/plugin.json.

Local development

To add the marketplace from a local clone (e.g. while iterating on the skill), point codex plugin marketplace add at the repo root instead of the owner/repo slug:

codex plugin marketplace add /path/to/drawio-mcp
codex plugin add drawio@drawio

Usage

In most cases you don't type a command at all — just ask Codex for a diagram ("draw a flowchart for user login") and the skill triggers automatically from its description. To invoke it explicitly, Codex namespaces plugin skills as /<plugin>:<skill>, so the command is /drawio:drawio:

/drawio:drawio create a flowchart for user login

By default, this writes a .drawio file and opens it in draw.io. To export to an image format or open the diagram in the browser, mention the format in your request:

/drawio:drawio png flowchart for user login       → login-flow.drawio.png
/drawio:drawio svg: ER diagram for e-commerce     → er-diagram.drawio.svg
/drawio:drawio pdf architecture overview          → architecture-overview.drawio.pdf
/drawio:drawio url flowchart for user login       → opens app.diagrams.net in browser, keeps login-flow.drawio locally

Output Formats

Format Output Editor Dependency
(default) .drawio file draw.io Desktop, or the browser app None
png .drawio.png (embedded XML) draw.io Desktop, or any viewer draw.io Desktop (for export)
svg .drawio.svg (embedded XML) draw.io Desktop, or any viewer draw.io Desktop (for export)
pdf .drawio.pdf (embedded XML) draw.io Desktop, or any PDF viewer draw.io Desktop (for export)
url Browser tab at app.diagrams.net + .drawio file kept locally draw.io editor in browser Node.js

The .drawio.* double extension signals that the file contains embedded diagram XML. Open any of these in draw.io to recover and edit the full diagram. The intermediate .drawio source file is deleted after image export since the exported file contains the complete diagram. In url mode, the .drawio file is kept so you have a persistent local copy to re-edit or share.

url mode uses only Node.js's built-in zlib (deflate-raw compression) and child_process (browser open) — no external dependencies. The resulting https://app.diagrams.net/#R... URL is the same format the MCP Tool Server uses for XML, so behavior is identical.

References

The skill fetches shared guides from GitHub at runtime — the single source of truth for all draw.io prompts across the repository. No extra files are bundled in the plugin.

  • shared/xml-essentials.md — the condensed XML rules (skeleton, cell templates, labels, shapes, the layout grid, containers, swimlanes, edge styles), used when authoring XML
  • shared/xml-reference.md — the full XML reference, fetched only for layers, tags, metadata, tables, cross-functional grids and dark-mode colors
  • shared/mermaid-reference.md — Mermaid syntax for all supported diagram types plus flowchart styling, used when authoring Mermaid

Logo

The Codex interface uses the official draw.io logo (assets/drawio-logo.svg, the vector drawio-desktop icon) for the composer icon and the light/dark plugin logo, with brandColor #F08705.

Other Variants

This repository offers multiple ways to integrate draw.io with AI assistants: