# Release v1.9.1: Add create_workflow Tool
**Release Date:** 2025-12-16
## š Critical Missing Feature
### Added `create_workflow` MCP Tool
**Problem:**
The system had NO way to create new workflows! There were tools to:
- ā Generate templates (`generate_workflow_template`)
- ā Update existing workflows (`update_workflow`)
- ā Execute workflows (`execute_workflow`)
But **no tool to actually CREATE a workflow** from scratch. This is obviously essential functionality.
**Solution:**
Added `create_workflow` tool as the primary method for building new workflows.
## ⨠New Tool
### `create_workflow`
Create a new workflow in n8n with nodes and connections.
**Parameters:**
- `name` (required): Workflow name
- `nodes` (required): Array of workflow nodes with type, name, parameters, position
- `connections` (required): Workflow connections between nodes
- `settings` (optional): Workflow settings
- `active` (optional): Whether to activate immediately (default: false)
**Returns:**
- Workflow ID
- Activation status
- Node count
- Connection count
- Suggested next steps
**Example:**
```python
create_workflow(
name="Customer Sync",
nodes=[
{
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [250, 300],
"parameters": {
"path": "customer-sync",
"responseMode": "onReceived"
}
},
{
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"position": [450, 300],
"parameters": {
"url": "https://api.example.com/customers",
"method": "POST"
}
}
],
connections={
"Webhook": {
"main": [[{"node": "HTTP Request", "type": "main", "index": 0}]]
}
},
active=False
)
```
**Response:**
```markdown
# ā
Workflow Created: Customer Sync
**ID**: `abc123`
**Status**: āŖ Inactive
**Nodes**: 2
**Connections**: 1 source nodes
## Nodes:
- **Webhook** (`n8n-nodes-base.webhook`)
- **HTTP Request** (`n8n-nodes-base.httpRequest`)
---
š” **Next Steps**:
- Execute with: `execute_workflow(workflow_id="abc123")`
- Monitor with: `watch_workflow_execution(workflow_id="abc123")`
- Activate with: `update_workflow(workflow_id="abc123", active=true)`
```
## šÆ Features
### Automatic State Management
- Created workflow is set as current workflow in state
- Action logged for session history
- Workflow ID stored for quick access
### Helpful Next Steps
- Suggests how to execute the new workflow
- Shows monitoring command for feedback loop
- Reminds how to activate if created inactive
### Integration with Existing Tools
- Works seamlessly with `watch_workflow_execution` (v1.9.0)
- Compatible with `add_node_intent` for documentation
- Can be validated with `validate_workflow`
## š Complete Workflow Creation Flow
```python
# 1. Create workflow
workflow = create_workflow(
name="Data Sync",
nodes=[...],
connections={...}
)
# Returns: workflow_id="xyz"
# 2. Add intent metadata (v1.8.0)
add_node_intent(
workflow_id="xyz",
node_name="HTTP Request",
reason="Fetch data from API",
assumption="API returns JSON"
)
# 3. Validate before execution (v1.2.0)
validate_workflow(workflow_id="xyz")
# 4. Execute (existing)
execute_workflow(workflow_id="xyz")
# 5. Monitor execution (v1.9.0)
watch_workflow_execution(workflow_id="xyz")
# 6. If error, get context (v1.9.0)
get_execution_error_context(
execution_id="...",
workflow_id="xyz"
)
```
## š§ Technical Details
### Workflow Data Structure
The tool accepts standard n8n workflow format:
```python
{
"name": "Workflow Name",
"nodes": [
{
"name": "Node Name",
"type": "n8n-nodes-base.nodeType",
"position": [x, y],
"parameters": {
# Node-specific parameters
},
"credentials": {
# Optional credentials
}
}
],
"connections": {
"SourceNode": {
"main": [
[
{
"node": "TargetNode",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"active": false
}
```
### n8n API Integration
Uses the existing `N8nClient.create_workflow()` method:
```python
response = await client.post(
f"{api_url}/api/v1/workflows",
json=workflow_data
)
```
## š Use Cases
### 1. Build Workflow from Scratch
```python
workflow = create_workflow(
name="Email Automation",
nodes=[...],
connections={...}
)
```
### 2. Template-Based Creation
```python
# Get template
template = generate_workflow_template(
description="Sync Notion to Airtable"
)
# Create from template
workflow = create_workflow(
name="Notion ā Airtable Sync",
nodes=template["nodes"],
connections=template["connections"]
)
```
### 3. Programmatic Workflow Generation
```python
# Generate nodes dynamically
nodes = []
for i, endpoint in enumerate(api_endpoints):
nodes.append({
"name": f"API_{i}",
"type": "n8n-nodes-base.httpRequest",
"position": [250 + (i * 200), 300],
"parameters": {"url": endpoint}
})
# Create workflow
workflow = create_workflow(
name="Multi-API Workflow",
nodes=nodes,
connections=generate_connections(nodes)
)
```
## š Why This Was Missing
The original implementation had:
- `generate_workflow_template` - But only creates a plan/outline, not actual workflow
- `update_workflow` - But can only modify existing workflows
- `suggest_workflow_nodes` - But only suggests nodes, doesn't create
Without `create_workflow`, the only way to create workflows was:
1. Manually create in n8n UI
2. Then use MCP tools to modify it
This made the system incomplete for autonomous operation.
## ā
Impact
### Before v1.9.1:
```
LLM: "I'll create a workflow for you"
LLM: *generates template*
LLM: "Here's the plan, but you need to create it manually in n8n"
User: *creates workflow in UI*
LLM: "Now I can help you modify it"
```
### After v1.9.1:
```
LLM: "I'll create a workflow for you"
LLM: *calls create_workflow*
System: "ā
Workflow created with ID abc123"
LLM: "Done! Testing it now..."
LLM: *calls execute_workflow*
```
## š Benefits
ā
**Complete Workflow Creation** - No manual steps required
ā
**Autonomous Operation** - LLM can build workflows end-to-end
ā
**Seamless Integration** - Works with all existing tools
ā
**State Management** - Auto-tracked in session
ā
**Guided Next Steps** - Shows what to do after creation
## š Files Changed
### Modified Files
- `src/n8n_workflow_builder/server.py` (+83 lines)
- Added `create_workflow` tool definition
- Added `create_workflow` handler implementation
## š¦ Dependencies
No new dependencies. Uses existing `N8nClient.create_workflow()` method.
## š Getting Started
```python
# Simple workflow creation
workflow = create_workflow(
name="Hello World",
nodes=[
{
"name": "Start",
"type": "n8n-nodes-base.manualTrigger",
"position": [250, 300],
"parameters": {}
}
],
connections={}
)
```
---
**Full Changelog**: v1.9.0...v1.9.1