Skip to content

UML (PlantUML)

UML-MCP supports the eight standard UML diagram types through the PlantUML backend on Kroki, plus a raw plantuml type for arbitrary @startuml source.

diagram_type Use it for
class Static structure: classes, attributes, methods, relationships
sequence Object interactions over time
activity Workflows and business processes
usecase Actors and system functionality
state Object lifecycle states
component Components and dependencies
deployment Physical architecture
object Class instances and their relationships
plantuml Raw PlantUML (any kind)

Plan before you generate

The default uml_diagram_with_thinking prompt produces a brief plan (purpose, elements, relationships) before the code, which dramatically improves first-shot diagram quality.

Class Diagrams

Class diagrams show the static structure of a system:

@startuml
class Car {
  -color: String
  -model: String
  +start(): void
  +accelerate(speed: int): void
}

class Driver {
  -name: String
  -license: String
  +drive(): void
}

Car -- Driver
@enduml

Sequence Diagrams

Sequence diagrams show object interactions arranged in time sequence:

@startuml
participant User
participant System
participant Database

User -> System: Login Request
System -> Database: Validate Credentials
Database --> System: Validation Result
alt successful case
    System --> User: Login Success
else failed case
    System --> User: Login Failed
end
@enduml

Activity Diagrams

Activity diagrams show workflows or business processes:

@startuml
start
:Check Authentication;
if (Authenticated?) then (yes)
  :Show Dashboard;
else (no)
  :Show Login Form;
endif
stop
@enduml

Use Case Diagrams

Use case diagrams show system functionality and actors:

@startuml
left to right direction
actor Customer
actor Clerk
rectangle Checkout {
  Customer -- (Checkout)
  (Checkout) .> (Payment) : include
  (Help) .> (Checkout) : extend
  (Checkout) -- Clerk
}
@enduml

State Diagrams

State diagrams show states of an object during its lifecycle:

@startuml
[*] --> Idle
Idle --> Processing: Start
Processing --> Completed: Success
Processing --> Failed: Error
Completed --> [*]
Failed --> Idle: Retry
@enduml

Component Diagrams

Component diagrams show components and dependencies:

@startuml
package "Frontend" {
  [Web UI]
  [API Client]
}
package "Backend" {
  [API Gateway]
  [Authentication]
  [Business Logic]
  database "Database"
}

[Web UI] --> [API Client]
[API Client] --> [API Gateway]
[API Gateway] --> [Authentication]
[API Gateway] --> [Business Logic]
[Business Logic] --> [Database]
@enduml

Tips for UML Diagrams

  1. Use PlantUML preprocessor for advanced features:

    !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
    

  2. Apply themes for better visuals:

    @startuml
    !theme cerulean
    class Example
    @enduml
    

  3. Use notes for additional information:

    @startuml
    class User
    note right of User: This class represents system users
    @enduml