Skip to main content
Glama

validate_workflow

Read-onlyIdempotent

Validate n8n workflow structure, connections, expressions, and AI tools to identify errors and warnings before deployment.

Instructions

Full workflow validation: structure, connections, expressions, AI tools. Returns errors/warnings/fixes. Essential before deploy.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflowYesThe complete workflow JSON to validate. Must include nodes array and connections object.
optionsNoOptional validation settings

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
validYes
errorsNo
summaryYes
warningsNo
suggestionsNo

Implementation Reference

  • MCP tool handler: receives tool arguments and delegates to WorkflowValidator for execution.
    async validateWorkflow(args) {
        return this.workflowValidator.validateWorkflow(args.workflow, args.options);
    }
  • Core implementation: performs structure validation, node validation, connection checks, expression validation, AI node checks, cycle detection, pattern analysis, and generates suggestions.
    async validateWorkflow(workflow, options = {}) {
        this.currentWorkflow = workflow;
        const { validateNodes = true, validateConnections = true, validateExpressions = true, profile = 'runtime' } = options;
        const result = {
            valid: true,
            errors: [],
            warnings: [],
            statistics: {
                totalNodes: 0,
                enabledNodes: 0,
                triggerNodes: 0,
                validConnections: 0,
                invalidConnections: 0,
                expressionsValidated: 0,
            },
            suggestions: []
        };
        try {
            if (!workflow) {
                result.errors.push({
                    type: 'error',
                    message: 'Invalid workflow structure: workflow is null or undefined'
                });
                result.valid = false;
                return result;
            }
            const executableNodes = Array.isArray(workflow.nodes) ? workflow.nodes.filter(n => !(0, node_classification_1.isNonExecutableNode)(n.type)) : [];
            result.statistics.totalNodes = executableNodes.length;
            result.statistics.enabledNodes = executableNodes.filter(n => !n.disabled).length;
            this.validateWorkflowStructure(workflow, result);
            if (workflow.nodes && Array.isArray(workflow.nodes) && workflow.connections && typeof workflow.connections === 'object') {
                if (validateNodes && workflow.nodes.length > 0) {
                    await this.validateAllNodes(workflow, result, profile);
                }
                if (validateConnections) {
                    this.validateConnections(workflow, result, profile);
                }
                if (validateExpressions && workflow.nodes.length > 0) {
                    this.validateExpressions(workflow, result, profile);
                }
                if (workflow.nodes.length > 0) {
                    this.checkWorkflowPatterns(workflow, result, profile);
                }
                if (workflow.nodes.length > 0 && (0, ai_node_validator_1.hasAINodes)(workflow)) {
                    const aiIssues = (0, ai_node_validator_1.validateAISpecificNodes)(workflow);
                    for (const issue of aiIssues) {
                        const validationIssue = {
                            type: issue.severity === 'error' ? 'error' : 'warning',
                            nodeId: issue.nodeId,
                            nodeName: issue.nodeName,
                            message: issue.message,
                            details: issue.code ? { code: issue.code } : undefined
                        };
                        if (issue.severity === 'error') {
                            result.errors.push(validationIssue);
                        }
                        else {
                            result.warnings.push(validationIssue);
                        }
                    }
                }
                this.generateSuggestions(workflow, result);
                if (result.errors.length > 0) {
                    this.addErrorRecoverySuggestions(result);
                }
            }
        }
        catch (error) {
            logger.error('Error validating workflow:', error);
            result.errors.push({
                type: 'error',
                message: `Workflow validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`
            });
        }
        result.valid = result.errors.length === 0;
        return result;
    }
  • ToolDocumentation: detailed schema definition, input/output parameters, examples, performance notes, best practices, and related tools.
    export const validateWorkflowDoc: ToolDocumentation = {
      name: 'validate_workflow',
      category: 'validation',
      essentials: {
        description: 'Full workflow validation: structure, connections, expressions, AI tools. Returns errors/warnings/fixes. Essential before deploy.',
        keyParameters: ['workflow', 'options'],
        example: 'validate_workflow({workflow: {nodes: [...], connections: {...}}})',
        performance: 'Moderate (100-500ms)',
        tips: [
          'Always validate before n8n_create_workflow to catch errors early',
          'Use options.profile="minimal" for quick checks during development',
          'AI tool connections are automatically validated for proper node references',
          'Detects operator structure issues (binary vs unary, singleValue requirements)'
        ]
      },
      full: {
        description: 'Performs comprehensive validation of n8n workflows including structure, node configurations, connections, and expressions. This is a three-layer validation system that catches errors before deployment, validates complex multi-node workflows, checks all n8n expressions for syntax errors, and ensures proper node connections and data flow.',
        parameters: {
          workflow: { 
            type: 'object', 
            required: true, 
            description: 'The complete workflow JSON to validate. Must include nodes array and connections object.' 
          },
          options: { 
            type: 'object', 
            required: false, 
            description: 'Validation options object' 
          },
          'options.validateNodes': { 
            type: 'boolean', 
            required: false, 
            description: 'Validate individual node configurations. Default: true' 
          },
          'options.validateConnections': { 
            type: 'boolean', 
            required: false, 
            description: 'Validate node connections and flow. Default: true' 
          },
          'options.validateExpressions': { 
            type: 'boolean', 
            required: false, 
            description: 'Validate n8n expressions syntax and references. Default: true' 
          },
          'options.profile': { 
            type: 'string', 
            required: false, 
            description: 'Validation profile for node validation: minimal, runtime (default), ai-friendly, strict' 
          }
        },
        returns: 'Object with valid (boolean), errors (array), warnings (array), statistics (object), and suggestions (array)',
        examples: [
          'validate_workflow({workflow: myWorkflow}) - Full validation with default settings',
          'validate_workflow({workflow: myWorkflow, options: {profile: "minimal"}}) - Quick validation for editing',
          'validate_workflow({workflow: myWorkflow, options: {validateExpressions: false}}) - Skip expression validation'
        ],
        useCases: [
          'Pre-deployment validation to catch all workflow issues',
          'Quick validation during workflow development',
          'Validate workflows with AI Agent nodes and tool connections',
          'Check expression syntax before workflow execution',
          'Ensure workflow structure integrity after modifications'
        ],
        performance: 'Moderate (100-500ms). Depends on workflow size and validation options. Expression validation adds ~50-100ms.',
        bestPractices: [
          'Always validate workflows before creating or updating in n8n',
          'Use minimal profile during development, strict profile before production',
          'Pay attention to warnings - they often indicate potential runtime issues',
          'Validate after any workflow modifications, especially connection changes',
          'Check statistics to understand workflow complexity',
          '**Auto-sanitization runs during create/update**: Operator structures and missing metadata are automatically fixed when workflows are created or updated, but validation helps catch issues before they reach n8n',
          'If validation detects operator issues, they will be auto-fixed during n8n_create_workflow or n8n_update_partial_workflow'
        ],
        pitfalls: [
          'Large workflows (100+ nodes) may take longer to validate',
          'Expression validation requires proper node references to exist',
          'Some warnings may be acceptable depending on use case',
          'Validation cannot catch all runtime errors (e.g., API failures)',
          'Profile setting only affects node validation, not connection/expression checks'
        ],
        relatedTools: ['validate_node', 'n8n_create_workflow', 'n8n_update_partial_workflow', 'n8n_autofix_workflow']
      }
    };
  • Tool definition registration: inputSchema and outputSchema used by MCP server for tool registration and validation.
        {
            name: 'validate_workflow',
            description: `Full workflow validation: structure, connections, expressions, AI tools. Returns errors/warnings/fixes. Essential before deploy.`,
            inputSchema: {
                type: 'object',
                properties: {
                    workflow: {
                        type: 'object',
                        description: 'The complete workflow JSON to validate. Must include nodes array and connections object.',
                    },
                    options: {
                        type: 'object',
                        properties: {
                            validateNodes: {
                                type: 'boolean',
                                description: 'Validate individual node configurations. Default true.',
                                default: true,
                            },
                            validateConnections: {
                                type: 'boolean',
                                description: 'Validate node connections and flow. Default true.',
                                default: true,
                            },
                            validateExpressions: {
                                type: 'boolean',
                                description: 'Validate n8n expressions syntax and references. Default true.',
                                default: true,
                            },
                            profile: {
                                type: 'string',
                                enum: ['minimal', 'runtime', 'ai-friendly', 'strict'],
                                description: 'Validation profile for node validation. Default "runtime".',
                                default: 'runtime',
                            },
                        },
                        description: 'Optional validation settings',
                    },
                },
                required: ['workflow'],
                additionalProperties: false,
            },
            outputSchema: {
                type: 'object',
                properties: {
                    valid: { type: 'boolean' },
                    summary: {
                        type: 'object',
                        properties: {
                            totalNodes: { type: 'number' },
                            enabledNodes: { type: 'number' },
                            triggerNodes: { type: 'number' },
                            validConnections: { type: 'number' },
                            invalidConnections: { type: 'number' },
                            expressionsValidated: { type: 'number' },
                            errorCount: { type: 'number' },
                            warningCount: { type: 'number' }
                        }
                    },
                    errors: {
                        type: 'array',
                        items: {
                            type: 'object',
                            properties: {
                                node: { type: 'string' },
                                message: { type: 'string' },
                                details: { type: 'string' }
                            }
                        }
                    },
                    warnings: {
                        type: 'array',
                        items: {
                            type: 'object',
                            properties: {
                                node: { type: 'string' },
                                message: { type: 'string' },
                                details: { type: 'string' }
                            }
                        }
                    },
                    suggestions: { type: 'array', items: { type: 'string' } }
                },
                required: ['valid', 'summary']
            },
        },
    ];
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and idempotentHint=true, indicating safe, repeatable operations. The description adds valuable context by specifying what gets validated (structure, connections, expressions, AI tools) and the output format (errors/warnings/fixes), which goes beyond the annotations. No contradictions exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (two sentences) and front-loaded with the core purpose. Every word earns its place, with no redundant information. The structure moves from action to output to usage context efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (validation of multiple aspects), rich annotations (readOnly, idempotent), 100% schema coverage, and the presence of an output schema (implied by 'Returns errors/warnings/fixes'), the description is complete enough. It covers purpose, scope, output, and critical usage timing without needing to explain parameters or return values in detail.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (workflow and options). The description doesn't add any parameter-specific details beyond what the schema provides, such as explaining the workflow JSON structure or option interactions. Baseline 3 is appropriate given the comprehensive schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Full workflow validation') and scope ('structure, connections, expressions, AI tools'), distinguishing it from sibling tools like validate_node (which validates individual nodes) or n8n_test_workflow (which executes tests). It uses precise terminology that differentiates its comprehensive validation purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'Essential before deploy,' providing clear guidance on when to use this tool versus alternatives like n8n_deploy_template or n8n_update_full_workflow. It implies this validation should precede deployment actions, though it doesn't explicitly name all alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/czlonkowski/n8n-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server