comfyui_modify_workflow
Apply batch modifications to a ComfyUI workflow: add or remove nodes, set inputs, and connect or disconnect outputs. Operations run sequentially and atomically.
Instructions
Apply batch operations to a ComfyUI workflow.
Operations execute sequentially in array order. If any operation fails,
the call raises ``ValueError`` and the input workflow is left
unmodified (atomic — operations are applied to a deep copy).
Args:
workflow (required): JSON string of the workflow to modify.
operations (required): JSON string of an array of operation objects.
Operation reference:
- ``add_node`` — append a new node. Fields:
``{"op": "add_node", "class_type": "<NodeType>",
"node_id": "<id>" (optional, auto-assigned if omitted),
"inputs": {...} (optional default inputs)}``
- ``remove_node`` — drop a node. Fields:
``{"op": "remove_node", "node_id": "<id>"}``
- ``set_input`` — set or replace a single input value. Fields:
``{"op": "set_input", "node_id": "<id>",
"input_name": "<key>", "value": <any>}``
- ``connect`` — wire one node's output into another's input. Fields:
``{"op": "connect", "from_node": "<id>", "from_output": <int>,
"to_node": "<id>", "to_input": "<key>"}``
- ``disconnect`` — clear an existing input connection. Fields:
``{"op": "disconnect", "node_id": "<id>", "input_name": "<key>"}``
Example:
``operations='[{"op": "set_input", "node_id": "3",
"input_name": "steps", "value": 50},
{"op": "add_node", "class_type": "LoraLoader"}]'``
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow | Yes | ||
| operations | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||