Repository navigation
Mermaid in, editable draw.io out: every type checked, plugins convert without draw.io Desktop - #120
Conversation
…to draw The viewer converted the first Mermaid diagram of a page before the Recursive font of Mermaid 12's redux themes had loaded, so its labels were measured in a fallback font and the boxes came out about 20 % too narrow (a class box 331 px wide instead of 397). The final conversion now loads the fonts mxMermaidToDrawio.getFonts names first, at most 3 s per font, as draw.io's editor does; a streaming preview made before they were there is not reused as the result. A diagram whose statements the parser didn't recognize converted to an empty frame; it is now an error with draw.io's own message. The headers draw.io converts that the reference doesn't teach (swimlane-beta, usecase-beta, agentflow-beta, cynefin-beta, the railroad variants, eventmodeling-beta, flowchart-elk) are recognized as Mermaid when passed as xml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/mermaid-to-drawio.js converts Mermaid to an editable .drawio file when draw.io Desktop isn't installed: it runs draw.io's own converter from viewer.diagrams.net (HeadlessEditorUi.parseMermaidDiagram, as the desktop CLI does) in an installed headless Chrome, Edge, Chromium or Brave, with Node's built-ins only. Only the scripts and fonts are downloaded; the Mermaid is converted locally and sent nowhere. Without a browser it exits with 3 and --link prints a #create= link that draw.io converts on open. The skill uses it when the CLI is missing, instead of rewriting the diagram as XML; the body stays under 24,000 bytes (23,781). Mirrored byte-identically to the Codex, Copilot, Cursor and Antigravity plugins; version 1.3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One diagram of each type draw.io converts (the reference's 28 plus swimlane, use case, agent flow, railroad and Cynefin), converted in the app's HTML by the viewer and by the plugins' mermaid-to-drawio.js, plus every example of the reference. Checks: cells, not an image; nothing locked; the labels are cells' text; shapes inside their containers; how many edges may have a loose end and how many cells may be images, which records what drawio-mermaid doesn't do yet per type. The class diagram converts first, so the viewer's font wait is checked against the plugins' converter. Skips without a browser or the network. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The root README says what every route does with Mermaid and what the conversion doesn't do yet, the registry description leads with it, and the app server's AGENTS.md has the font wait, the empty-diagram error, the per-type test and the gaps per type. The privacy table names the downloads of the plugins' converter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… read Node can fire the browser's exit before the last of its stderr is read, so the "No usable sandbox" line could arrive too late and the script exited with 3 instead of retrying with --no-sandbox. The exit's error now waits for stderr to end, at most 1 s, and close() no longer waits for an exit that has already happened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its own text The preview parses the text up to its last newline but cached the parse under the whole partial, so a final text that came with its last line reused the parse without it, and a preview without cells skipped the "Nothing to draw" error. It is kept now only when the rest after the last newline is blank and it has cells; mermaid-types.test.js streams both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
I re-reviewed after the two follow-up commits and didn't find any new bugs. Because this is a large change that adds a new script that launches a local browser and loads draw.io's scripts from viewer.diagrams.net, a human look would still be worthwhile.
What was reviewed:
- mermaid-to-drawio.js: the browser exit handler now waits for stderr to end (or 1 s) before choosing between NO_SANDBOX and EXITED, so a late "No usable sandbox" line still triggers the relaunch.
- shared.js handleMermaidPartial: the preview now caches only when the text after the last newline is blank and the XML has cells, so a reused result is neither truncated nor empty. The
\\sescaping matches the file's template-string convention.
Extended reasoning...
The PR touches 32 files (about 3,700 added lines). It changes the app server's Mermaid conversion (font loading, an error for diagrams with no cells, recognition of beta headers) and adds a 524-line converter script, mirrored to five plugins, that spawns headless Chrome/Edge/Chromium/Brave and downloads draw.io scripts and fonts. The browser launch and the loading of remote scripts are the sensitive part. The commits since the last review fix the two earlier inline findings (and the pre-existing one) in the code. The size of the change and the new process-spawning script are why this is deferred rather than approved.
Brings in #116 (PlantUML and CSV in create_diagram) and #117 (the @drawio/mcp npm entry in server.json, version 1.13.1, and its test). Conflicts, both sides kept: - server.json description: "Mermaid, PlantUML, CSV or XML in, editable draw.io diagrams out, live in chat. 10,000+ shapes." Since #116 the viewer converts PlantUML (drawio-plantuml) and CSV (draw.io's CSV import) into draw.io cells, and this branch makes every Mermaid type come out as cells, so the line is true now and is the one #121 sets. - README comparison table: the app server takes all three and PlantUML (#116); the skill converts Mermaid with draw.io Desktop or an installed Chrome, Edge or Chromium (this branch). - docs/app-server-tools.md: the create_diagram input lists plantuml and csv (#116) with this branch's Mermaid details, followed by #116's PlantUML and CSV paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ntainers
As root on Linux (Docker, dev containers, CI jobs) Chrome refuses to start
its sandbox ("Running as root without --no-sandbox is not supported"), and
the script only relaunched on "No usable sandbox", so it exited with 3 and
the skill fell back to a link. As root it now passes --no-sandbox from the
start, and it relaunches without the sandbox on every line Chrome prints
when it can't start one: no user namespaces, run as root, a SUID helper
that isn't set up, a container that may not make namespaces. A test with a
stand-in for the browser checks each, without a browser.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#120 is in main as one squash commit (3f15a69). This keeps only this branch's own change on top of it: libavoid loaded after the converter, the swimlane routing test, 1.3.1. In DEVELOPING.md main's Sandbox bullet stays, with this branch's libavoid, Swimlanes and Tests text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #120 (Mermaid in, editable draw.io out). In docs/app-server-tools.md the Mermaid input keeps both: main's native conversion in the viewer, checked per type, and this branch's flowcharts, ER and sequence diagrams on the server, with this branch's two bullets for server and viewer conversion. #120's new README section and the app server's Mermaid Conversion section now say which types the server converts and which the viewer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#120 has the server take the headers draw.io converts that the reference doesn't teach (agentflow-beta, eventmodeling-beta and the railroad variants) as Mermaid. The server's header check didn't know five of them and turned them away as misspelled types, so they now pass on to the viewer. flowchart-elk is converted on the server, so its case in the lenient-input test expects the converted diagram. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s on the server (#121) * feat(app-server): PlantUML and CSV in create_diagram create_diagram takes `plantuml` and `csv` besides `xml` and `mermaid`. The viewer converts them with draw.io's own converters, as Arrange > Insert > Advanced does: PlantUML with drawio-plantuml, loaded from viewer.diagrams.net only when a PlantUML diagram comes in, CSV with the CSV import of the viewer bundle on an offscreen graph. "Open in draw.io" keeps the PlantUML source in the group draw.io makes on insert, and the model gets the converted diagram in its context, as for Mermaid. The server checks what would fail in the viewer (no @start/@EnD lines, a CSV without data lines, the orgchart layout, whose bundle the viewer doesn't load), draws PlantUML passed as xml or mermaid as PlantUML, and gives clients without the app a #create link for CSV. draw.io links can't carry PlantUML, so those clients are asked to redraw it. %column% placeholders in CSV styles work: draw.io's decompression runs decodeURIComponent on the inflated data, which throws "URI malformed" only for CSV compressed without being URL-encoded first. The app server's link encodes first, as the tool server does; the tool server's warning against these placeholders is replaced by that explanation (checked in app.diagrams.net on 2026-11-18). The tool description names the formats in its first line only (2038 of 2048 characters); the new parameters say to use them for source the user gives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(app-server): empty plantuml/csv and late conversions in the viewer The viewer counts plantuml or csv as given only when its text is more than white space, as the server does (sourceArgument), so a host that sends the unused parameters as "" keeps the XML or Mermaid preview and gets no converter error. A PlantUML or CSV conversion still running when the tool result or endStreaming comes is dropped (sourceRender), so it no longer replaces an error the server returned with the diagram or its own error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(app-server): convert Mermaid, PlantUML and CSV into draw.io cells on the server create_diagram no longer only hands Mermaid, PlantUML and CSV to the viewer. The types shared/convert reads are converted on the server into editable draw.io cells, laid out by shared/semantic (sequence diagrams by their own placement in draw.io's UML shapes) and styled in the calm theme, with the colors the source writes on top: - Mermaid flowcharts, ER and sequence diagrams - PlantUML sequence and activity diagrams (the new syntax) - draw.io CSV: rows keep their columns as data (UserObject with the label template and placeholders), identity, parent, connect, width/height and the tree, flow and none layouts The result is XML after the usual passes, with a note on what was converted, warnings for what isn't drawn as written, and a #R link for clients without the app. A syntax error is a tool error that names the line, its text, what is wrong and how to fix it. Other types go to draw.io's own converters in the viewer as before, with a note. A Mermaid flowchart with postLayout elk (or a flowchart-elk header) is laid out again with ELK in the viewer. The viewer previews the same conversion while the source streams in (the converters are bundled with the semantic engine). DRAWIO_CONVERT=off restores the viewer-only behaviour. The first sentence of the create_diagram description now says what the model gains; the parameter descriptions say what is converted on the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: conversion of Mermaid, PlantUML and CSV on the server shared/convert gets its AGENTS.md (what each format covers, the rules, the files); the app server's AGENTS.md, docs/app-server-tools.md, the root AGENTS.md and the semantic engine's AGENTS.md describe the conversion, the result, the preview, the DRAWIO_CONVERT switch, the styles option and what has not been measured yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(convert): ELK from the Mermaid config, quotes in comments and messages A Mermaid flowchart that selects ELK in its config, as the Mermaid reference teaches (`layout: elk` in the frontmatter `config` or an `%%{init}%%` directive, or the older `defaultRenderer: "elk"`), came back in the server's own layout: only a `flowchart-elk` header counted, and the config only gave the warning that it is not used. readHeader now reads those selectors as draw.io does (EditorUi.isMermaidElkFlowchart, drawio-mermaid), so the payload carries `postLayout: "elk"` and the viewer lays the cells out again. The warning names only what is still not used ("Apart from the ELK layout, …"); an ER diagram with `layout: elk` still gets it, since it has a layout of its own. A single `"` in a `%%` comment (`%% 3.5" drive`) or a sequence message (`The 27" monitor`) opened a quoted label that took every later line into one: a flowchart lost its nodes, a sequence diagram its later messages, without a warning. Quotes now open a label only where Mermaid reads a string: not in `%%` lines, accessibility lines, frontmatter or the header, and not in a sequence diagram, where `"` in a message or note is text. A quote still open at the end of the text opened no label, so the lines after it are read as lines of their own (text still streaming in keeps it open, as a label still being written). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: one example per format for Mermaid, PlantUML and CSV, release notes The root README gets a short section on create_diagram's input formats: what is converted on the server into editable draw.io shapes (Mermaid flowcharts, ER and sequence diagrams, PlantUML sequence and activity diagrams, draw.io CSV), what goes to the viewer's converters, and one minimal example per format, each checked through create_diagram. The app server README's parameter rows said PlantUML and CSV were converted in the viewer only; they now say what the server converts, and the self-hosting paragraph names DRAWIO_CONVERT=off. CHANGELOG.md is new: release notes for the next app server release, linking the blog post at drawio.com/blog/mcp-mermaid-plantuml-csv/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(listings): name Mermaid, PlantUML and CSV in the registry and plugin directory The MCP Registry description of io.draw/mcp now reads "Mermaid, PlantUML, CSV or XML in, editable draw.io diagrams out, live in chat. 10,000+ shapes." (94 of 100 characters). The listing text of the plugin directory package for ChatGPT and Codex (openai-plugin) says a diagram written in Mermaid, PlantUML or CSV can be pasted and becomes shapes to edit. Nothing is published; the package needs a version bump when it is uploaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(convert): name a type left to the viewer as Mermaid writes it For a diagram type the server leaves to draw.io's converter in the viewer, the note to the model wrote the type as the converter reads it, lowercased: "Mermaid classdiagram diagrams are converted …", and for PlantUML "usecase" or "uml". typeName (shared/convert/index.js) now gives the name the note uses: the Mermaid header as Mermaid writes it, in backticks (`classDiagram`, `C4Context`, `treeView-beta`), and the PlantUML family in words ("use case", "`@startmindmap`"), none for an @startuml diagram of no family the converter tells apart. The fallback's `type` stays the lowercased id. The header table behind it is complete now, so the hint for a misspelled Mermaid header names C4Dynamic, C4Deployment, classDiagram-v2 and treeView-beta as Mermaid writes them too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(convert): every Mermaid header draw.io converts is a type #120 has the server take the headers draw.io converts that the reference doesn't teach (agentflow-beta, eventmodeling-beta and the railroad variants) as Mermaid. The server's header check didn't know five of them and turned them away as misspelled types, so they now pass on to the viewer. flowchart-elk is converted on the server, so its case in the lenient-input test expects the converted diagram. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Every Mermaid diagram type draw.io converts now comes out as a native, editable draw.io diagram on every route (shapes, connectors attached to the shapes they join, labels that are the shapes' own text, no image fallback), and the plugins convert Mermaid without draw.io Desktop.
What it does
App server: fonts and empty diagrams (
mcp-app-server/src/shared.js)mxMermaidToDrawio.getFontsnames, at most 3 s per font, as draw.io's editor does. A streaming preview made before the fonts were there is no longer reused as the result.swimlane-beta,usecase-beta,agentflow-beta,cynefin-beta, the railroad variants,eventmodeling-beta,flowchart-elk) are recognized as Mermaid when passed asxml.Plugins: Mermaid without draw.io Desktop (version 1.3.0)
skills/drawio/scripts/mermaid-to-drawio.jsconverts Mermaid to an editable.drawiofile when draw.io Desktop is not installed. It runs draw.io's own converter from viewer.diagrams.net (HeadlessEditorUi.parseMermaidDiagram, as the desktop CLI does) in an installed headless Chrome, Edge, Chromium or Brave, using only Node's built-ins. Only draw.io's scripts and fonts are downloaded; the Mermaid is converted locally and sent nowhere. Without a browser it exits with 3, and--linkprints a#create=link that draw.io converts when it opens..github/plugin/marketplace.jsonare at 1.3.0.Tests (
mcp-app-server/test/mermaid-types.test.js)mermaid-to-drawio.js, plus every example in the Mermaid reference.DRAWIO_TEST_BROWSER=off).test/lenient-input.test.jschecks that the beta headers are recognized as Mermaid.Docs
server.jsonregistry description leads with "Mermaid in, editable draw.io out".AGENTS.mddescribes the font wait, the empty-diagram error, the per-type test and the gaps per type. The plugin READMEs and DEVELOPING.md files describe the new converter.Known gaps (in draw.io's Mermaid converter, not in this repository)
In a few types some parts still come out as drawings rather than connected cells: loose lines in timeline, tree view, Ishikawa, railroad, event modeling and Cynefin diagrams; radar curves as images; names placed beside their shapes in architecture and Wardley diagrams; some shapes not inside their containers; and no title in railroad diagrams. Swimlane diagrams are not routed, because the editor's libavoid router is not on the CDN. The per-type limits in the test record these gaps, so a converter fix shows up as a limit that can be tightened.
How it was tested
mcp-app-server:npm test(node --test) with Chrome installed, including the new per-type Mermaid test run through both the viewer and the plugins' converter: 329 tests, 325 pass, 0 fail. All 35 per-type Mermaid tests ran and pass, as do the reference-examples, font and empty-diagram tests. The 4 skipped tests are unrelated to this change: two need a live Worker URL, one needs elkjs, and one only writes an optional report.mcp-tool-server:npm test: 153 tests, 153 pass, 0 fail.check-skill-sync.yml, run locally: the four ports are byte-identical to the Claude Code copy, the SKILL.md body is 23,781 bytes, the bundled scripts passnode --check, and the front matter parses as YAML.This PR releases nothing: no version bump of the app server or the tool server, and no deploy.
🤖 Generated with Claude Code