uml-mcp

UML Diagrams

UML-MCP supports various UML diagram types through PlantUML.

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