n8n_get_workflow
Retrieve a complete n8n workflow JSON by ID for auditing or integration with n8n_lint_workflow.
Instructions
Fetch a single workflow JSON by id from a live n8n instance (requires N8N_API_URL + N8N_API_KEY). Returns the full nodes/connections payload — pair with n8n_lint_workflow to audit a deployed workflow.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Workflow ID. |
Implementation Reference
- src/index.ts:70-75 (registration)Tool 'n8n_get_workflow' is registered in the tools array with its name, description, and inputSchema (getWorkflowInputSchema imported from rest-api.ts).
{ name: "n8n_get_workflow", description: "Fetch a single workflow JSON by id from a live n8n instance (requires N8N_API_URL + N8N_API_KEY). Returns the full nodes/connections payload — pair with n8n_lint_workflow to audit a deployed workflow.", inputSchema: getWorkflowInputSchema, }, - src/index.ts:121-122 (registration)The request handler dispatches 'n8n_get_workflow' calls to the getWorkflow function.
case "n8n_get_workflow": return getWorkflow(args ?? {}); - src/tools/rest-api.ts:146-152 (schema)getWorkflowInputSchema defines the input: a required 'id' string field.
export const getWorkflowInputSchema = { type: "object", properties: { id: { type: "string", description: "Workflow ID." }, }, required: ["id"], } as const; - src/tools/rest-api.ts:154-154 (helper)getWorkflowZod is a Zod schema validating the 'id' parameter for getWorkflow.
const getWorkflowZod = z.object({ id: z.string().min(1) }); - src/tools/rest-api.ts:156-163 (handler)getWorkflow is the handler function: it reads config, parses args with Zod, calls GET /workflows/:id via the n8n REST API, and returns the full workflow JSON.
export async function getWorkflow(rawArgs: unknown) { const cfg = getConfig(); if ("error" in cfg) return textResult(cfg.error); const args = getWorkflowZod.parse(rawArgs); const r = await call(cfg, "GET", `/workflows/${encodeURIComponent(args.id)}`); if (!r.ok) return textResult(r.error); return jsonResult(r.data); }