n8n_duplicate_workflow
Create a copy of an existing n8n workflow by specifying its ID, with an optional new name for the duplicate.
Instructions
Create a copy of an existing workflow.
Args:
id (string): Workflow ID to duplicate
newName (string, optional): Name for the copy (default: "Copy of [original name]")
Returns: The duplicated workflow with its new ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Workflow ID to duplicate | |
| newName | No | Name for the copy |
Implementation Reference
- src/tools/audit-utils.ts:261-305 (handler)The handler function for 'n8n_duplicate_workflow', which retrieves an existing workflow, prepares it for duplication (clearing ID/metadata), updates the name, sets it to inactive, and creates it as a new workflow via a POST request.
server.registerTool( 'n8n_duplicate_workflow', { title: 'Duplicate Workflow', description: `Create a copy of an existing workflow. Args: - id (string): Workflow ID to duplicate - newName (string, optional): Name for the copy (default: "Copy of [original name]") Returns: The duplicated workflow with its new ID.`, inputSchema: z.object({ id: z.string().min(1).describe('Workflow ID to duplicate'), newName: z.string().optional().describe('Name for the copy') }).strict(), annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } }, async (params: { id: string; newName?: string }) => { // Get the original workflow const original = await get<Record<string, unknown>>(`/workflows/${params.id}`); // Prepare copy const copy = { ...original }; delete copy.id; delete copy.createdAt; delete copy.updatedAt; delete copy.versionId; copy.name = params.newName || `Copy of ${original.name}`; copy.active = false; // Always deactivate copies // Create the copy const newWorkflow = await post<Record<string, unknown>>('/workflows', copy); return { content: [{ type: 'text', text: `✅ Workflow duplicated!\n\n- Original ID: ${params.id}\n- New ID: ${newWorkflow.id}\n- New Name: ${newWorkflow.name}` }], structuredContent: newWorkflow }; } );