Building flows with MCP
With the MCP you can create complete flows programmatically: create the flow, add nodes, connect them, configure them, and activate them in production.
Steps
- 1Create the flow: create_flow({name: 'My flow'}).
- 2Add the trigger: add_node({flow_id, tool_id: TRIGGER_ID, ...}).
- 3Add action nodes: add_node(...) for each flow step.
- 4Connect the nodes: connect_nodes({flow_id, source_node_id, target_node_id}).
- 5Configure each node: configure_node({node_id, config: {...}}).
- 6Validate the flow: validate_flow({flow_id}) — detects errors before activating.
- 7Activate in production: set_production_mode({flow_id, enabled: true}).
- 8Execute to test: execute_flow({flow_id, payload: {...}}) with a sample payload.
Reference
- IDs change on write
- Node IDs are reassigned on each write operation. Use get_flow to get current IDs before an operation.
- Auto layout
- Call layout_flow({flow_id}) after adding all nodes to organize the canvas.
- execute_flow
- Requires a real or sample payload matching what the trigger would receive. Use get_node_sample to get an example payload.
- Validation
- validate_flow detects orphan nodes, missing configurations, and connection errors.
Common errors
- Node not found after add_node
- IDs are reassigned. Call get_flow to get the current ID of the newly created node.
- execute_flow stays in «Waiting»
- Almost always means the phone number is wired to the webhook of the wrong environment (dev vs prod). Verify the channel points to the correct environment.
Next step
Learn to use the KV Store from the MCP.