Edit architecture diagram
edit_diagramApply a sequence of modifications to an existing diagram: add, remove, or update nodes, edges, groups, or insert a node between two connected nodes. Returns updated diagram as SVG, Mermaid, and a live link.
Instructions
Apply a list of operations to an EXISTING diagram. The ops re-use this tool's op vocabulary; you author them, we validate + apply + re-layout + re-render.
ALWAYS call get_diagram(diagramId) first: it returns the current ids and the version. Pass that version as baseVersion. If the diagram changed since you fetched it, you get a STALE_VERSION error telling you the current version — refetch with get_diagram, recompute your ops, and retry.
The operations (each element of ops):
add_node { op, node:{ id, label, kind, parentId? } }
remove_node { op, id } (also drops edges touching the node)
update_node { op, id, patch:{ label?, kind?, parentId?, metadata? } }
add_edge { op, edge:{ id, source, target, kind, label?, directed? } }
remove_edge { op, id }
update_edge { op, id, patch:{ source?, target?, label?, kind?, directed? } }
add_group { op, group:{ id, label, type, parentId? } }
remove_group{ op, id }
move_to_group { op, nodeId, groupId } (groupId null un-nests the node)
set_layout { op, patch:{ direction?, spacing? } }
insert_between { op, newNode:{ id, label, kind, parentId? }, sourceId, targetId, inKind?, outKind? }
insert_between IS THE KEY OP for "add X between A and B" requests. It splices newNode onto the existing A→B edge: removes that edge, adds the node, and wires A→newNode→B so the connection re-routes through it automatically.
WORKED EXAMPLE — "add a Redis cache between the API and the DB" on the diagram above:
get_diagram(diagramId) → shows nodes n_api, n_db and version 1.
edit_diagram({ diagramId, baseVersion: 1, ops: [ { "op": "insert_between", "sourceId": "n_api", "targetId": "n_db", "newNode": { "id": "n_redis", "label": "Redis", "kind": { "catalog": "saas", "type": "redis" }, "parentId": "g_vpc" }, "inKind": "request", "outKind": "data_flow" } ] }) The API→DB edge is gone and now flows API→Redis→DB. Never send x/y/position — geometry is computed for you.
Node kinds: catalog ∈ {aws, gcp, azure, k8s, saas, generic} with rich per-catalog types (e.g. aws:lambda, gcp:bigquery, azure:cosmos_db, k8s:deployment, saas:kafka), plus generic flowchart kinds (process, decision, terminator, data, document, subprocess).
Returns { url, svg, mermaid, appliedOps, version }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ops | Yes | ||
| diagramId | Yes | The diagram to edit (from create_diagram or get_diagram). | |
| baseVersion | Yes | The version you are editing against — get it from get_diagram. Stale → STALE_VERSION. |