Skip to content

feat(app-server): PlantUML and CSV in create_diagram - #116

Merged
alderg merged 2 commits into
mainfrom
voice/plantuml-csv
Nov 18, 2026
Merged

alderg merged 2 commits into
mainfrom
voice/plantuml-csv

Conversation

@alderg

@alderg alderg commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

create_diagram in the MCP App Server takes two more formats, plantuml and csv, besides xml and mermaid.

What it does

  • PlantUML is converted in the viewer by draw.io's own PlantUML converter (drawio-plantuml, mxPlantUmlToDrawio.parseText), as Arrange > Insert > Advanced > PlantUML does in draw.io; no PlantUML server is involved. The 1.2 MB converter is loaded from viewer.diagrams.net/js/plantuml/ only when a PlantUML diagram comes in (PLANTUML_PATH inlines a local build for the Node server). "Open in draw.io", Copy and Download keep the PlantUML source in the group draw.io makes on insert, so the diagram stays editable as PlantUML.
  • CSV is converted with the CSV import of the viewer bundle (doImportCsv) on an offscreen graph, as Arrange > Insert > Advanced > CSV does. %column% placeholders work in labels and styles, stylePlaceholders=1 included; the ELK layouts use the page's ELK.
  • The server checks what would fail in the viewer and returns an error the model can act on: PlantUML without its @start…/@end… lines, a CSV without a header and a data line, the orgchart layout (its bundle isn't loaded by the viewer). PlantUML passed as xml or mermaid is drawn as PlantUML with a note.
  • Clients without MCP Apps get a #create= link of type csv for CSV. draw.io links can't carry PlantUML, so those clients are asked to draw it again as Mermaid or XML.
  • The model gets the converted diagram in its context, as for Mermaid.
  • The tool description names the two formats in its first line only (2038 of 2048 characters); the new parameters say to use them for source the user gives or asks for, so the format rule for XML and Mermaid is unchanged.

The "URI malformed" error with %column% in CSV styles

draw.io's Graph.decompress runs decodeURIComponent on the inflated data, which throws "URI malformed" on a raw %fill% only when the CSV was compressed without being URL-encoded first. The app server's link encodes before compressing, as the tool server already does, so the placeholders work. The tool server docs' warning against them is replaced by that explanation (checked in app.diagrams.net).

Tests

  • New mcp-app-server/test/plantuml-csv.test.js (server checks, the viewer's helpers, the fallback link); npm test in mcp-app-server (298 pass, 3 skipped, 0 fail) and mcp-tool-server (153 pass).
  • Checked end to end in headless Chrome with the app resource in a sandboxed frame: PlantUML sequence and class diagrams, PlantUML passed as mermaid, an unsupported PlantUML family (error shown), CSV with fillColor=%fill%, stylePlaceholders=1 and verticalflow, the orgchart and no-data errors, and XML and Mermaid unchanged.

Nothing is deployed; this ships with the next app server release.

🤖 Generated with Claude Code

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>

@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.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread mcp-app-server/src/shared.js Resolved
Comment thread mcp-app-server/src/shared.js Resolved
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>

@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.

I reviewed the follow-up commit and found no new bugs. This is still a large feature in the viewer, including on-demand loading of the 1.2 MB PlantUML converter from viewer.diagrams.net, so a human should also look at it.

What was reviewed:

  • sourceArgument now counts plantuml/csv only when non-blank. ontoolinput and ontoolinputpartial both use it, which matches the server's trim().length > 0 check.
  • The sourceRender token in renderSourceDiagram is cleared in endStreaming and ontoolresult, so a conversion that finishes late no longer draws over a tool error or a newer result.
  • Checked the server-side plantUmlProblem/csvProblem checks and the #create= CSV fallback link against the new tests in plantuml-csv.test.js. I didn't run the tests.
Extended reasoning...

The change adds PlantUML and CSV formats to create_diagram in mcp-app-server (about 580 lines in shared.js plus a 354-line test file) and updates docs and AGENTS.md files. Its main external surface is loading a remote converter script into the viewer when a PlantUML diagram comes in. It touches no auth or crypto. The follow-up commit 8a94e6c changes the code at both places named in the earlier inline comments. I deferred because of the size of the change and the remote script loading, not because of an open defect.

@alderg
alderg merged commit 5a78c26 into main Nov 18, 2026
1 check passed
@alderg
alderg deleted the voice/plantuml-csv branch November 18, 2026 16:58
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>
alderg added a commit that referenced this pull request Nov 18, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant