Skip to main content
Glama
spences10

mcp-n8n-builder

create_workflow

Build and activate custom n8n workflows programmatically by defining nodes, connections, and settings. Supports automatic triggers for immediate workflow execution.

Instructions

Creates a new workflow in n8n with specified nodes and connections. Note that only workflows with automatic trigger nodes (schedule, webhook, etc.) can be activated - workflows with only manual triggers cannot be activated. Returns the created workflow with its assigned ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activateNoWhether to activate the workflow after creation (only works for workflows with automatic triggers)
workflowYesComplete workflow structure including nodes, connections, and settings

Implementation Reference

  • The main handler function that executes the create_workflow tool: validates input schema, checks for valid n8n nodes, creates the workflow via API client, optionally activates it, and returns success/error messages.
    export async function handle_create_workflow(
    	api_client: N8nApiClient,
    	args: any,
    ) {
    	try {
    		// Validate input with Zod
    		const parsed_input = CreateWorkflowInputSchema.parse(args);
    
    		// Validate that all nodes exist in n8n
    		const invalid_nodes =
    			await node_validator.validate_workflow_nodes(
    				parsed_input.workflow.nodes,
    			);
    
    		if (invalid_nodes.length > 0) {
    			// Format error message with suggestions
    			const error_messages = invalid_nodes.map((node) => {
    				const suggestion = node.suggestion
    					? `Did you mean '${node.suggestion}'?`
    					: 'No similar nodes found.';
    				return `- '${node.node_type}': Not a valid n8n node. ${suggestion}`;
    			});
    
    			// Include relevant sections from the workflow composition guide
    			const node_categories =
    				WORKFLOW_COMPOSITION_GUIDE.node_categories;
    
    			return {
    				content: [
    					{
    						type: 'text',
    						text:
    							`Workflow contains invalid node types:\n${error_messages.join(
    								'\n',
    							)}\n\nPlease correct these node types before creating the workflow.\n\n` +
    							`Here are the available node categories for reference:\n${node_categories}`,
    					},
    				],
    				isError: true,
    			};
    		}
    
    		const workflow = await api_client.create_workflow(
    			parsed_input.workflow,
    			parsed_input.activate,
    		);
    
    		const activation_status = workflow.active
    			? 'activated'
    			: 'created (not activated)';
    
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `Successfully ${activation_status} workflow "${workflow.name}" (ID: ${workflow.id})`,
    				},
    			],
    		};
    	} catch (error: any) {
    		if (error.name === 'ZodError') {
    			return handle_validation_error(error);
    		}
    		return {
    			content: [
    				{
    					type: 'text',
    					text: `Error creating workflow: ${
    						error.message || String(error)
    					}`,
    				},
    			],
    			isError: true,
    		};
    	}
    }
  • Zod schema defining the input structure for the create_workflow tool, including the workflow object and optional activate flag.
    export const CreateWorkflowInputSchema = z.object({
    	workflow: WorkflowSchema,
    	activate: z.boolean().optional(),
    });
  • Tool registration in the list of tools returned by ListToolsRequestSchema, defining name, description, and inputSchema for create_workflow.
    {
    	name: 'create_workflow',
    	description:
    		'Creates a new workflow in n8n with specified nodes and connections. Note that only workflows with automatic trigger nodes (schedule, webhook, etc.) can be activated - workflows with only manual triggers cannot be activated. Returns the created workflow with its assigned ID.',
    	inputSchema: {
    		type: 'object',
    		properties: {
    			workflow: {
    				type: 'object',
    				description:
    					'Complete workflow structure including nodes, connections, and settings',
    				properties: {
    					name: {
    						type: 'string',
    						description:
    							'Name of the workflow - use descriptive names for easier identification',
    					},
    					nodes: {
    						type: 'array',
    						description:
    							'Array of workflow nodes (triggers, actions, etc.)',
    						items: {
    							type: 'object',
    						},
    					},
    					connections: {
    						type: 'object',
    						description:
    							'Connections between nodes defining the workflow execution path',
    					},
    					settings: {
    						type: 'object',
    						description:
    							'Workflow settings like error handling, execution timeout, etc.',
    					},
    				},
    				required: ['name', 'nodes', 'connections'],
    			},
    			activate: {
    				type: 'boolean',
    				description:
    					'Whether to activate the workflow after creation (only works for workflows with automatic triggers)',
    			},
    		},
    		required: ['workflow'],
    	},
    },
  • Dispatch in the CallToolRequestSchema switch statement that routes create_workflow calls to the handle_create_workflow function.
    case 'create_workflow':
    	return await handle_create_workflow(api_client, args);
  • API client method that performs the actual HTTP POST to create the workflow in n8n and optionally activates it.
    async create_workflow(
    	workflow: any,
    	activate?: boolean,
    ): Promise<any> {
    	const response = await this.request<any>(
    		'POST',
    		'/workflows',
    		workflow,
    	);
    
    	if (activate && response.id) {
    		await this.activate_workflow(response.id);
    		response.active = true;
    	}
    
    	return response;
    }
Behavior4/5

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

With no annotations, the description carries full burden and discloses key behavioral traits: it explains activation constraints (automatic vs. manual triggers), mentions the return value (created workflow with ID), and implies it's a write operation. It doesn't cover error handling or permissions.

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?

Two sentences with zero waste: first states purpose and key constraint, second specifies return value. It's front-loaded with essential information and appropriately sized.

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

Completeness4/5

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

For a creation tool with no annotations and no output schema, the description is fairly complete: it covers purpose, activation behavior, and return value. However, it lacks details on error cases or permissions, which could be useful given the complexity.

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 already documents both parameters thoroughly. The description adds minimal value beyond schema by mentioning 'nodes and connections' and activation note, but doesn't provide additional syntax or format details. Baseline 3 is appropriate.

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 verb 'creates' and resource 'new workflow in n8n', specifying it includes 'nodes and connections'. It distinguishes from siblings like update_workflow (modifies existing) and list_workflows (reads).

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

Usage Guidelines4/5

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

It provides clear context about when activation works (only for workflows with automatic triggers) and implies usage for creation vs. alternatives like update_workflow. However, it doesn't explicitly state when not to use it or compare with all siblings.

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

Related 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/spences10/mcp-n8n-builder'

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