Skip to main content
Glama

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
NameRequiredDescriptionDefault
clientIdYes

Implementation Reference

  • 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"]
      }
    },
  • Input schema for the 'list-workflows' tool, specifying that a 'clientId' string is required.
    inputSchema: {
      type: "object",
      properties: {
        clientId: { type: "string" }
      },
      required: ["clientId"]
    }
  • 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');
    }
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fellipesaraiva88/n8n-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server