delete_workflow
Permanently remove a workflow by its ID from the MCP n8n-builder server. Use this irreversible action carefully; consider deactivating workflows if reuse is possible.
Instructions
Permanently deletes a workflow by its ID. This action cannot be undone, so use with caution. Consider deactivating workflows instead if you might need them again later.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the workflow to delete - can be obtained from list_workflows |
Implementation Reference
- The handler function that executes the delete_workflow tool. It validates the workflow ID, retrieves the workflow details to include the name in the response, calls the API client to delete the workflow, and returns a success or error message./** * Handles the delete_workflow tool */ export async function handle_delete_workflow( api_client: N8nApiClient, args: any, ) { if (!args.id) { throw new McpError( ErrorCode.InvalidParams, 'Workflow ID is required', ); } // First get the workflow to show its name try { const workflow = await api_client.get_workflow(args.id); // Now delete the workflow const result = await api_client.delete_workflow(args.id); return { content: [ { type: 'text', text: `Successfully deleted workflow "${workflow.name}" (ID: ${args.id})`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error deleting workflow: ${ error.message || String(error) }`, }, ], isError: true, }; } }
- src/tool-handlers/index.ts:203-217 (registration)Registration of the 'delete_workflow' tool in the MCP server, including name, description, and input schema definition.name: 'delete_workflow', description: 'Permanently deletes a workflow by its ID. This action cannot be undone, so use with caution. Consider deactivating workflows instead if you might need them again later.', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'ID of the workflow to delete - can be obtained from list_workflows', }, }, required: ['id'], }, },
- src/tool-handlers/index.ts:328-329 (registration)The switch case in the tool call handler that routes calls to 'delete_workflow' to the handle_delete_workflow function.case 'delete_workflow': return await handle_delete_workflow(api_client, args);
- src/n8n-api-client.ts:153-155 (helper)The N8nApiClient helper method that performs the actual HTTP DELETE request to delete the workflow from the n8n API.async delete_workflow(id: string): Promise<any> { return this.request<any>('DELETE', `/workflows/${id}`); }
- src/tool-handlers/index.ts:15-15 (registration)Import of the handle_delete_workflow function from workflow-tools.js for use in tool registration.handle_delete_workflow,