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:
1) get_diagram(diagramId) → shows nodes n_api, n_db and version 1.
2) 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 }.
ConnectorNo auth