Skip to main content
Glama

create-workflow

Set up a new workflow in MCP-N8N by defining nodes and connections. Requires compact JSON input with client ID, name, nodes, and connections for configuration.

Instructions

Create a new workflow in n8n. Use to set up a new workflow with optional nodes and connections. IMPORTANT: 1) Arguments must be provided as compact, single-line JSON without whitespace or newlines. 2) Must provide full workflow structure including nodes and connections arrays, even if empty. The 'active' property should not be included as it is read-only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientIdYes
connectionsNo
nameYes
nodesNo

Implementation Reference

  • src/index.ts:436-448 (registration)
    Registration of the 'create-workflow' tool in the ListTools response, specifying name, description, and input schema.
    name: "create-workflow", description: "Create a new workflow in n8n. Use to set up a new workflow with optional nodes and connections. IMPORTANT: 1) Arguments must be provided as compact, single-line JSON without whitespace or newlines. 2) Must provide full workflow structure including nodes and connections arrays, even if empty. The 'active' property should not be included as it is read-only.", inputSchema: { type: "object", properties: { clientId: { type: "string" }, name: { type: "string" }, nodes: { type: "array" }, connections: { type: "object" } }, required: ["clientId", "name"] } },
  • Input schema for the 'create-workflow' tool defining parameters: clientId (required), name (required), nodes (optional array), connections (optional object).
    inputSchema: { type: "object", properties: { clientId: { type: "string" }, name: { type: "string" }, nodes: { type: "array" }, connections: { type: "object" } }, required: ["clientId", "name"] }
  • Main MCP CallTool handler for 'create-workflow': extracts arguments, retrieves N8nClient instance, calls createWorkflow method, handles success/error responses.
    case "create-workflow": { const { clientId, name, nodes = [], connections = {} } = args as { clientId: string; name: string; nodes?: any[]; connections?: Record<string, any>; }; const client = clients.get(clientId); if (!client) { return { content: [{ type: "text", text: "Client not initialized. Please run init-n8n first.", }], isError: true }; } try { const workflow = await client.createWorkflow(name, nodes, connections); return { content: [{ type: "text", text: `Successfully created workflow:\n${JSON.stringify(workflow, null, 2)}`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }], isError: true }; } }
  • N8nClient.createWorkflow method: the core logic that performs POST request to /workflows endpoint with workflow name, nodes, connections, and default settings.
    async createWorkflow(name: string, nodes: any[] = [], connections: any = {}): Promise<N8nWorkflow> { return this.makeRequest<N8nWorkflow>('/workflows', { method: 'POST', body: JSON.stringify({ name, nodes, connections, settings: { saveManualExecutions: true, saveExecutionProgress: true, }, }), }); }
  • TypeScript interface defining the structure of an N8n workflow object returned by the API.
    interface N8nWorkflow { id: number; name: string; active: boolean; createdAt: string; updatedAt: string; tags: string[]; }

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/fellipesaraiva88/n8n-mcp-server'

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