Skip to main content
Glama

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
NameRequiredDescriptionDefault
idNoWorkflow ID to execute
fileNoPath to workflow file to execute
dataNoInput data for the workflow

Implementation Reference

  • 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}`); } }
  • 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, });
  • 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', }, }, }, },
  • 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', }, }, },

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/mckinleymedia/mcflow-mcp'

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