n8n Comprehensive
AutomationComplete guide to n8n workflow automation covering core concepts, advanced AI with LangChain, code/expressions, integrations, API management, and embedding.
Available MCP Tools
Workflow Management
n8n_create_workflow- Create new workflows programmaticallyn8n_get_workflow- Retrieve workflow details and configurationn8n_update_partial_workflow- Update workflows incrementallyn8n_update_full_workflow- Replace entire workflow configurationn8n_delete_workflow- Remove workflowsn8n_list_workflows- List all workflows with metadatan8n_validate_workflow- Validate workflow structuren8n_autofix_workflow- Automatically fix common workflow errors
Node Discovery
search_nodes- Find available node types by keywordget_node- Get detailed node configuration and parameters
Execution & Testing
n8n_test_workflow- Test/trigger workflow executionn8n_executions- Manage workflow executions (get, list, delete)
Templates & Deployment
search_templates- Search n8n template libraryget_template- Get template detailsn8n_deploy_template- Deploy templates directly to n8n instance
When to Use
- Building n8n workflows from scratch
- Implementing AI agents and chatbots with LangChain nodes
- Writing Code nodes for data transformation
- Integrating services and APIs into workflows
- Debugging workflow execution errors
- Using n8n API for programmatic control
- Working with vector stores and RAG implementations
Decision Trees
Data Transformation
- Simple field mapping → Expressions
- Complex logic → Code node
- Multiple transformations → Set node + Code node combo
- Batch processing → Loop + Code node
AI Implementation
- Simple text generation → Basic LLM Chain
- Question answering → Retrieval QA Chain
- Conversational AI → AI Agent + Memory
- Multi-step reasoning → ReAct Agent
- Database queries → SQL Agent
Integration Method
- Built-in node exists → Use built-in node
- Community node available → Install community node
- No node available → HTTP Request node
- Need custom logic → HTTP Request + Code node
Common Workflow Patterns
Pattern 1: Webhook to Database
Webhook Trigger → Validate Data (Code) → Transform (Set) → Insert to DB → Return Response
Pattern 2: Scheduled Data Sync
Schedule Trigger → Get Data from Source → Transform → Upsert to Destination → Log Results
Pattern 3: AI Document Processing
Trigger → Load Document → Extract Text → Chunk → Embed → Store in Vector DB
Pattern 4: Multi-Service Orchestration
Trigger → [Service A, B, C in parallel] → Merge Results → Transform → Output
Quick Reference: Expression Syntax
// Current item
{{ $json.fieldName }}
{{ $json.nested.property }}
{{ $json.array[0] }}
// Other nodes
{{ $('Node Name').item.json.field }}
// Dates
{{ $now }}
{{ $today.format('YYYY-MM-DD') }}
// Transformations
{{ $json.text.toUpperCase() }}
{{ $json.items.map(i => i.name) }}
{{ $json.price * 1.1 }}
Quick Reference: Code Node
// Basic structure
const items = $input.all();
return items.map(item => ({
json: {
// transformed data
}
}));
// Access other nodes
const data = $('Previous Node').all();
// Binary preservation
return [{
json: { processed: true },
binary: item.binary
}];
Best Practices
- Workflow Design: Start simple, iterate to complex; use meaningful node names
- Code & Expressions: Prefer expressions for simple tasks; always return proper format
- AI Implementation: Choose appropriate model for task; use structured output parsers
- Integrations: Validate credentials first; handle rate limits gracefully
- Performance: Use batch processing; filter data early; monitor execution times