Skip to main content
Glama
ifmelate

n8n-workflow-builder-mcp

by ifmelate

list_workflows

Retrieve and manage workflows on the n8n-workflow-builder-mcp server to streamline automation tasks and enhance workflow organization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that executes the list_workflows tool logic for n8n integration, calls the underlying model method.
    const listWorkflowsExecute = async (params) => {
        try {
            logger.info('Listing workflows from n8n', {
                active: params.active,
                limit: params.limit,
                offset: params.offset
            });
    
            // Prepare options for listing
            const options = {
                active: params.active,
                limit: params.limit,
                offset: params.offset
            };
    
            // Perform the list operation
            const result = await n8nIntegration.listWorkflows(options);
    
            // Log the operation
            logDataAccess({
                success: result.success,
                userId: params.userId || 'anonymous',
                dataType: 'workflow',
                action: 'list',
                details: {
                    integrationType: getIntegrationType(),
                    count: result.count
                }
            });
    
            return {
                ...result,
                message: result.message || `Retrieved ${result.count || 0} workflows from n8n`
            };
        } catch (error) {
            logger.error('Failed to list workflows from n8n', { error: error.message });
    
            // Log the failed operation
            logDataAccess({
                success: false,
                userId: params.userId || 'anonymous',
                dataType: 'workflow',
                action: 'list',
                reason: error.message
            });
    
            throw new Error(`Failed to list workflows from n8n: ${error.message}`);
        }
    };
  • Tool definition including input schema and handler association for list workflows from n8n.
    const listWorkflowsTool = createTool(
        'List workflows from n8n',
        {
            active: {
                type: 'boolean',
                description: 'Filter workflows by active status',
                optional: true
            },
            limit: {
                type: 'number',
                description: 'Maximum number of workflows to return',
                optional: true
            },
            offset: {
                type: 'number',
                description: 'Number of workflows to skip',
                optional: true
            },
            userId: {
                type: 'string',
                description: 'User identifier for security logging',
                optional: true
            }
        },
        listWorkflowsExecute
    );
  • Registration of the listWorkflowsTool in the n8nTools object, exported for MCP tool usage.
    const n8nTools = {
        deploy: n8nIntegrationTools.deployWorkflowTool,
        activate: n8nIntegrationTools.activateWorkflowTool,
        get: n8nIntegrationTools.getWorkflowTool,
        checkExecution: n8nIntegrationTools.checkExecutionStatusTool,
        list: n8nIntegrationTools.listWorkflowsTool
    };
  • Core model method implementing workflow listing via n8n API or filesystem, called by the tool handler.
    async listWorkflows(options = {}) {
        try {
            const integrationType = getIntegrationType();
            logger.info('Listing workflows from n8n', { integrationType });
    
            if (integrationType === 'api') {
                // Construct query parameters
                const queryParams = new URLSearchParams();
                if (options.active !== undefined) {
                    queryParams.append('active', options.active);
                }
                if (options.limit) {
                    queryParams.append('limit', options.limit);
                }
                if (options.offset) {
                    queryParams.append('offset', options.offset);
                }
    
                // List via n8n API
                const response = await fetch(`${config.n8n.apiUrl}workflows?${queryParams.toString()}`, {
                    method: 'GET',
                    headers: {
                        'X-N8N-API-KEY': config.n8n.apiKey
                    }
                });
    
                if (!response.ok) {
                    const errorData = await response.json().catch(() => ({}));
                    logger.error('n8n API error during workflow listing', {
                        status: response.status,
                        error: errorData
                    });
                    throw new Error(`Failed to list workflows: ${response.status} ${response.statusText}`);
                }
    
                const data = await response.json();
                const workflows = data.data || [];
    
                logger.info('Workflows listed successfully via API', { count: workflows.length });
    
                return {
                    success: true,
                    workflows: workflows.map(w => ({
                        id: w.id,
                        name: w.name,
                        active: w.active,
                        createdAt: w.createdAt,
                        updatedAt: w.updatedAt
                    })),
                    count: workflows.length,
                    message: `Retrieved ${workflows.length} workflows from n8n`
                };
            } else if (integrationType === 'filesystem') {
                // If n8n workflows directory is not configured, return error
                if (!config.n8n.workflowsPath) {
                    throw new Error('n8n.workflowsPath is not configured');
                }
    
                // List via filesystem
                const n8nWorkflowsDir = path.resolve(process.cwd(), config.n8n.workflowsPath);
    
                try {
                    await fs.access(n8nWorkflowsDir);
                } catch (error) {
                    if (error.code === 'ENOENT') {
                        logger.warn('n8n workflows directory not found', { path: n8nWorkflowsDir });
                        return {
                            success: true,
                            workflows: [],
                            count: 0,
                            message: 'n8n workflows directory not found'
                        };
                    }
                    throw error;
                }
    
                const files = await fs.readdir(n8nWorkflowsDir);
                const jsonFiles = files.filter(file => file.endsWith('.json'));
    
                // Apply pagination if options provided
                const { limit, offset } = options;
                const paginatedFiles = limit
                    ? jsonFiles.slice(offset || 0, (offset || 0) + limit)
                    : jsonFiles;
    
                // Process each workflow file
                const workflowPromises = paginatedFiles.map(async (file) => {
                    const filePath = path.join(n8nWorkflowsDir, file);
                    try {
                        const data = await fs.readFile(filePath, 'utf8');
                        const workflow = JSON.parse(data);
    
                        return {
                            id: workflow.id || path.basename(file, '.json'),
                            name: workflow.name || 'Unnamed Workflow',
                            active: workflow.active || false,
                            createdAt: workflow.createdAt,
                            updatedAt: workflow.updatedAt,
                            path: filePath
                        };
                    } catch (error) {
                        logger.error('Error reading workflow file', { path: filePath, error: error.message });
                        return null;
                    }
                });
    
                // Wait for all files to be processed
                const workflows = (await Promise.all(workflowPromises)).filter(w => w !== null);
    
                // Apply active filter if provided
                const filteredWorkflows = options.active !== undefined
                    ? workflows.filter(w => w.active === options.active)
                    : workflows;
    
                logger.info('Workflows listed successfully via filesystem', {
                    count: filteredWorkflows.length,
                    path: n8nWorkflowsDir
                });
    
                return {
                    success: true,
                    workflows: filteredWorkflows,
                    count: filteredWorkflows.length,
                    message: `Retrieved ${filteredWorkflows.length} workflows from n8n`
                };
            } else {
                throw new Error('Invalid integration type');
            }
        } catch (error) {
            logger.error('Failed to list workflows from n8n', { error: error.message });
            throw new Error(`Failed to list workflows from n8n: ${error.message}`);
        }
    }
  • Mock handler for local workflow storage list operation.
    const listWorkflowsExecute = async (params) => {
        const { limit = 10, offset = 0 } = params;
    
        logger.info(`Listing workflows (limit: ${limit}, offset: ${offset})`);
    
        // Mock implementation
        return {
            workflows: [
                {
                    id: 'wf1',
                    name: 'Mock Workflow 1',
                    path: '/path/to/workflows/wf1.json',
                    lastModified: new Date().toISOString()
                },
                {
                    id: 'wf2',
                    name: 'Mock Workflow 2',
                    path: '/path/to/workflows/wf2.json',
                    lastModified: new Date().toISOString()
                }
            ],
            total: 2
        };
    };
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ifmelate/n8n-workflow-builder-mcp'

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