n8n_create_workflow
Create automated workflows in n8n by defining nodes, connections, and settings to streamline business processes and data integration.
Instructions
Create a new workflow in n8n.
Args:
name (string): Workflow name (required)
nodes (array): Array of node objects, each with:
name (string): Node display name
type (string): Node type (e.g., "n8n-nodes-base.httpRequest")
position ([x, y]): Canvas position
parameters (object): Node-specific parameters
credentials (object, optional): Credential mappings
connections (object): Node connections mapping
settings (object, optional): Workflow settings
tags (array, optional): Tag IDs to associate
Returns: The created workflow with its assigned ID.
Example node types:
n8n-nodes-base.manualTrigger - Manual trigger
n8n-nodes-base.scheduleTrigger - Scheduled trigger
n8n-nodes-base.webhook - Webhook trigger
n8n-nodes-base.httpRequest - HTTP Request
n8n-nodes-base.code - Custom JavaScript/Python
n8n-nodes-base.set - Set data
n8n-nodes-base.if - Conditional
n8n-nodes-base.merge - Merge data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Workflow name | |
| nodes | No | Array of workflow nodes | |
| connections | No | Node connections mapping | |
| settings | No | Workflow settings | |
| staticData | No | Static data for the workflow | |
| tags | No | Array of tag IDs to associate |
Implementation Reference
- src/tools/workflows.ts:171-178 (handler)The handler function for 'n8n_create_workflow' which calls the 'post' utility to create a workflow in n8n.
async (params: z.infer<typeof CreateWorkflowSchema>) => { const workflow = await post<N8nWorkflow>('/workflows', params); return { content: [{ type: 'text', text: `✅ Workflow created successfully!\n\n${formatWorkflow(workflow)}` }], structuredContent: workflow }; } - src/tools/workflows.ts:133-179 (registration)Registration of the 'n8n_create_workflow' tool, including its schema and description.
server.registerTool( 'n8n_create_workflow', { title: 'Create n8n Workflow', description: `Create a new workflow in n8n. Args: - name (string): Workflow name (required) - nodes (array): Array of node objects, each with: - name (string): Node display name - type (string): Node type (e.g., "n8n-nodes-base.httpRequest") - position ([x, y]): Canvas position - parameters (object): Node-specific parameters - credentials (object, optional): Credential mappings - connections (object): Node connections mapping - settings (object, optional): Workflow settings - tags (array, optional): Tag IDs to associate Returns: The created workflow with its assigned ID. Example node types: - n8n-nodes-base.manualTrigger - Manual trigger - n8n-nodes-base.scheduleTrigger - Scheduled trigger - n8n-nodes-base.webhook - Webhook trigger - n8n-nodes-base.httpRequest - HTTP Request - n8n-nodes-base.code - Custom JavaScript/Python - n8n-nodes-base.set - Set data - n8n-nodes-base.if - Conditional - n8n-nodes-base.merge - Merge data`, inputSchema: CreateWorkflowSchema, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } }, async (params: z.infer<typeof CreateWorkflowSchema>) => { const workflow = await post<N8nWorkflow>('/workflows', params); return { content: [{ type: 'text', text: `✅ Workflow created successfully!\n\n${formatWorkflow(workflow)}` }], structuredContent: workflow }; } ); - src/schemas/index.ts:71-84 (schema)Zod schema definition for 'CreateWorkflowSchema' used to validate inputs for 'n8n_create_workflow'.
export const CreateWorkflowSchema = z.object({ name: z.string().min(1).max(128) .describe('Workflow name'), nodes: z.array(NodeSchema).default([]) .describe('Array of workflow nodes'), connections: z.record(z.record(z.array(z.array(ConnectionSchema)))).default({}) .describe('Node connections mapping'), settings: WorkflowSettingsSchema.optional() .describe('Workflow settings'), staticData: z.record(z.unknown()).optional() .describe('Static data for the workflow'), tags: z.array(z.string()).optional() .describe('Array of tag IDs to associate') }).strict();