list-workflows
Retrieve and display all available workflows in n8n after initialization. Input required: compact JSON with clientId for streamlined access.
Instructions
List all workflows from n8n. Use after init-n8n to see available workflows. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientId | Yes |
Implementation Reference
- src/index.ts:887-926 (handler)The primary handler for executing the 'list-workflows' tool. It retrieves the N8nClient instance using the provided clientId, calls the client's listWorkflows method, formats the workflow data, and returns it as a JSON string in the tool response.case "list-workflows": { const { clientId } = args as { clientId: string }; const client = clients.get(clientId); if (!client) { return { content: [{ type: "text", text: "Client not initialized. Please run init-n8n first.", }], isError: true }; } try { const workflows = await client.listWorkflows(); const formattedWorkflows = workflows.data.map(wf => ({ id: wf.id, name: wf.name, active: wf.active, created: wf.createdAt, updated: wf.updatedAt, tags: wf.tags, })); return { content: [{ type: "text", text: JSON.stringify(formattedWorkflows, null, 2), }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }], isError: true }; } }
- src/index.ts:413-422 (registration)Registration of the 'list-workflows' tool within the ListToolsRequestSchema handler. Defines the tool's name, description, and input schema, making it discoverable by MCP clients.name: "list-workflows", description: "List all workflows from n8n. Use after init-n8n to see available workflows. IMPORTANT: Arguments must be provided as compact, single-line JSON without whitespace or newlines.", inputSchema: { type: "object", properties: { clientId: { type: "string" } }, required: ["clientId"] } },
- src/index.ts:415-421 (schema)Input schema for the 'list-workflows' tool, specifying that a 'clientId' string is required.inputSchema: { type: "object", properties: { clientId: { type: "string" } }, required: ["clientId"] }
- src/index.ts:156-158 (helper)Core helper method in the N8nClient class that makes the HTTP request to the n8n API endpoint '/workflows' to retrieve the list of workflows.async listWorkflows(): Promise<N8nWorkflowList> { return this.makeRequest<N8nWorkflowList>('/workflows'); }
- src/index.ts:33-36 (schema)TypeScript interface defining the structure of the response from the n8n workflows list API, used by the listWorkflows method.interface N8nWorkflowList { data: N8nWorkflow[]; nextCursor?: string; }