add_node_to_workflow
Append a node to an existing n8n workflow for testing and inspection purposes within a safe environment.
Instructions
Append a node JSON object to an existing workflow.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflowId | Yes | ||
| node | Yes |
Implementation Reference
- src/n8n-client.ts:130-135 (handler)The core implementation function that adds a node to a workflow by fetching the workflow, appending the node to the nodes array, and updating the workflow via n8n API.
export async function addNodeToWorkflow(workflowId: string, node: Record<string, unknown>) { const workflow = await getWorkflow(workflowId); const nodes = Array.isArray(workflow.nodes) ? workflow.nodes : []; workflow.nodes = [...nodes, node]; return await updateWorkflow(workflowId, workflow); } - src/index.ts:77-84 (registration)Tool registration defining the tool name, description, and input schema with workflowId (string) and node (object) as required parameters.
name: 'add_node_to_workflow', description: 'Append a node JSON object to an existing workflow.', inputSchema: { type: 'object', properties: { workflowId: { type: 'string' }, node: { type: 'object' } }, required: ['workflowId', 'node'], }, }, - src/index.ts:240-244 (handler)Request handler that validates input arguments using Zod schema, calls the addNodeToWorkflow function, and returns the result as JSON text.
if (name === 'add_node_to_workflow') { const { workflowId, node } = z.object({ workflowId: z.string(), node: z.record(z.unknown()) }).parse(args); const updated = await addNodeToWorkflow(workflowId, node); return { content: [{ type: 'text', text: JSON.stringify(updated, null, 2) }] }; }