create_node
Add a new node to an existing n8n workflow, specifying type, parameters, and position for workflow automation.
Instructions
Create a new node in an existing n8n workflow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflowId | Yes | The workflow ID | |
| type | Yes | The node type (e.g., n8n-nodes-base.webhook) | |
| name | No | Optional name for the node | |
| params | No | Optional node parameters | |
| position | No | Optional [x, y] position | |
| credentials | No | Optional credentials configuration |
Implementation Reference
- src/n8n-client.ts:408-424 (handler)Core handler implementation in N8nClient that generates a node ID, computes default position if needed, constructs the new node object, and atomically appends it to the workflow's nodes array via performWorkflowUpdate.async createNode(request: CreateNodeRequest): Promise<CreateNodeResponse> { const nodeId = this.generateNodeId(); await this.performWorkflowUpdate(request.workflowId, (workflow) => { const position = request.position || this.getDefaultPosition(workflow.nodes); const newNode: N8nNode = { id: nodeId, name: request.name || request.type.split('.').pop() || 'New Node', type: request.type, typeVersion: 1, position, parameters: request.params || {}, credentials: request.credentials || {}, }; workflow.nodes.push(newNode); }); return { nodeId }; }
- src/index.ts:541-551 (handler)MCP server tool handler that receives the tool call, delegates to N8nClient.createNode, and formats the success response as MCP content.private async handleCreateNode(args: CreateNodeRequest) { const result = await this.n8nClient.createNode(args); return { content: [ { type: 'text', text: JSON.stringify(jsonSuccess(result), null, 2), }, ], }; }
- src/index.ts:211-211 (registration)Tool registration in the MCP server's ListTools response, defining the tool name, description, and JSON schema for input validation.{ name: 'create_node', description: 'Create a new node in an existing n8n workflow', inputSchema: { type: 'object', properties: { workflowId: { oneOf: [{ type: 'string' }, { type: 'number' }], description: 'The workflow ID' }, type: { type: 'string', description: 'The node type (e.g., n8n-nodes-base.webhook)' }, name: { type: 'string', description: 'Optional name for the node' }, params: { type: 'object', description: 'Optional node parameters' }, position: { type: 'array', items: { type: 'number' }, minItems: 2, maxItems: 2, description: 'Optional [x, y] position' }, credentials: { type: 'object', description: 'Optional credentials configuration' } }, required: ['workflowId', 'type'] } },
- src/types.ts:188-195 (schema)TypeScript interface defining the input parameters for create_node, used in handlers and registration.export interface CreateNodeRequest { workflowId: string | number; type: string; name?: string; params?: Record<string, any>; position?: [number, number]; credentials?: Record<string, string>; }
- src/types.ts:197-199 (schema)TypeScript interface defining the output of create_node, containing the generated node ID.export interface CreateNodeResponse { nodeId: string; }