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',
        },
      },
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'execute/test' implies a potentially resource-intensive operation, the description doesn't disclose important behavioral traits like whether this is a read-only test or actually triggers workflow execution, what permissions are required, whether it's rate-limited, or what happens to existing workflows. The description adds minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with a single sentence that communicates the core purpose and critical usage guidance. It's front-loaded with the main action and includes an important prohibition. While efficient, it could potentially be structured to separate purpose from guidance more clearly.

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

Completeness2/5

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

For a tool with 3 parameters, no annotations, no output schema, and a nested object parameter ('data'), the description is insufficiently complete. It doesn't explain what 'execute/test' means operationally, what the tool returns, whether it's safe for production use, or how to interpret results. The description leaves significant gaps for a tool that presumably triggers workflow execution.

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 all three parameters (id, file, data) with their descriptions. The description doesn't add any parameter semantics beyond what's in the schema - it doesn't explain the relationship between 'id' and 'file' parameters, or clarify that 'data' provides workflow input. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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: 'Execute/test an n8n workflow' with a specific verb (execute/test) and resource (n8n workflow). It distinguishes from alternatives by explicitly warning 'DO NOT use bash n8n commands, use this tool instead', though it doesn't differentiate from sibling tools like 'start' or 'deploy' which might have overlapping functionality.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'DO NOT use bash n8n commands, use this tool instead' clearly indicates when to use this tool versus an alternative approach. It doesn't mention when not to use it relative to sibling tools, but the explicit prohibition against bash commands provides strong contextual guidance.

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

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