n8n_activate_workflow
Activate or deactivate an n8n workflow by providing its ID. Set active to false to stop it.
Instructions
Activate or deactivate a workflow on a live n8n instance (requires N8N_API_URL + N8N_API_KEY). Pass active: false to deactivate.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Workflow ID. | |
| active | No | Defaults to true (activate). Set false to deactivate. |
Implementation Reference
- src/tools/rest-api.ts:232-244 (handler)The activateWorkflow async function that executes the n8n_activate_workflow tool. Calls POST /workflows/{id}/{activate|deactivate} on the n8n REST API.
export async function activateWorkflow(rawArgs: unknown) { const cfg = getConfig(); if ("error" in cfg) return textResult(cfg.error); const args = activateWorkflowZod.parse(rawArgs); const action = args.active === false ? "deactivate" : "activate"; const r = await call( cfg, "POST", `/workflows/${encodeURIComponent(args.id)}/${action}`, ); if (!r.ok) return textResult(r.error); return textResult(`Workflow ${args.id} ${action}d.`); } - src/tools/rest-api.ts:214-225 (schema)Input JSON Schema for n8n_activate_workflow. Requires 'id' (string workflow ID), optional 'active' boolean (default true for activate, false for deactivate).
export const activateWorkflowInputSchema = { type: "object", properties: { id: { type: "string", description: "Workflow ID." }, active: { type: "boolean", description: "Defaults to true (activate). Set false to deactivate.", }, }, required: ["id"], } as const; - src/tools/rest-api.ts:227-230 (schema)Zod validation schema for n8n_activate_workflow input, used at runtime to parse and validate arguments.
const activateWorkflowZod = z.object({ id: z.string().min(1), active: z.boolean().optional(), }); - src/index.ts:82-87 (registration)Registration of the n8n_activate_workflow tool in the tools array, with its name, description, and inputSchema.
{ name: "n8n_activate_workflow", description: "Activate or deactivate a workflow on a live n8n instance (requires N8N_API_URL + N8N_API_KEY). Pass `active: false` to deactivate.", inputSchema: activateWorkflowInputSchema, }, - src/index.ts:125-126 (registration)Dispatch in the CallToolRequestSchema handler that routes n8n_activate_workflow to the activateWorkflow function.
case "n8n_activate_workflow": return activateWorkflow(args ?? {}); - src/tools/rest-api.ts:20-30 (helper)Helper function getConfig() that reads N8N_API_URL and N8N_API_KEY from environment, used by the activateWorkflow handler.
function getConfig(): ApiConfig | { error: string } { const url = process.env.N8N_API_URL?.trim(); const key = process.env.N8N_API_KEY?.trim(); if (!url || !key) { return { error: "n8n REST tools are not configured. Set N8N_API_URL (e.g. https://n8n.example.com) and N8N_API_KEY (n8n -> Settings -> API) in the MCP server's environment. The other 4 tools (generate, lint, scaffold, explain) work without these.", }; } const trimmed = url.replace(/\/$/, "").replace(/\/api\/v1$/, ""); return { baseUrl: `${trimmed}/api/v1`, apiKey: key };