execute
Run n8n workflows directly from McFlow to test automation processes with provided input data.
Instructions
Execute/test an n8n workflow - DO NOT use bash n8n commands, use this tool instead
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Workflow ID to execute | |
| file | No | Path to workflow file to execute | |
| data | No | Input data for the workflow |
Implementation Reference
- src/n8n/manager.ts:768-830 (handler)Core handler function that executes the 'n8n execute' CLI command with workflow ID, file path, or input data, handles output parsing and error checking.async executeWorkflow(options: { id?: string; file?: string; data?: any; } = {}): Promise<any> { try { // Build command let command = 'n8n execute'; if (options.id) { command += ` --id=${options.id}`; } else if (options.file) { const fullPath = path.join(this.workflowsPath, options.file); command += ` --file="${fullPath}"`; } else { throw new Error('Either id or file must be specified'); } // Add input data if provided if (options.data) { const dataFile = `/tmp/n8n-input-${Date.now()}.json`; await fs.writeFile(dataFile, JSON.stringify(options.data)); command += ` --input="${dataFile}"`; } console.error(`Executing: ${command}`); const { stdout, stderr } = await execAsync(command, { timeout: 60000, // 60 second timeout }); // Clean up temp file if created if (options.data) { const dataFile = `/tmp/n8n-input-${Date.now()}.json`; await fs.unlink(dataFile).catch(() => {}); } if (this.hasRealError(stderr, stdout)) { throw new Error(stderr); } // Parse execution results if possible let result = stdout; try { result = JSON.parse(stdout); } catch { // Not JSON, use as-is } return { content: [ { type: 'text', text: `ā Workflow executed successfully!\n\n` + `${options.id ? `š Workflow ID: ${options.id}\n` : ''}` + `${options.file ? `š File: ${options.file}\n` : ''}` + `\nš Results:\n${typeof result === 'object' ? JSON.stringify(result, null, 2) : result}`, }, ], }; } catch (error: any) { throw new Error(`Failed to execute workflow: ${error.message}`); } }
- src/tools/handler.ts:155-160 (handler)Tool dispatcher in ToolHandler.handleTool method that routes 'execute' tool calls to N8nManager.executeWorkflow.case 'execute': return await this.n8nManager.executeWorkflow({ id: args?.id as string, file: args?.file as string, data: args?.data as any, });
- src/tools/registry.ts:268-288 (registration)MCP tool registration including name, description, and input schema definition returned by getToolDefinitions().{ name: 'execute', description: 'Execute/test an n8n workflow - DO NOT use bash n8n commands, use this tool instead', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Workflow ID to execute', }, file: { type: 'string', description: 'Path to workflow file to execute', }, data: { type: 'object', description: 'Input data for the workflow', }, }, }, },
- src/tools/registry.ts:271-287 (schema)Input schema definition for the 'execute' tool parameters: id (string), file (string), data (object).inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Workflow ID to execute', }, file: { type: 'string', description: 'Path to workflow file to execute', }, data: { type: 'object', description: 'Input data for the workflow', }, }, },