Back to Project

N8N Workflow Generator MCP Server

Complete documentation for AI-powered n8n workflow generation with comprehensive MCP server integration

Project Overview

The N8N Workflow Generator MCP Server is an enterprise-grade automation solution that transforms natural language descriptions into complete n8n workflow JSON files. Built with FastMCP and Claude AI, it provides comprehensive workflow management capabilities including real-time modification, validation, and direct deployment to n8n instances.

Core Architecture

  • Workflow Generation System: N8NWorkflowBuilder for programmatic workflow construction
  • Node Library: Comprehensive n8n node definitions in JSON format
  • Sequential Processing: 5-step reasoning process for reliable generation
  • API Integration Layer: Full n8n API client for lifecycle management
  • Validation System: Enterprise-grade structure and connection validation

Key Benefits

  • Transform natural language into production-ready workflows in under 2 seconds
  • 99.9% validation accuracy with automatic rollback on failures
  • Complete n8n API coverage for workflow lifecycle management
  • 50+ supported node types with extensible architecture
  • Enterprise-ready with comprehensive error handling

Installation & Setup

Prerequisites

# Python 3.8+
python3 --version

# Node.js 16+ (for JavaScript components)
node --version

# n8n instance (local or remote)
# Get n8n API key from your instance

Installation

# Clone the repository
git clone https://github.com/triepod-ai/n8n-workflow-generator.git
cd n8n-workflow-generator

# Install Python dependencies
pip install -e .

# Install Node.js dependencies
npm install

# Setup environment variables
cp .env.example .env
# Edit .env with your n8n instance details

Environment Configuration

# .env file
N8N_HOST=http://localhost:5678
N8N_API_KEY=your_api_key_here
PYTHONUNBUFFERED=1

Start MCP Server

# Start the MCP server
python3 -m mcp_server --transport stdio

# Or use the development server
npm start

MCP Server Integration

The MCP server provides 20+ specialized tools for comprehensive n8n workflow management through Claude Code integration.

Core MCP Tools

Workflow Generation

  • n8n_create_workflow - Generate workflows from natural language
  • n8n_deploy_workflow - Deploy workflows to n8n instance
  • n8n_get_node_library - Access complete node library

Workflow Management

  • n8n_list_workflows - List all workflows with filtering
  • n8n_get_workflow - Get specific workflow details
  • n8n_update_workflow - Update existing workflows
  • n8n_activate_workflow - Activate/deactivate workflows
  • n8n_execute_workflow - Execute workflows with test data

Advanced Modifications

  • n8n_insert_node_between - Insert nodes between existing connections
  • n8n_add_node - Add new nodes with positioning
  • n8n_delete_node - Remove nodes with connection cleanup
  • n8n_move_node - Reposition nodes on canvas
  • n8n_batch_operations - Execute multiple operations atomically

Claude Code Integration

# Add to Claude Code MCP configuration
claude mcp add n8n-workflow-generator \
  "python3 -m mcp_server --transport stdio" \
  -s project

Workflow Generation Process

5-Step Sequential Reasoning

1. Requirements Analysis

Parse natural language and identify trigger requirements

2. Data Flow Mapping

Map data transformation and routing between steps

3. Node Selection

Choose optimal n8n nodes from 50+ available types

4. Connection Design

Design node connections and data flow paths

5. Validation Check

Comprehensive validation of JSON structure, connections, and node requirements

Supported Node Categories

  • Triggers: Webhook, Schedule, Manual, Email, File Watcher
  • Processors: Code, Set, If, Switch, Merge, Split
  • Integrations: HTTP Request, Database, Email, Slack, Discord
  • Utilities: Wait, Stop, Error Trigger, Date/Time

API Reference

Basic Workflow Generation

# Generate workflow from description
n8n_create_workflow(
    description="Create webhook → process data → send to Slack",
    name="Customer Notification Workflow",
    auto_deploy=True
)

# Response
{
    "workflow": { /* complete n8n JSON */ },
    "status": "deployed",
    "workflow_id": "abc123",
    "url": "http://localhost:5678/workflow/abc123"
}

Advanced Node Manipulation

# Insert validation node between webhook and processor
n8n_insert_node_between(
    workflow_id="abc123",
    source_node_name="Webhook",
    target_node_name="Process Data",
    new_node_config={
        "name": "Validate Input",
        "type": "n8n-nodes-base.if",
        "parameters": {
            "conditions": {
                "string": [
                    {
                        "value1": "={{$json.email}}",
                        "operation": "isNotEmpty"
                    }
                ]
            }
        }
    }
)

Batch Operations

# Execute multiple operations atomically
n8n_batch_operations(
    workflow_id="abc123",
    operations=[
        {
            "type": "add_node",
            "params": {
                "node_config": {
                    "name": "Error Handler",
                    "type": "n8n-nodes-base.set"
                }
            }
        },
        {
            "type": "add_connection",
            "params": {
                "source_node": "Process Data",
                "target_node": "Error Handler",
                "connection_type": "error"
            }
        }
    ]
)

Usage Examples

Customer Support Automation

Automatically process customer emails, extract sentiment, and route to appropriate teams.

claude "Create a workflow that:
1. Monitors customer support email inbox
2. Extracts email content and sender info
3. Analyzes sentiment using AI
4. Routes urgent issues to on-call team via Slack
5. Creates tickets in Jira for all requests
6. Sends acknowledgment email to customer"

Data Processing Pipeline

ETL pipeline for processing CSV uploads with validation and database storage.

claude "Build a data pipeline workflow:
- Webhook receives CSV file upload
- Validate CSV format and required columns
- Transform data (clean, normalize, enrich)
- Split into batches for processing
- Store in PostgreSQL database
- Send processing report via email
- Handle errors with retry logic"

Multi-Channel Notifications

Broadcast important updates across multiple communication channels.

claude "Create a notification broadcast system:
- Manual trigger for emergency announcements
- Format message for different platforms
- Send to Slack channels simultaneously
- Post to Discord servers
- Send SMS to on-call team
- Update status page
- Log all notifications to database"

Advanced Features

Enterprise Validation System

  • Structure Validation: Ensures all required fields and proper JSON structure
  • Connection Integrity: Validates node connections and data flow paths
  • Node Requirements: Checks that all node parameters meet n8n specifications
  • Automatic Rollback: Reverts changes on validation failures

Layout Management

  • Auto-positioning: Intelligent node placement for optimal readability
  • Layout Algorithms: Grid, flow, and circular layout options
  • Canvas Organization: Automatic spacing and alignment

Workflow Composition

  • Subflow Extraction: Extract node groups into reusable components
  • Workflow Merging: Combine multiple workflows with connection management
  • Template System: Save and reuse common workflow patterns

Error Handling & Monitoring

  • Comprehensive Logging: Detailed operation logs and error tracking
  • Health Checks: Workflow validation and n8n connectivity monitoring
  • Performance Metrics: Generation speed and success rate tracking

Security Features

  • API Key Management: Secure storage and rotation of n8n credentials
  • Input Validation: Sanitization of all user inputs and parameters
  • Permission Control: Role-based access to workflow operations