add-relationship
Connect C4 diagram elements by adding relationships with source, target, description, and optional direction or technology. Model interactions and dependencies before generating the diagram image.
Instructions
Add a relationship between elements in the C4 diagram.
Required Input Fields:
- projectId: String (UUID from create-c4-project)
- diagramId: String (UUID from create-context-diagram)
- sourceId: String (UUID of the source element)
- targetId: String (UUID of the target element)
- description: String (Description of the relationship)
Optional Input Fields:
- technology: String (Technology used in the relationship)
- direction: String (Relationship direction: standard, bidirectional, up, down, left, right, back, neighbor)
- sprite: String (Icon/sprite for the relationship)
- tags: String (Styling tags for the relationship)
- link: String (URL link for the relationship)
- rel: String (for sequence diagrams)
For sequence diagrams, you can specify custom arrow styles using the rel parameter:
- Common examples: "->", "-->", "<-", "o->", "->o", "->"
- The rel parameter accepts any valid PlantUML arrow syntax
- For example, "o->" represents an asynchronous message, "->o" represents a message to a participant's lifeline
- For the complete reference of arrow types, refer to PlantUML's sequence diagram documentation
Examples:
- A standard synchronous call: $rel="->" (solid arrow)
- An asynchronous message: $rel="o->" (starting with a circle)
- A return message: $rel="<-" (arrow pointing backward)
The response will include unique IDs that you'll need for all subsequent operations,
as well as a state object that will direct you to the appropriate next step to take.
Response Fields:
- message: String (User-friendly message about the update)
- projectId: String (UUID of the project)
- elementIds: Object (Mappings of element UUIDs to their names)
You can continue to use the add-element and add-relationship tools to design your diagram,
and when you're finished, you must call the generate-diagram-image tool to create
a png image of the completed diagram.Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"projectId": "<projectId>",
"diagramId": "<diagramId>",
"sourceId": "<sourceId>",
"targetId": "<targetId>",
"description": "<description>"
},
"name": "add-relationship"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rel | No | Arrow style for sequence diagrams (e.g., "o->", "-->", "<-") | |
| link | No | Optional URL link for the relationship | |
| tags | No | Optional styling tags for the relationship | |
| sprite | No | Optional sprite/icon for the relationship | |
| sourceId | Yes | ID of the source element | |
| targetId | Yes | ID of the target element | |
| diagramId | Yes | UUID of the diagram from create-context-diagram | |
| direction | No | Direction of the relationship | standard |
| projectId | Yes | UUID of the project from create-c4-project | |
| technology | No | Optional technology used in the relationship | |
| description | Yes | Description of the relationship |