Skip to main content
Glama

generate

Create n8n workflows from templates using real nodes. Specify template type and workflow name to generate functional automation workflows without mock components.

Instructions

Generate a workflow from template using REAL n8n nodes (no mock/placeholder nodes). IMPORTANT: Use dashes in filenames, not underscores

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYesTemplate type to use
nameYesWorkflow name (use dashes, not underscores)
projectNoOptional project name (only for multi-project repos)
configNoConfiguration options for the template

Implementation Reference

  • The core handler function that implements the 'generate' tool logic. It defines predefined workflow templates with real n8n nodes (webhook-api, scheduled-report), sets positions and connections, and creates the workflow 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);
    }
  • Defines the input schema, parameters, description, and enum values for the 'generate' tool.
    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'],
    },
  • Registers and dispatches the 'generate' tool call to the implementation function generateWorkflowFromTemplate.
    case 'generate':
      return await generateWorkflowFromTemplate(
        this.workflowManager,
        args?.template as string,
        args?.project as string,
        args?.name as string,
        args?.config as any
      );
  • MCP server registration: provides tool definitions (including 'generate') via ListToolsRequestSchema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: getToolDefinitions(),
    }));
  • MCP server handler: routes tool calls (including 'generate') to ToolHandler.handleTool for execution.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      return await this.toolHandler.handleTool(
        request.params.name,
        request.params.arguments
      );
    });

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