Skip to main content
Glama
C4 Diagram MCP Server

C4 Diagram MCP Server

by tarastclair

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

NameRequiredDescriptionDefault
relNoArrow style for sequence diagrams (e.g., "o->", "-->", "<-")
linkNoOptional URL link for the relationship
tagsNoOptional styling tags for the relationship
spriteNoOptional sprite/icon for the relationship
sourceIdYesID of the source element
targetIdYesID of the target element
diagramIdYesUUID of the diagram from create-context-diagram
directionNoDirection of the relationshipstandard
projectIdYesUUID of the project from create-c4-project
technologyNoOptional technology used in the relationship
descriptionYesDescription of the relationship

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It usefully discloses the mutation's return payload (message, projectId, elementIds) and that a state object directs the next step, but it says nothing about permissions, duplicate/conflicting relationships, or what happens if sourceId/targetId don't exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well front-loaded with required inputs first, then optional, then examples and response fields, so an agent can scan it quickly. There is some waste: the rel example list repeats "->" twice and the bulleted arrow examples later restate the same three cases.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 11-parameter mutation with no output schema, the description supplies response fields and the required downstream call, which is more than most. It is still thin on failure modes and on how direction interacts with rel for sequence diagrams.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents every parameter and the baseline is 3. The description mostly restates those same descriptions and the required/optional split, with only the rel arrow-syntax examples adding meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives a specific verb and resource ("Add a relationship between elements in the C4 diagram") that an agent can act on immediately. It does not explicitly contrast with the sibling update-relationship, so the add-vs-modify distinction is left to the tool name alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states clear workflow context: keep calling add-element/add-relationship to build the diagram and then "you must call the generate-diagram-image tool" at the end, and it scopes the rel parameter to sequence diagrams. It gives no explicit when-not-to-use guidance and never names update-relationship as the alternative for modifying an existing relationship.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.