GitHubGitHub Stars
The problem

PlantUML and Mermaid lie.

LLMs love inventing UML syntax that does not exist — and those tools do not forgive it. The result: broken renderings, generic diagrams, hallucinations without validation.

kUML is Kotlin. The compiler checks every model. LLMs get instant, machine-readable feedback — and deliver correct models instead of pretty lies.

PaymentFlow.kuml.kts
// Named parameters make every DSL call self-explanatory
// — critical for reliable LLM generation.
sequenceDiagram(name = "Payment Flow") {
    val customer = lifeline(name = "Customer")
    val gateway  = lifeline(name = "API Gateway")
    val payments = lifeline(name = "Payment Service")
    val ledger   = lifeline(name = "Ledger")

    message(from = customer, to = gateway,  label = "POST /pay")
    message(from = gateway,  to = payments, label = "processPayment(order)")
    message(from = payments, to = ledger,   label = "debit(account, amount)")
    reply(from = ledger,     to = payments, label = "ok")
    reply(from = payments,   to = gateway,  label = "PaymentConfirmation")
    reply(from = gateway,    to = customer, label = "201 Created")
}
The method

Typed Domain Grounding.

kUML is the first instance of a more general method. To teach an LLM a new domain, don't invent a language — any new syntax is a foreign language with zero training data behind it. Instead, embed the domain as a type-safe DSL in a host language the model already speaks. Only the vocabulary is new, never the grammar — and the host compiler becomes a deterministic oracle over everything the model writes.

Classic grounding (RAG)

Anchors individual answers in retrieved facts. Data space: documents, embeddings, retrieval. Verifier: relevance heuristics and human judgement. Solves: wrong facts.

Typed Domain Grounding

Anchors an entire domain language in knowledge the model already has. Language space: host-language syntax and type system. Verifier: the compiler — deterministic and machine-checkable. Solves: invented structure. Orthogonal to RAG, and composable with it.

“Never invent syntax an LLM has never seen: embed the domain in a language it already knows — and let the compiler be the oracle.”
Five building blocks

What makes kUML LLM-ready.

MCP server

A first-class kuml-mcp binary — stdio JSON-RPC 2.0, MCP protocol 2024-11-05. Eleven tools out of the box: six authoring tools (render, validate,list_elements, describe,generate, examples) plus five Runtime tools for driving state machines and activity diagrams interactively (kuml.run.start/event/snapshot/patch/stop). Drop-in for Claude Desktop, Cursor, Continue and every MCP-capable agent.

MCP resources

Beyond tools, kuml-mcp advertisescapabilities.resources and serves the DSL knowledge itself — no tool-call round-trip needed:kuml://dsl/reference (the full builder-function reference for UML, SysML v2, C4 and BPMN), kuml://dsl/examples(curated example scripts for every diagram type), andkuml://dsl/schema (machine-readable JSON of every tool's input schema). MCP clients can auto-load this instead of learning the DSL only through render/validate feedback loops.

Named parameters

Every DSL call uses explicit named parameters by convention. LLMs produce more reliable code because the meaning of each argument is unambiguous — and the Kotlin compiler refuses what the model hallucinated.

Canonical formatter

kuml fmt normalises the source so the same model always looks the same — both for humans and for diffing LLM output. Combined with kuml validate the agent gets instant, structured JSON feedback on every iteration.

Real, published results

LLM benchmark

A Generate-Compile-Repair benchmark across 50 architecture tasks puts kUML ahead of PlantUML and Mermaid on structural fidelity (45.3% vs. 37.9%) and hallucination rate (15.4% vs. 16.5%) — a real compiler rejects what a permissive parser silently auto-declares.

Open the benchmark gallery
Model guidance

Which LLM should you use with kUML?

We ran the full 50-task Generate-Compile-Repair benchmark against 9 distinct models — five cloud frontier models, three local open-weight models via Ollama, and one model served over the decentralized Gonka compute network — with seven of those also tested with live MCP tool access to kuml.examples added on top, for 16 configurations total. Structural Fidelity (how closely a generated diagram matches a hand-authored gold standard) across every configuration tested so far:

Bar chart ranking 16 model configurations by kUML Structural Fidelity, from Claude Sonnet 5 with MCP tool access at 56.0% down to MiniMax-M2.7 without MCP tool access at 6.0%

Using a cloud API? Add MCP tools — but measure first.

Claude Sonnet 5 with live kuml.examples access via kuml-mcp is the best result we've measured (56.0% SF, up from 44.5% without the tool). Gemini 2.5 Flash improves substantially too. But MCP tool access is not a universal upgrade: GPT-4o and qwen3-coder:30b barely move, and one local model's compile rate collapsed from 60% to 2% simply because the tool was offered — even though it was never called. Test the delta for your own model before assuming tools help.

Running fully local? Results vary by model, not by size.

We tested three open-weight models on Ollama (qwen3-coder:30b, llama4:scout, deepseek-r1:70b). None consistently beats or loses to PlantUML/Mermaid the way frontier models do — one leads clearly, one trails clearly, one ties. "Bigger" and "newer" don't predict which. If you're picking a local model for kUML generation today, treat this as a starting point to benchmark against your own tasks, not a settled ranking.

Full methodology, all 16 configurations, per-family breakdowns, and how to reproduce this against your own model (cloud, decentralized-network, or local, no API key needed for Ollama):read the benchmark writeup· blog post· browse every generated diagram

MCP Setup

Drop in. Works in every MCP-capable agent.

Same JSON block, different file path — Claude Code, Claude Desktop, Cursor, Continue. From the first prompt onward the agent creates, validates and renders diagrams as SVG.

mcp.json — all clients
# ── Claude Code ─────────────────────────────────────────────────
# ~/.config/claude/mcp.json  (global)  ·  .mcp.json  (per project)
{
  "mcpServers": {
    "kuml": { "command": "kuml-mcp" }
  }
}

# ── Claude Desktop ────────────────────────────────────────────────
# macOS:  ~/Library/Application Support/Claude/claude_desktop_config.json
# Linux:  ~/.config/Claude/claude_desktop_config.json
# → same JSON block, different file path

# ── Cursor ────────────────────────────────────────────────────────
# .cursor/mcp.json  (per project)  ·  or: Settings → MCP → Add Server

# ── Continue ──────────────────────────────────────────────────────
# .continue/config.json  → add the same "mcpServers" block

# ── Tools (Protocol 2024-11-05) ───────────────────────────────────
#   Authoring: kuml.render · kuml.validate · kuml.list_elements
#              kuml.describe · kuml.generate · kuml.examples
#   Runtime:   kuml.run.start · kuml.run.event · kuml.run.snapshot
#              kuml.run.patch · kuml.run.stop
#
# ── Resources (auto-loaded DSL knowledge) ─────────────────────────
#   kuml://dsl/reference · kuml://dsl/examples · kuml://dsl/schema
#
# Example — Claude Code:
> Create a C4 container diagram for a Stripe webhook system
  and render it as SVG.
kUML Desktop

The desktop app as an MCP server.

Instead of starting kuml-mcp over stdio, an agent can connect straight to the running kUML Desktop app. It then works on the script that is open there and sees the live preview. The connection is local and protected by a token.

mcp (HTTP) — kUML Desktop
# ── kUML Desktop as an MCP server (HTTP, local only) ──────────────
# The desktop app's server is OFF by default.
# 1. In kUML Desktop:  Tools ▸ MCP server…  → switch it on.
# 2. Copy the ready-made command from the dialog (it contains port and token):
claude mcp add --transport http kuml-desktop http://127.0.0.1:<port>/mcp \
  --header "Authorization: Bearer <token>"
#
# Other HTTP-capable MCP clients: URL http://127.0.0.1:<port>/mcp, header
# "Authorization: Bearer <token>" (Streamable HTTP, POST /mcp only).
#
# The server listens on 127.0.0.1 only; the token is never displayed.
# The port is remembered across restarts, so the command stays valid.
# If the port is taken, a new port and token are chosen; copy the new command from the dialog.
#
# ── Tools ──────────────────────────────────────────────────────────
#   Open script:  kuml_desktop_get_script · kuml_desktop_set_script
#                 kuml_desktop_render
#   Workspace:    kuml_desktop_workspace_info · _list_documents
#                 _get_document · _set_document · _validate
#                 _render_document · _render_all · _open_document