generate
Create n8n workflows from templates with real nodes for webhooks, scheduled reports, data sync, error handling, and approval flows.
Instructions
Generate a workflow from template using REAL n8n nodes (no mock/placeholder nodes)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| config | No | Configuration options for the template | |
| name | Yes | Workflow name | |
| project | No | Optional project name (only for multi-project repos) | |
| template | Yes | Template type to use |
Input Schema (JSON Schema)
{
"properties": {
"config": {
"description": "Configuration options for the template",
"type": "object"
},
"name": {
"description": "Workflow name",
"type": "string"
},
"project": {
"description": "Optional project name (only for multi-project repos)",
"type": "string"
},
"template": {
"description": "Template type to use",
"enum": [
"webhook-api",
"scheduled-report",
"data-sync",
"error-handler",
"approval-flow"
],
"type": "string"
}
},
"required": [
"template",
"name"
],
"type": "object"
}
Implementation Reference
- src/tools/registry.ts:178-203 (schema)JSON schema definition for the 'generate' tool, including input parameters like template (enum), name, project, and config.{ name: 'generate', description: 'Generate a workflow from template using REAL n8n nodes (no mock/placeholder nodes). IMPORTANT: Use dashes in filenames, not underscores', inputSchema: { type: 'object', properties: { template: { type: 'string', enum: ['webhook-api', 'scheduled-report', 'data-sync', 'error-handler', 'approval-flow'], description: 'Template type to use', }, name: { type: 'string', description: 'Workflow name (use dashes, not underscores)', }, project: { type: 'string', description: 'Optional project name (only for multi-project repos)', }, config: { type: 'object', description: 'Configuration options for the template', }, }, required: ['template', 'name'], },
- src/server/mcflow.ts:76-85 (registration)MCP server registration of all tools via getToolDefinitions() for listTools, and routes tool calls to ToolHandler.handleTool.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions(), })); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { return await this.toolHandler.handleTool( request.params.name, request.params.arguments ); });
- src/tools/handler.ts:100-107 (handler)Switch case in ToolHandler that dispatches 'generate' tool calls to the generateWorkflowFromTemplate function.case 'generate': return await generateWorkflowFromTemplate( this.workflowManager, args?.template as string, args?.project as string, args?.name as string, args?.config as any );
- src/workflows/templates.ts:4-120 (handler)Core implementation of the 'generate' tool: defines hardcoded workflow templates with real n8n nodes (Webhook, Code, etc.), builds nodes/connections, and creates the workflow file via WorkflowManager.export async function generateWorkflowFromTemplate( workflowManager: WorkflowManager, template: string, project: string, name: string, config: any = {} ): Promise<any> { const templates: { [key: string]: any } = { 'webhook-api': { name: project ? `${project} - ${name}` : name, nodes: [ { id: 'webhook-trigger', name: 'Webhook', type: 'n8n-nodes-base.webhook', typeVersion: 1, position: NodePositioning.getHorizontalPosition(0), parameters: { path: config.webhookPath || `/${name}`, responseMode: 'onReceived', responseData: 'allEntries', options: {}, }, }, { id: 'process-data', name: 'Process Data', type: 'n8n-nodes-base.code', typeVersion: 2, position: NodePositioning.getHorizontalPosition(1), parameters: { language: 'javaScript', jsCode: config.processCode || '// Process the incoming data\nreturn $input.all();', }, }, { id: 'respond', name: 'Respond', type: 'n8n-nodes-base.respondToWebhook', typeVersion: 1, position: NodePositioning.getHorizontalPosition(2), parameters: { respondWith: 'json', responseBody: '={{ $json }}', }, }, ], connections: { 'webhook-trigger': { main: [[{ node: 'process-data', type: 'main', index: 0 }]], }, 'process-data': { main: [[{ node: 'respond', type: 'main', index: 0 }]], }, }, }, 'scheduled-report': { name: `${project} - ${name}`, nodes: [ { id: 'schedule-trigger', name: 'Schedule', type: 'n8n-nodes-base.scheduleTrigger', typeVersion: 1, position: NodePositioning.getVerticalPosition(0), parameters: { rule: { interval: [ { field: 'hours', hoursInterval: config.hoursInterval || 24, }, ], }, }, }, { id: 'gather-data', name: 'Gather Data', type: 'n8n-nodes-base.httpRequest', typeVersion: 4.2, position: [500, 300], parameters: { url: config.dataUrl || 'https://api.example.com/data', method: 'GET', }, }, { id: 'format-report', name: 'Format Report', type: 'n8n-nodes-base.code', typeVersion: 2, position: [750, 300], parameters: { language: 'javaScript', jsCode: '// Format the report\nreturn { report: $input.all() };', }, }, ], connections: { 'schedule-trigger': { main: [[{ node: 'gather-data', type: 'main', index: 0 }]], }, 'gather-data': { main: [[{ node: 'format-report', type: 'main', index: 0 }]], }, }, }, }; const workflowTemplate = templates[template]; if (!workflowTemplate) { throw new Error(`Unknown template: ${template}`); } return await workflowManager.createWorkflow(name, workflowTemplate, project); }