Skip to main content
Glama
Jimmy974

n8n Workflow Builder MCP Server

by Jimmy974

create_workflow

Create and configure n8n workflows programmatically by defining nodes and connections for automated task orchestration.

Instructions

Create and configure n8n workflows programmatically

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nodesYes
connectionsNo

Implementation Reference

  • The CallToolRequestSchema request handler implements the core logic for the 'create_workflow' tool: it validates the input arguments, uses N8NWorkflowBuilder to construct the workflow with nodes and connections, and returns the exported JSON workflow.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== 'create_workflow') {
        throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
      }
    
      try {
        const builder = new N8NWorkflowBuilder();
        function isWorkflowSpec(obj: any): obj is WorkflowSpec {
          return obj &&
            typeof obj === 'object' &&
            Array.isArray(obj.nodes) &&
            obj.nodes.every((node: any) => 
              typeof node === 'object' &&
              typeof node.type === 'string' &&
              typeof node.name === 'string'
            ) &&
            (!obj.connections || (
              Array.isArray(obj.connections) &&
              obj.connections.every((conn: any) =>
                typeof conn === 'object' &&
                typeof conn.source === 'string' &&
                typeof conn.target === 'string'
              )
            ));
        }
    
        const args = request.params.arguments;
        if (!isWorkflowSpec(args)) {
          throw new McpError(
            ErrorCode.InvalidParams,
            'Invalid workflow specification: must include nodes array with type and name properties'
          );
        }
        
        const { nodes, connections } = args;
    
        for (const node of nodes) {
          builder.addNode(node.type, node.name, node.parameters || {});
        }
    
        for (const conn of connections || []) {
          builder.connectNodes(
            conn.source,
            conn.target,
            conn.sourceOutput,
            conn.targetInput
          );
        }
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(builder.exportWorkflow(), null, 2)
          }]
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Workflow creation failed: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    });
  • Input schema for the 'create_workflow' tool, specifying the structure of nodes and optional connections.
    inputSchema: {
      type: 'object',
      properties: {
        nodes: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              type: { type: 'string' },
              name: { type: 'string' },
              parameters: { type: 'object' }
            },
            required: ['type', 'name']
          }
        },
        connections: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              source: { type: 'string' },
              target: { type: 'string' },
              sourceOutput: { type: 'number', default: 0 },
              targetInput: { type: 'number', default: 0 }
            },
            required: ['source', 'target']
          }
        }
      },
      required: ['nodes']
    }
  • src/index.ts:102-137 (registration)
    Registration of the 'create_workflow' tool in the ListToolsRequestSchema handler.
      tools: [{
        name: 'create_workflow',
        description: 'Create and configure n8n workflows programmatically',
        inputSchema: {
          type: 'object',
          properties: {
            nodes: {
              type: 'array',
              items: {
                type: 'object',
                properties: {
                  type: { type: 'string' },
                  name: { type: 'string' },
                  parameters: { type: 'object' }
                },
                required: ['type', 'name']
              }
            },
            connections: {
              type: 'array',
              items: {
                type: 'object',
                properties: {
                  source: { type: 'string' },
                  target: { type: 'string' },
                  sourceOutput: { type: 'number', default: 0 },
                  targetInput: { type: 'number', default: 0 }
                },
                required: ['source', 'target']
              }
            }
          },
          required: ['nodes']
        }
      }]
    }));
  • Helper class N8NWorkflowBuilder that manages workflow nodes, connections, positioning, and exports the final n8n-compatible workflow JSON structure.
    class N8NWorkflowBuilder {
      private nodes: any[];
      private connections: any[];
      private nextPosition: { x: number, y: number };
    
      constructor() {
        this.nodes = [];
        this.connections = [];
        this.nextPosition = { x: 100, y: 100 };
      }
    
      addNode(nodeType: string, name: string, parameters: any) {
        const node = {
          type: nodeType,
          name: name,
          parameters: parameters,
          position: { ...this.nextPosition }
        };
        this.nodes.push(node);
        this.nextPosition.x += 200;
        return name;
      }
    
      connectNodes(source: string, target: string, sourceOutput = 0, targetInput = 0) {
        this.connections.push({
          source_node: source,
          target_node: target,
          source_output: sourceOutput,
          target_input: targetInput
        });
      }
    
      exportWorkflow(): any {
        interface WorkflowConnection {
          node: string;
          type: string;
          index: number;
          sourceNode: string;
          sourceIndex: number;
        }
    
        interface Workflow {
          nodes: any[];
          connections: {
            main: WorkflowConnection[];
          };
        }
    
        const workflow: Workflow = {
          nodes: this.nodes,
          connections: { main: [] }
        };
        
        for (const conn of this.connections) {
          const connection: WorkflowConnection = {
            node: conn.target_node,
            type: 'main',
            index: conn.target_input,
            sourceNode: conn.source_node,
            sourceIndex: conn.source_output
          };
          workflow.connections.main.push(connection);
        }
        
        return workflow;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'create and configure' which implies a write operation, but fails to disclose critical behavioral traits such as permissions required, whether workflows are active upon creation, error handling, or rate limits.

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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, with every word earning its place.

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?

Given the complexity of creating workflows (a mutation operation), no annotations, no output schema, and low parameter semantics, the description is incomplete. It lacks details on behavior, output, error cases, or integration context, making it inadequate for safe and effective use.

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

Parameters2/5

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

With 0% schema description coverage for the 2 parameters, the description does not compensate by explaining what 'nodes' and 'connections' represent in the context of n8n workflows. It adds no meaning beyond the bare schema, leaving parameters semantically unclear.

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 verb ('Create and configure') and resource ('n8n workflows'), specifying that this is for programmatic creation. However, without sibling tools, there's no explicit differentiation from alternatives, preventing a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus other methods (e.g., UI-based creation) or any prerequisites. It implies usage for programmatic workflow creation but lacks explicit context or exclusions.

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/Jimmy974/n8n-workflow-builder'

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