Produces Mermaid or PlantUML diagram code from user specifications for UML, architecture, and flow diagrams. Use when the user asks for a diagram (sequence, class, activity, use case, component, state, deployment), diagram code, or when generating diagram script for documentation, design, or the generate_uml MCP tool. Supports Kroki-renderable output.
Generate a single, correct Mermaid or PlantUML code block from a user's description. Output only the diagram script in one code block; no prose outside it.
generate_uml MCP toolThe generate_uml tool supports all Kroki diagram types via diagram_type (e.g. mermaid, plantuml, d2, graphviz, blockdiag, bpmn, vegalite, wavedrom, etc.). Use resource uml://types for the full list and uml://templates for starter code. For non-Mermaid/PlantUML types (D2, BlockDiag, BPMN, Bytefield, Vega, WaveDrom, etc.), see references/DIAGRAM-TYPES.md.
mermaid or plantuml.@startuml and end with @enduml.%% ... or PlantUML ' ...) to note assumptions.From the user's message or context, identify:
| Diagram Type | Mermaid syntax |
|---|---|
| Sequence | sequenceDiagram |
| Class | classDiagram |
| State | stateDiagram-v2 |
| Activity | flowchart (TB) |
| Component, Deployment, Network | flowchart + subgraphs |
| Gantt | gantt |
| MindMap | mindmap |
| Use Case | flowchart (actors + use cases; no native use case in Mermaid) |
| Timing | sequenceDiagram with timing notes |
| Object | classDiagram (instances via notes) or flowchart |
| JSON/YAML | flowchart representing the structure (not raw JSON/YAML inside the block) |
Default direction: TB. Use LR for architecture/component/deployment when it improves readability.
| Diagram Type | PlantUML |
|---|---|
| Sequence | sequence diagram syntax |
| Use Case | usecase diagram syntax |
| Class | class diagram syntax |
| Activity | activity diagram syntax |
| Component | component diagram syntax |
| State | state diagram syntax |
| Object | object diagram syntax |
| Deployment | deployment diagram syntax |
| Timing | timing or sequence |
| Network | deployment/component (nodes + links) |
| Wireframe | salt (simple UI wireframes) |
| Gantt | gantt syntax |
| MindMap | mindmap syntax |
| WBS | wbs syntax |
| JSON/YAML | class/object or mindmap representing structure |
Use left to right direction for architecture-heavy diagrams when it helps. Add a short title in the target language.
alt/opt for branches.generate_uml tool is available, call it with the produced diagram_type and code (e.g. diagram_type: "mermaid", "class", "sequence", "activity", "usecase" as appropriate).Example 1 (Mermaid – login flow)
User request: "User login flow: enter credentials, API validates, DB check, return JWT or error."
sequenceDiagram
actor User
participant Client
participant API
participant DB
User->>Client: Enter credentials
Client->>API: Validate request
API->>DB: Check credentials
alt Valid
DB-->>API: OK
API-->>Client: JWT
Client-->>User: Logged in
else Invalid
DB-->>API: Fail
API-->>Client: Error
Client-->>User: Show error
end
Example 2 (PlantUML – login sequence)
User request: "Login: validate, DB check, JWT or error."
@startuml
title Login flow
actor User
participant "API" as API
database DB
User -> API : credentials
API -> DB : validate
alt valid
DB --> API : OK
API --> User : JWT
else invalid
DB --> API : fail
API --> User : error
end
@enduml
Example 3 (Mermaid – API call sequence)
User request: "Show me a Mermaid sequence diagram for an API call."
Use sequenceDiagram with participants such as Client, API, Auth, DB. Show request/response and optional alt for success/error. See resource uml://mermaid-examples (key sequence_api) or uml://examples (Mermaid) for examples. Then call generate_uml("mermaid", code).
Example 4 (Mermaid – Gantt)
User request: "Generate a Gantt chart using Mermaid syntax."
Use a Mermaid gantt block with title, dateFormat, section, and tasks (with ids and durations or after). See resource uml://mermaid-examples (key gantt). Then call generate_uml("mermaid", code).
Convert class diagram to Mermaid
When the user asks to convert a class diagram (PlantUML or prose) into Mermaid:
classDiagram syntax: class name, then lines for attributes/methods with + - #.--|>, composition *--, aggregation o--, association -- with : label, dependency ..>.generate_uml("mermaid", code).BPMN process model
When the user asks how to draw a BPMN process model:
uml://bpmn-guide for the structured guide and to generate_uml with diagram_type bpmn for BPMN XML.For full diagram-type mappings and optional constraints (direction, detail_level, max_nodes, naming_style, group_by), see references/DIAGRAM-TYPES.md.