create_workflow
Create automated workflows in n8n by providing a JSON definition with nodes, connections, and optional settings.
Instructions
Create a new n8n workflow from JSON definition
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the workflow | |
| nodes | Yes | Array of workflow nodes | |
| connections | Yes | Node connections object | |
| active | No | Whether to activate the workflow | |
| settings | No | Workflow settings | |
| tags | No | Tags for the workflow |
Implementation Reference
- src/handlers.ts:85-88 (handler)Handler for create_workflow: parses args with CreateWorkflowSchema and delegates to client.createWorkflow()
case "create_workflow": { const workflow = CreateWorkflowSchema.parse(args); return await client.createWorkflow(workflow); } - src/n8n-client.ts:76-79 (helper)N8nClient.createWorkflow: sends POST /api/v1/workflows with workflow payload and validates response with WorkflowSchema
async createWorkflow(workflow: any) { const response = await this.client.post("/api/v1/workflows", workflow); return WorkflowSchema.parse(response.data); } - src/handlers.ts:16-23 (schema)CreateWorkflowSchema: Zod schema validating name (string, required), nodes (array), connections (record), active (boolean, default false), settings (record, optional), tags (array of strings, optional)
const CreateWorkflowSchema = z.object({ name: z.string(), nodes: z.array(z.any()), connections: z.record(z.any()), active: z.boolean().optional().default(false), settings: z.record(z.any()).optional(), tags: z.array(z.string()).optional(), }); - src/tools.ts:44-79 (registration)Tool registration with name 'create_workflow', description, and inputSchema (JSON Schema) requiring name, nodes, connections
{ name: "create_workflow", description: "Create a new n8n workflow from JSON definition", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the workflow", }, nodes: { type: "array", description: "Array of workflow nodes", }, connections: { type: "object", description: "Node connections object", }, active: { type: "boolean", description: "Whether to activate the workflow", default: false, }, settings: { type: "object", description: "Workflow settings", }, tags: { type: "array", items: { type: "string" }, description: "Tags for the workflow", }, }, required: ["name", "nodes", "connections"], }, }, - src/index.ts:32-34 (registration)MCP server registers the tool list via ListToolsRequestSchema, making create_workflow discoverable
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });