edit_diagram
CHANGE AN EXISTING DIAGRAM instead of regenerating it: add, update and remove devices and links in a .drawio document and get the edited document back. This is the tool for "add a switch to this drawing" — create_diagram would redraw the whole page and throw away every position a human placed by hand. Call describe first to get the ids, then name them here. Everything you do not name keeps its exact position. Do NOT set x/y on a new device: Drawbridge places what you add below the existing drawing, which is the whole point of using this rather than editing the XML. Say what a new device belongs UNDER with near, naming a device already in the drawing: it lands straight below that one, in free space, so use it on every device you are about to cable to something. Put cables in an aggregate with bundle on add_edge or update_edge — its name, "ae1": cables given one name share one ring, and a ring of that name already drawn is joined. A cable already in another ring is added to this one; to move it, send bundle "" first and then the new name, in the same call. Set kind on every device you add or it draws as a plain box, and read the notes in the result — a mistyped id skips that one op and says so rather than failing the batch. The result names the ids it minted, in op order. Every id in an op must already exist when you send it — an op cannot name something an earlier op in the same call created, so adding a device and cabling it is two calls: add it, read the ids, then wire them. It writes nothing: save the returned document yourself, as it is — a cable or a position you write into the XML by hand skips the routing and the checks this tool makes. Results carry name: a suggested basename for this diagram. Write every file for one diagram into its own directory named after it — /.drawio, /.svg, /.cables.csv — so two diagrams never share a directory.
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": {
"document": "<document>",
"ops": "<ops>"
},
"name": "edit_diagram"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ops | Yes | The changes to apply, in order. Send a whole thought at a time rather than an op per call. | |
| kind | No | Output format for the edited document. Defaults to drawio, which is what you want: it is the file the user keeps working on. | |
| name | No | Basename to use for this diagram instead of the one derived from its content. Slugified; wins over the document’s own name. | |
| theme | No | Render theme. Omit to follow the OS appearance; pin it for machine-independent output. | |
| document | Yes | The .drawio document as XML text. |