Skip to main content
Glama
AutomateLab-tech

automatelab-n8n-mcp

n8n_generate_workflow

Generate n8n workflow JSON from plain-English descriptions, supporting triggers, common action nodes, and AI agent setups.

Instructions

Generate a valid n8n workflow JSON from a plain-English description. Handles webhook/schedule/RSS triggers, common action nodes (Slack, Google Sheets, Discord, Gmail, Notion, HTTP), and AI Agent setups (LangChain root agent + chat model + memory + optional HTTP tool, wired with ai_languageModel / ai_memory / ai_tool connections). Returns workflow JSON with unique node IDs, connections, positions, and typeVersion on every node.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesPlain-English workflow description, e.g. 'Stripe webhook -> Slack message + Google Sheets row'.
nameNoOptional workflow name. Derived from the first sentence of the description if omitted.

Implementation Reference

  • Main handler function for n8n_generate_workflow. Parses input, detects triggers/actions via regex patterns, builds workflow JSON, and returns it.
    export async function generateWorkflow(rawArgs: unknown) {
    	const args = inputZod.parse(rawArgs);
    
    	if (AI_AGENT_PATTERN.test(args.description)) {
    		return buildAiAgentWorkflow(args);
    	}
    
    	let trigger: NodeSpec | null = null;
    	for (const p of TRIGGER_PATTERNS) {
    		if (p.match.test(args.description)) {
    			trigger = p.build();
    			break;
    		}
    	}
    	if (!trigger) {
    		trigger = {
    			id: randomUUID(),
    			name: "Manual Trigger",
    			type: "n8n-nodes-base.manualTrigger",
    			typeVersion: 1,
    			position: [240, 300],
    			parameters: {},
    		};
    	}
    
    	const actions: NodeSpec[] = [];
    	let slot = 0;
    	for (const p of ACTION_PATTERNS) {
    		if (p.match.test(args.description)) {
    			actions.push(p.build(slot++));
    		}
    	}
    	if (actions.length === 0) {
    		actions.push({
    			id: randomUUID(),
    			name: "HTTP Request",
    			type: "n8n-nodes-base.httpRequest",
    			typeVersion: 4.2,
    			position: [560, 300],
    			parameters: {
    				method: "POST",
    				url: "https://example.com/api",
    				sendBody: true,
    				bodyParameters: { parameters: [] },
    				options: {},
    			},
    		});
    	}
    
    	const nodes = [trigger, ...actions];
    
    	const connections: Record<string, { main: MainConnection[][] }> = {
    		[trigger.name]: {
    			main: [
    				actions.map((a) => ({ node: a.name, type: "main" as const, index: 0 })),
    			],
    		},
    	};
    
    	const workflow = {
    		name: args.name ?? deriveName(args.description),
    		nodes,
    		connections,
    		active: false,
    		settings: { executionOrder: "v1" },
    		pinData: {},
    	};
    
    	return {
    		content: [
    			{ type: "text" as const, text: JSON.stringify(workflow, null, 2) },
    		],
    	};
    }
  • Helper that builds an AI Agent workflow (chat trigger + agent + chat model + memory + optional HTTP tool) when the description mentions AI/LLM/chatbot.
    function buildAiAgentWorkflow(args: { description: string; name?: string }) {
    	const trigger: NodeSpec = {
    		id: randomUUID(),
    		name: "When chat message received",
    		type: "@n8n/n8n-nodes-langchain.chatTrigger",
    		typeVersion: 1.1,
    		position: [240, 300],
    		parameters: { options: {} },
    	};
    
    	const agent: NodeSpec = {
    		id: randomUUID(),
    		name: "AI Agent",
    		type: "@n8n/n8n-nodes-langchain.agent",
    		typeVersion: 1.7,
    		position: [480, 300],
    		parameters: { options: {} },
    	};
    
    	const chatModel: NodeSpec = {
    		id: randomUUID(),
    		name: "OpenAI Chat Model",
    		type: "@n8n/n8n-nodes-langchain.lmChatOpenAi",
    		typeVersion: 1.2,
    		position: [400, 480],
    		parameters: {
    			model: { __rl: true, mode: "list", value: "gpt-4o-mini" },
    			options: {},
    		},
    	};
    
    	const memory: NodeSpec = {
    		id: randomUUID(),
    		name: "Window Buffer Memory",
    		type: "@n8n/n8n-nodes-langchain.memoryBufferWindow",
    		typeVersion: 1.3,
    		position: [560, 480],
    		parameters: {},
    	};
    
    	const nodes: NodeSpec[] = [trigger, agent, chatModel, memory];
    
    	const connections: Record<string, Record<string, WireConnection[][]>> = {
    		[trigger.name]: {
    			main: [[{ node: agent.name, type: "main", index: 0 }]],
    		},
    		[chatModel.name]: {
    			ai_languageModel: [
    				[{ node: agent.name, type: "ai_languageModel", index: 0 }],
    			],
    		},
    		[memory.name]: {
    			ai_memory: [[{ node: agent.name, type: "ai_memory", index: 0 }]],
    		},
    	};
    
    	if (/\b(http|api|tool|fetch)\b/i.test(args.description)) {
    		const httpTool: NodeSpec = {
    			id: randomUUID(),
    			name: "HTTP Request Tool",
    			type: "@n8n/n8n-nodes-langchain.toolHttpRequest",
    			typeVersion: 1.1,
    			position: [720, 480],
    			parameters: {
    				toolDescription:
    					"Call an external HTTP API. Replace the URL and parameters before running.",
    				url: "https://example.com/api",
    				method: "GET",
    				sendBody: false,
    			},
    		};
    		nodes.push(httpTool);
    		connections[httpTool.name] = {
    			ai_tool: [[{ node: agent.name, type: "ai_tool", index: 0 }]],
    		};
    	}
    
    	const workflow = {
    		name: args.name ?? deriveName(args.description),
    		nodes,
    		connections,
    		active: false,
    		settings: { executionOrder: "v1" },
    		pinData: {},
    	};
    
    	return {
    		content: [
    			{ type: "text" as const, text: JSON.stringify(workflow, null, 2) },
    		],
    	};
    }
  • Input schema for n8n_generate_workflow: requires 'description' (string) and optional 'name' (string).
    export const generateWorkflowInputSchema = {
    	type: "object",
    	properties: {
    		description: {
    			type: "string",
    			description:
    				"Plain-English workflow description, e.g. 'Stripe webhook -> Slack message + Google Sheets row'.",
    		},
    		name: {
    			type: "string",
    			description:
    				"Optional workflow name. Derived from the first sentence of the description if omitted.",
    		},
    	},
    	required: ["description"],
    } as const;
  • src/index.ts:46-51 (registration)
    Registration of the tool with name 'n8n_generate_workflow', description, and input schema.
    {
    	name: "n8n_generate_workflow",
    	description:
    		"Generate a valid n8n workflow JSON from a plain-English description. Handles webhook/schedule/RSS triggers, common action nodes (Slack, Google Sheets, Discord, Gmail, Notion, HTTP), and AI Agent setups (LangChain root agent + chat model + memory + optional HTTP tool, wired with ai_languageModel / ai_memory / ai_tool connections). Returns workflow JSON with unique node IDs, connections, positions, and typeVersion on every node.",
    	inputSchema: generateWorkflowInputSchema,
    },
  • src/index.ts:113-114 (registration)
    Handler dispatch: routes the 'n8n_generate_workflow' tool call to the generateWorkflow function.
    case "n8n_generate_workflow":
    	return generateWorkflow(args ?? {});
Behavior5/5

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

With no annotations, the description fully bears the burden of transparency. It details the output structure (unique IDs, connections, positions, typeVersion) and supported node types, leaving no ambiguity about behavior.

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: first states core purpose, second details capabilities. Efficient and front-loaded with no extraneous information.

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 simple generation tool with 2 parameters and no output schema, the description covers inputs, outputs, and supported features. Minor gap: no mention of prerequisites like internet access or API keys.

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

Parameters4/5

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

Schema coverage is 100%, and the description adds value by explaining how 'name' defaults and what kind of plain-English text 'description' expects (e.g., trigger -> action pairs).

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 tool's purpose: generating n8n workflow JSON from plain English. It lists specific supported triggers and nodes, distinguishing it from siblings like n8n_create_workflow which likely creates via API.

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

Usage Guidelines3/5

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

The description implies when to use (for generating workflow JSON from descriptions) but does not explicitly contrast with siblings or specify when not to use it.

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/AutomateLab-tech/n8n-mcp'

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