edit_diagram
ActiveTool of Flowgraf
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 }.
Parameters schema
{
"type": "object",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": [
"diagramId",
"baseVersion",
"ops"
],
"properties": {
"ops": {
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"required": [
"op",
"node"
],
"properties": {
"op": {
"type": "string",
"const": "add_node"
},
"node": {
"type": "object",
"required": [
"id",
"label",
"kind"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"kind": {
"type": "object",
"required": [
"catalog",
"type"
],
"properties": {
"type": {
"type": "string",
"maxLength": 512,
"minLength": 1
},
"catalog": {
"enum": [
"aws",
"gcp",
"azure",
"k8s",
"saas",
"generic"
],
"type": "string"
}
},
"additionalProperties": false
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"bold": {
"type": "boolean"
},
"fill": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"border": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"textSize": {
"enum": [
"s",
"m",
"l"
],
"type": "string"
}
},
"additionalProperties": false
},
"metadata": {
"type": "object",
"propertyNames": {
"type": "string",
"maxLength": 256
},
"additionalProperties": {}
},
"parentId": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"id"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"op": {
"type": "string",
"const": "remove_node"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"id",
"patch"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"op": {
"type": "string",
"const": "update_node"
},
"patch": {
"type": "object",
"properties": {
"kind": {
"type": "object",
"required": [
"catalog",
"type"
],
"properties": {
"type": {
"type": "string",
"maxLength": 512,
"minLength": 1
},
"catalog": {
"enum": [
"aws",
"gcp",
"azure",
"k8s",
"saas",
"generic"
],
"type": "string"
}
},
"additionalProperties": false
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"bold": {
"type": "boolean"
},
"fill": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"border": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"textSize": {
"enum": [
"s",
"m",
"l"
],
"type": "string"
}
},
"additionalProperties": false
},
"metadata": {
"type": "object",
"propertyNames": {
"type": "string",
"maxLength": 256
},
"additionalProperties": {}
},
"parentId": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"edge"
],
"properties": {
"op": {
"type": "string",
"const": "add_edge"
},
"edge": {
"type": "object",
"required": [
"id",
"source",
"target",
"kind"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"kind": {
"enum": [
"request",
"response",
"async_event",
"data_flow",
"dependency",
"network",
"generic"
],
"type": "string"
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"bold": {
"type": "boolean"
},
"color": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"width": {
"enum": [
"thin",
"normal",
"thick"
],
"type": "string"
},
"textSize": {
"enum": [
"s",
"m",
"l"
],
"type": "string"
}
},
"additionalProperties": false
},
"source": {
"type": "string",
"minLength": 1
},
"target": {
"type": "string",
"minLength": 1
},
"directed": {
"type": "boolean"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"id"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"op": {
"type": "string",
"const": "remove_edge"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"id",
"patch"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"op": {
"type": "string",
"const": "update_edge"
},
"patch": {
"type": "object",
"properties": {
"kind": {
"enum": [
"request",
"response",
"async_event",
"data_flow",
"dependency",
"network",
"generic"
],
"type": "string"
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"bold": {
"type": "boolean"
},
"color": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"width": {
"enum": [
"thin",
"normal",
"thick"
],
"type": "string"
},
"textSize": {
"enum": [
"s",
"m",
"l"
],
"type": "string"
}
},
"additionalProperties": false
},
"source": {
"type": "string",
"minLength": 1
},
"target": {
"type": "string",
"minLength": 1
},
"directed": {
"type": "boolean"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"group"
],
"properties": {
"op": {
"type": "string",
"const": "add_group"
},
"group": {
"type": "object",
"required": [
"id",
"label",
"type"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"type": {
"enum": [
"vpc",
"subnet",
"availability_zone",
"region",
"cluster",
"trust_boundary",
"logical"
],
"type": "string"
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"color": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"dashed": {
"type": "boolean"
}
},
"additionalProperties": false
},
"parentId": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"id"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"op": {
"type": "string",
"const": "remove_group"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"id",
"patch"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"op": {
"type": "string",
"const": "update_group"
},
"patch": {
"type": "object",
"properties": {
"type": {
"enum": [
"vpc",
"subnet",
"availability_zone",
"region",
"cluster",
"trust_boundary",
"logical"
],
"type": "string"
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"color": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"dashed": {
"type": "boolean"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"nodeId",
"groupId"
],
"properties": {
"op": {
"type": "string",
"const": "move_to_group"
},
"nodeId": {
"type": "string",
"minLength": 1
},
"groupId": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"patch"
],
"properties": {
"op": {
"type": "string",
"const": "set_layout"
},
"patch": {
"type": "object",
"properties": {
"engine": {
"enum": [
"elk",
"dagre"
],
"type": "string"
},
"spacing": {
"type": "object",
"properties": {
"node": {
"type": "number",
"maximum": 10000,
"minimum": 0
},
"layer": {
"type": "number",
"maximum": 10000,
"minimum": 0
}
},
"additionalProperties": false
},
"direction": {
"enum": [
"TB",
"LR",
"BT",
"RL"
],
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"patch"
],
"properties": {
"op": {
"type": "string",
"const": "set_theme"
},
"patch": {
"type": "object",
"properties": {
"mode": {
"enum": [
"light",
"dark",
"blueprint"
],
"type": "string"
},
"styleMode": {
"enum": [
"plain",
"shadow"
],
"type": "string"
},
"background": {
"enum": [
"dots",
"grid",
"plain"
],
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"title"
],
"properties": {
"op": {
"type": "string",
"const": "set_title"
},
"title": {
"type": "string",
"maxLength": 256,
"minLength": 1
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"op",
"newNode",
"sourceId",
"targetId"
],
"properties": {
"op": {
"type": "string",
"const": "insert_between"
},
"inKind": {
"enum": [
"request",
"response",
"async_event",
"data_flow",
"dependency",
"network",
"generic"
],
"type": "string"
},
"newNode": {
"type": "object",
"required": [
"id",
"label",
"kind"
],
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"kind": {
"type": "object",
"required": [
"catalog",
"type"
],
"properties": {
"type": {
"type": "string",
"maxLength": 512,
"minLength": 1
},
"catalog": {
"enum": [
"aws",
"gcp",
"azure",
"k8s",
"saas",
"generic"
],
"type": "string"
}
},
"additionalProperties": false
},
"label": {
"type": "string",
"maxLength": 512
},
"style": {
"type": "object",
"properties": {
"bold": {
"type": "boolean"
},
"fill": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"border": {
"enum": [
"gray",
"slate",
"blue",
"teal",
"green",
"amber",
"orange",
"red",
"pink",
"violet"
],
"type": "string"
},
"textSize": {
"enum": [
"s",
"m",
"l"
],
"type": "string"
}
},
"additionalProperties": false
},
"metadata": {
"type": "object",
"propertyNames": {
"type": "string",
"maxLength": 256
},
"additionalProperties": {}
},
"parentId": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
},
"outKind": {
"enum": [
"request",
"response",
"async_event",
"data_flow",
"dependency",
"network",
"generic"
],
"type": "string"
},
"sourceId": {
"type": "string",
"minLength": 1
},
"targetId": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
}
]
}
},
"diagramId": {
"type": "string",
"minLength": 1,
"description": "The diagram to edit (from create_diagram or get_diagram)."
},
"baseVersion": {
"type": "integer",
"maximum": 9007199254740991,
"minimum": 1,
"description": "The version you are editing against — get it from get_diagram. Stale → STALE_VERSION."
}
}
}No endpoints wrapped at confidence ≥ 0.50.
Parent server
Flowgraf
1/7 registries