Skip to content

feat(app-server): convert Mermaid, PlantUML and CSV into draw.io cells on the server - #121

Merged
alderg merged 11 commits into
mainfrom
voice/server-conversion
Nov 18, 2026
Merged

alderg merged 11 commits into
mainfrom
voice/server-conversion

Conversation

@alderg

@alderg alderg commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #116. This branch contains #116's two commits (PlantUML and CSV in create_diagram, and its review fix) and should be merged after it; once #116 is in, the diff here is only the last two commits.

What changes

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 (flowchart, graph, flowchart-elk), 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 ({xml, converted, _buildId}), with a note on what was converted, warnings for what isn't drawn as written, and a #R link for clients without the app (PlantUML gets a link for the first time). 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 that names them. 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 script (about 315 KB → 484 KB, 91 → 137 KB gzipped). DRAWIO_CONVERT=off restores the viewer-only behaviour, and a comma list converts only the formats it names. The first sentence of the create_diagram description now says what the model gains; the mermaid, plantuml and csv parameter descriptions say what is converted on the server.

The second commit documents it: a new shared/convert/AGENTS.md, and updates to the app server's AGENTS.md, docs/app-server-tools.md, the root AGENTS.md, README.md and shared/semantic/AGENTS.md.

Rebase onto #116's review fix

The viewer's tool-input handlers now use #116's sourceArgument, so an empty plantuml or csv beside XML or Mermaid is ignored both for the server-conversion preview and for draw.io's converters, and endStreaming clears both sourceRender and the conversion preview's key.

Docs, release notes, listings and the viewer note

  • 8357f39 README: a section on the input formats with one minimal, working example each for Mermaid, PlantUML and CSV, what is converted to editable shapes and what goes to the viewer (each example checked against the current code). A new CHANGELOG.md with the release notes for the next release, linking the blog post at https://www.drawio.com/blog/mcp-mermaid-plantuml-csv/ (only on drawusaurus's voice/mcp-mermaid-plantuml-csv branch so far).
  • 6ac5881 The MCP Registry description (server.json) and the OpenAI plugin-directory listing name Mermaid, PlantUML and CSV. Nothing is published; the listing needs a version bump when it is uploaded. chore(registry): list @drawio/mcp in server.json, name the formats #117 and Mermaid in, editable draw.io out: every type checked, plugins convert without draw.io Desktop #120 each rewrite the same server.json line differently, so whichever merges last settles the wording. The Codex CLI plugin's skill takes only Mermaid and XML, so its description is unchanged.
  • f48b5cb For a type left to the viewer, the note to the model wrote it lowercased ("Mermaid classdiagram diagrams …"). It now names the Mermaid header as Mermaid writes it (classDiagram, C4Context) and the PlantUML family in words ("use case", @startmindmap), through typeName in shared/convert/index.js; the fallback's type stays the lowercased id. The hint for a misspelled header gets the same complete table. Covered by a new test in test/convert.test.js.

Not measured yet

  • The new first sentence changes tools/list, so the ChatGPT app needs a Rescan once this is deployed.
  • Which format models choose with the new description (XML they place or Mermaid) has not been measured again; for flowcharts the measured rule still asks for XML.

Tests

  • mcp-app-server: npm test, 342 tests, 339 pass, 3 skipped (two need EDGE_COMPARE_URL, one needs elkjs). New test/convert.test.js covers the three formats, errors with their line, partial input, what is left to the viewer, the switch, the bundle giving the same XML as the modules, and the tool's results and parameters.
  • mcp-tool-server: npm test, 153 pass.

🤖 Generated with Claude Code

alderg and others added 4 commits November 18, 2026 08:42
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>
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>
…s 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>
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>
Comment thread shared/convert/mermaid.js Resolved
Comment thread shared/convert/index.js Resolved
…sages

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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new blocking issues. 1 optional suggestion (a nit or a note on pre-existing code) was found and not posted.

alderg and others added 3 commits November 18, 2026 17:49
…otes

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>
…lugin 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>
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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

alderg added a commit that referenced this pull request Nov 18, 2026
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>
Brings in #116 as squash-merged (identical to the two #116 commits
already on this branch) and #117 (the @drawio/mcp npm entry in
server.json at 1.13.1, its test, the tool server's mcpName).

Conflicts, both sides kept:
- the files #116 and this branch both changed: this branch's version,
  since main's #116 is the same as this branch's copy of it
- server.json description: this branch's line ("Mermaid, PlantUML, CSV
  or XML in, editable draw.io diagrams out, live in chat. 10,000+
  shapes."), with #117's version and packages entry
- mcp-app-server/AGENTS.md key files: this branch's semantic-bundle.js
  row, #117's server.json row

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

alderg and others added 2 commits November 18, 2026 18:28
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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

@alderg
alderg merged commit dc1c954 into main Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant