n8n Workflows
AutomationCreate and troubleshoot n8n workflows with support for LangChain AI integrations, data transformations, and email processing.
Available MCP Tools
n8n_create_workflow- Create new workflowsn8n_get_workflow- Retrieve workflow detailsn8n_update_partial_workflow- Update workflows (may have API issues)n8n_validate_workflow- Validate workflow structuresearch_nodes- Find available node typesget_node- Get node configuration details
Basic Workflow Structure
Every workflow consists of:
- Nodes array - Defines each node's type, parameters, position
- Connections object - Maps data flow between nodes
- Settings - Execution order and workflow settings
Common Workflow Pattern
Trigger → Transform Data → AI Analysis → Store Results → Send Output
Example: Email Processing
Email IMAP Trigger
→ Extract Email Data (Set node)
→ Basic LLM Chain (with Anthropic + Parser)
→ Parse Results (Code node)
→ Insert into Supabase
→ Prepare Reply (Set node)
→ Send Email
Key Data Structure Requirements
Code Node Returns
Critical: Always return an array of objects with json keys:
return [{
json: {
field1: "value",
field2: 123
},
binary: item.binary // If preserving attachments
}];
Accessing Other Nodes
const data = $('Node Name').first().json;
LangChain Integration
Basic LLM Chain + Anthropic Pattern
Three nodes required:
- Basic LLM Chain - Main orchestrator
- Anthropic Chat Model - Connected via
ai_languageModel - Structured Output Parser - Connected via
ai_outputParser
Output Parser Configuration
{
"parameters": {
"jsonSchemaExample": "{\"sentiment\": \"positive\", \"category\": \"inquiry\"}"
}
}
Email Attachment Handling
Email attachments are in the binary property:
const binaryData = item.binary || {};
const attachments = [];
for (const [key, value] of Object.entries(binaryData)) {
if (value && value.fileName) {
attachments.push({
fileName: value.fileName,
mimeType: value.mimeType,
fileSize: value.fileSize
});
}
}
Troubleshooting
When workflows fail validation or execution:
- Use validation tool first:
n8n_validate_workflow({id: "workflow-id"}) - Check common issues:
- Code nodes returning wrong format
- Missing required parameters
- Undefined variables in Code nodes
- Broken connections between nodes
Key Learnings
- Always validate workflows before debugging:
n8n_validate_workflow - Code nodes must access data via
$input.all()or$('Node Name') - LangChain output parsers simplify JSON extraction from Claude
- Binary data must be explicitly preserved through transformations
- Use
autoMapInputDatafor Supabase to auto-map JSON fields to columns