get_workflow
Retrieve a specific n8n workflow using its unique ID to access workflow details and configuration for automation processes.
Instructions
Get a specific n8n workflow by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The workflow ID |
Implementation Reference
- src/index.ts:393-398 (handler)Primary MCP tool handler for 'get_workflow'. Resolves workflow ID (handling numeric aliases), fetches via N8nClient, augments with alias, and returns JSON response.private async handleGetWorkflow(args: { id: string | number }) { const id = this.resolveWorkflowId(args.id); const workflow = await this.n8nClient.getWorkflow(id); this.withAlias(workflow); return { content: [{ type: 'text', text: JSON.stringify(jsonSuccess(workflow), null, 2) }] }; }
- src/index.ts:70-70 (registration)Tool registration including name, description, and input schema definition.{ name: 'get_workflow', description: 'Get a specific n8n workflow by ID', inputSchema: { type: 'object', properties: { id: { oneOf: [{ type: 'string' }, { type: 'number' }], description: 'The workflow ID' } }, required: ['id'] } },
- src/n8n-client.ts:160-164 (helper)Core N8nClient method implementing the HTTP GET request to retrieve workflow by ID.async getWorkflow(id: string | number): Promise<N8nWorkflow> { const response = await this.api.get<N8nApiResponse<N8nWorkflow> | N8nWorkflow>(`/workflows/${id}`); const payload: any = response.data as any; return (payload && typeof payload === 'object' && 'data' in payload) ? payload.data : payload; }
- src/index.ts:359-365 (helper)Helper function to resolve numeric workflow ID aliases to actual string IDs.private resolveWorkflowId(id: string | number): string | number { if (typeof id === 'number') { const real = this.workflowIdAliasToString.get(id); return real ?? id; } return id; }
- src/index.ts:370-384 (helper)Helper to attach stable numeric ID aliases to workflow objects for client convenience.private withAlias<T extends N8nWorkflow | N8nWorkflow[]>(payload: T): T { const attach = (wf: N8nWorkflow) => { const alias = this.registerWorkflowAlias(wf.id as any); if (alias != null) { // non-destructive augmentation (wf as any).numericId = alias; } }; if (Array.isArray(payload)) { payload.forEach(attach); } else { attach(payload as N8nWorkflow); } return payload; }