Skip to main content
Glama

diagonaldiagrams

PyPI License: MIT

diagonaldiagrams is a Python library and MCP server that lets an AI agent draw diagrams and charts as SVG, and check them for overlapping text, arrows through boxes and text that spills, before showing them.

Site: filmed examples, benchmarks and a gallery.

An architecture diagram drawn by diagonaldiagrams, with one chat request traced through an AI agent platform

How it works

  1. Describe. The agent writes a short description of the figure, in Mermaid, JSON or CSV.

  2. Draw. diagonaldiagrams lays it out and saves an SVG.

  3. Check. It audits the drawing and prints one line of JSON: all clear, or what is wrong and how to fix it. The agent reads that line instead of a screenshot.

$ diagonaldiagrams mermaid flow.mmd -o flow.svg
{"ok": true, "svg": "flow.svg", ..., "items": 3,
 "layout": ["row 1: Start", "row 2: Ready? (decision)", "row 3: Done"]}

When ok is false, each error comes with a fix.

Related MCP server: excalidraw-mcp

Install

Needs Python 3.11 or newer.

Command line

pip install diagonaldiagrams

MCP (Cursor, Claude Desktop and other MCP apps). Add this to the app's MCP settings; it needs uv. The server is in the official MCP registry as io.github.lucas19919/diagonaldiagrams.

{
  "mcpServers": {
    "diagonaldiagrams": { "command": "uvx", "args": ["diagonaldiagrams", "mcp"] }
  }
}

Claude Desktop can also open the .mcpb file from the latest release.

Claude Code

/plugin marketplace add lucas19919/diagonaldiagrams
/plugin install diagonaldiagrams@diagonaldiagrams

Any other agent: tell it Install diagonaldiagrams from https://github.com/lucas19919/diagonaldiagrams. It follows the install skill, then draws with the drawing skill. The short version for models is llms.txt.

What it draws

Command

Input

Draws

mermaid

flowchart, sequenceDiagram, erDiagram

A flow, a sequence, or a schema

flow, arch, seq, schema

JSON

The same four, from a spec

iso

JSON

A layer stack in isometric 3D, with links between layers

bar, line, scatter

CSV

A comparison, a trend, a relationship

geo

CSV or GeoJSON

Places on a built-in coastline

chart <type>

CSV or JSON

About 60 more

  • describe <type> prints the spec shape for any figure type.

  • --fit column sizes a figure for a README or docs page. slide is the default, and page is for print.

  • story turns one figure into several views in one page, and --gif films it when ffmpeg is installed.

  • apply edits a spec with a JSON patch, and export writes PNG, PDF, draw.io or Excalidraw files.

How it compares

Measured on 2026-10-19 against Mermaid CLI and Pele, on version 0.8.0, with the same four flowcharts of 5 to 40 steps.

  • Speed. A 20-step flowchart takes 152 ms, about 15 times faster than Mermaid CLI (2,340 ms) and about 1.5 times slower than Pele (101 ms).

  • Tokens. An agent used 4.4k to 6.4k tokens per figure at every size. At 5 to 20 steps Pele and Mermaid CLI used fewer (1.3k to 4.0k). At 40 steps diagonaldiagrams used 6.4k, Pele 6.3k and Mermaid CLI 15.4k. This is two runs, so treat it as a small sample.

  • Quality. In blind pairs, diagonaldiagrams was judged clearer than Pele 85% of the time and than Mermaid CLI 97% of the time on slide-sized figures. It lost where an architecture translated from Mermaid was sized for a narrow column: 0 of 8 against Pele.

The full tables, the method and the scripts to rerun them are in bench/.

Develop

python -m unittest discover tests/unit   # unit tests
python tests_smoke.py                    # the command-line contract
python scripts/golden.py                 # the reference figures, byte for byte

How the engine is put together: docs/ARCHITECTURE.md. How releases are made: PUBLISHING.md.

License

MIT. See LICENSE.

Available Tools

9 tools
applyPatch a spec fileA
Destructive

Edit a spec file with a patch instead of rewriting it: move or reorder items, rename text, change colors, add or remove things, or move them into a group, so a regenerated spec keeps the change. Changes the spec file in place and writes the patch beside it (SPEC.patch.json). Render the spec to the same out path again; changed in the result says what moved.

Inputs: spec (required), patch (required).

auditAudit an SVGA
Read-onlyIdempotent

Check a finished SVG or HTML figure for what you cannot see in your own output: text over text, arrows through boxes, text that spills out of its shape, low contrast, tiny text, and in 3D figures text hidden behind a nearer face. Works on any SVG on disk, not only ones this tool drew. Returns JSON: ok, errors with a fix, and warnings. Read-only. render already audits its own output, so use this after hand edits or on a figure from elsewhere.

Inputs: path (required).

describeDescribe a figure typeA
Read-onlyIdempotent

Look up how to write a spec. With a figure type it returns that type's spec shape, rules, size budgets and an example; with no type it lists every type. Also takes style and story. Read-only, writes nothing. Call it before render when you are unsure of the shape.

Inputs: type.

diffCompare two drawingsA
Read-onlyIdempotent

Say what changed between two drawings of the same figure (.svg or .html): items added, removed, renamed, moved, reordered or recolored, as JSON and plain sentences. Read-only. Use it after apply or an edit to confirm the change did what you meant.

Inputs: new (required), old (required).

exportExport a figure to another formatA
Idempotent

Redraw a rendered figure as png, pdf, svg, drawio or excalidraw. It reads the receipt (OUT.graph.json) that render wrote beside the figure, so the figure must have been drawn by this tool. Writes the new file next to it, or at out, and returns the path as a line of text. png and pdf need cairosvg or headless Edge or Chrome. Overwrites an existing file at the same path.

Inputs: path (required), to, out, layout.

inferSuggest a scatter spec from a CSVA
Read-onlyIdempotent

Propose a starting spec for a scatter chart from a CSV. Returns the spec as JSON to edit and pass to render. Read-only: it suggests and draws nothing. Only for scatter charts; for other charts, describe the type and write the spec yourself.

Inputs: data, path.

renderDraw and audit a figureA
Idempotent

Draw one figure and audit it in a single call. Validates the input, lays it out, writes OUT.svg, OUT.html and a receipt (OUT.graph.json) side by side, then checks the drawing. Returns one JSON line: ok, the file paths, a layout outline and any warnings. When ok is false, each error has a fix: change the spec or options and call render again. Overwrites files at the same out path. Use validate to check an input without drawing, and audit for an SVG this tool did not just draw.

Inputs: type (required), out, data, path, +3 more.

storyBuild an animated story pageA
Idempotent

Present one figure as a story: a story file lists views that focus, dim, highlight and reveal parts of it, and one HTML page animates between them. Writes OUT.html and returns JSON with ok, the path and the views; overwrites an existing page. describe story shows the story file's shape. For a plain figure use render.

Inputs: out (required), story (required).

validateValidate a specA
Read-onlyIdempotent

Check an input without drawing anything: a spec, scene or CSV. Returns JSON with ok and, on failure, errors that each carry a fix. Read-only, and cheaper than render while you are still shaping the spec. For a finished drawing use audit.

Inputs: type (required), data, path, spec, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool targets a distinct stage of the diagram workflow: describe for spec shapes, infer for CSV-to-spec, render for drawing, validate for input checks, audit for finished SVGs, export for format conversion, apply for patching specs, story for animated views, and diff for comparisons. The descriptions explicitly delineate overlaps (e.g., validate vs audit vs render auditing its own output), leaving no realistic confusion.

    Naming Consistency5/5

    All nine tools use a consistent lowercase single-verb imperative style (describe, infer, render, validate, audit, export, apply, story, diff). There are no mixed conventions such as camelCase or noun-heavy names, and the pattern is predictable.

    Tool Count5/5

    Nine tools is well within the ideal 3–15 range and each tool has a clear, non-redundant role in the diagram lifecycle. The set is neither bloated nor thin for a diagram rendering and auditing server.

    Completeness4/5

    The core lifecycle—spec discovery, inference, rendering, validation, auditing, export, patching, story presentation, and diffing—is broadly covered. Minor gaps exist: there is no dedicated tool to create or edit story files, and non-scatter spec creation relies on the user writing the spec after using describe.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers