activate
Activate or deactivate n8n workflows to control automation execution and manage workflow states within the McFlow server.
Instructions
Activate or deactivate a workflow in n8n
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Workflow ID | |
| active | Yes | Set to true to activate, false to deactivate |
Implementation Reference
- src/tools/handler.ts:179-183 (handler)The handler function for the 'activate' tool in the ToolHandler class's handleTool method. It delegates to n8nManager.updateWorkflowStatus with the provided workflow ID and active status.case 'activate': return await this.n8nManager.updateWorkflowStatus( args?.id as string, args?.active as boolean );
- src/tools/registry.ts:306-322 (schema)Defines the tool schema including name, description, and input schema (requires id and active boolean) for the 'activate' tool.name: 'activate', description: 'Activate or deactivate a workflow in n8n', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Workflow ID', }, active: { type: 'boolean', description: 'Set to true to activate, false to deactivate', }, }, required: ['id', 'active'], }, },
- src/server/mcflow.ts:76-78 (registration)Registers all tools, including 'activate', by providing getToolDefinitions() in response to ListToolsRequestSchema in the MCP server setup.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions(), }));
- src/n8n/manager.ts:905-931 (helper)The core helper function that executes the n8n CLI command to activate or deactivate a workflow by ID and returns success/error messages.async updateWorkflowStatus(id: string, activate: boolean): Promise<any> { try { const command = activate ? `n8n update:workflow --id=${id} --activate` : `n8n update:workflow --id=${id} --deactivate`; console.error(`Executing: ${command}`); const { stdout, stderr } = await execAsync(command); if (this.hasRealError(stderr, stdout)) { throw new Error(stderr); } return { content: [ { type: 'text', text: `β Workflow ${activate ? 'activated' : 'deactivated'} successfully!\n\n` + `π Workflow ID: ${id}\n` + `${activate ? 'βΆοΈ Status: Active' : 'βΈοΈ Status: Inactive'}\n`, }, ], }; } catch (error: any) { throw new Error(`Failed to update workflow status: ${error.message}`); } }