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 }; };

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