Skip to main content
Glama

list

Display all n8n workflows in your project to review and manage automation processes, with optional filtering by project name.

Instructions

List all n8n workflows in this project (use deployed to see workflows in n8n)

Input Schema

NameRequiredDescriptionDefault
projectNoOptional project name to filter workflows

Input Schema (JSON Schema)

{ "properties": { "project": { "description": "Optional project name to filter workflows", "type": "string" } }, "type": "object" }

Implementation Reference

  • Core handler function that implements the logic for listing all n8n workflows in the project by scanning appropriate directories and formatting the output as a markdown list.
    async listWorkflows(project?: string): Promise<any> { const workflows: Array<{ path: string; name: string; project?: string }> = []; try { if (this.structure.type === 'simple') { // Simple structure: look in ./workflows/flows/ // Try multiple possible paths const possibleFlowsPaths = [ path.join(this.workflowsPath, 'flows'), path.join(this.workflowsPath, 'flows'), ]; let foundWorkflows = false; for (const flowsDir of possibleFlowsPaths) { try { const files = await fs.readdir(flowsDir); for (const file of files) { if (file.endsWith('.json') && !file.includes('package.json') && !file.includes('workflow_package.json')) { workflows.push({ path: `workflows/flows/${file}`, name: file.replace('.json', ''), }); foundWorkflows = true; } } if (foundWorkflows) break; } catch { // Try next path } } if (!foundWorkflows) { console.error('No flows directory found. It will be created when you add your first workflow.'); } } else if (this.structure.type === 'multi-project') { // Multi-project structure if (project) { // List workflows for specific project const projectPath = path.join(this.workflowsPath, project, 'workflows'); try { const files = await fs.readdir(projectPath); for (const file of files) { if (file.endsWith('.json')) { workflows.push({ path: `${project}/workflows/${file}`, name: file.replace('.json', ''), project, }); } } } catch {} } else if (this.structure.projects) { // List all workflows from all projects for (const proj of this.structure.projects) { const workflowsDir = path.join(this.workflowsPath, proj, 'workflows'); try { const files = await fs.readdir(workflowsDir); for (const file of files) { if (file.endsWith('.json')) { workflows.push({ path: `${proj}/workflows/${file}`, name: file.replace('.json', ''), project: proj, }); } } } catch {} } } } else { // Unknown structure: try common locations const possiblePaths = [ path.join(this.workflowsPath, 'flows'), // New structure this.workflowsPath, // Already the workflows folder this.workflowsPath, // Root ]; for (const searchPath of possiblePaths) { try { const files = await fs.readdir(searchPath); for (const file of files) { if (file.endsWith('.json')) { const relativePath = path.relative(this.workflowsPath, path.join(searchPath, file)); workflows.push({ path: relativePath, name: file.replace('.json', ''), }); } } break; // Stop after finding workflows in one location } catch {} } } // Format the output nicely let output = ''; if (workflows.length === 0) { output = 'πŸ“­ No workflows found.\n\nCreate your first workflow to get started!'; } else { output = `πŸ“‹ Found ${workflows.length} workflow${workflows.length > 1 ? 's' : ''}:\n\n`; // Group by project if multi-project if (this.structure.type === 'multi-project') { const grouped = workflows.reduce((acc, w) => { const proj = w.project || 'common'; if (!acc[proj]) acc[proj] = []; acc[proj].push(w); return acc; }, {} as Record<string, typeof workflows>); for (const [proj, flows] of Object.entries(grouped)) { output += `πŸ“‚ ${proj}/\n`; for (const flow of flows) { output += ` β€’ ${flow.name}\n`; } output += '\n'; } } else { // Simple list for simple structure for (const workflow of workflows) { output += `β€’ ${workflow.name}\n`; } } } return { content: [ { type: 'text', text: output, }, ], }; } catch (error) { throw new Error(`Failed to list workflows: ${error}`); } }
  • Dispatch handler in ToolHandler.handleTool() that routes the 'list' tool call to WorkflowManager.listWorkflows().
    case 'list': return await this.workflowManager.listWorkflows(args?.project as string);
  • Input schema definition for the 'list' tool, including optional project filter.
    { name: 'list', description: 'List all n8n workflows in this project (use deployed to see workflows in n8n)', inputSchema: { type: 'object', properties: { project: { type: 'string', description: 'Optional project name to filter workflows', }, }, }, },
  • MCP server registration of tool handlers: ListTools returns schemas from getToolDefinitions(), CallTool dispatches to ToolHandler.handleTool().
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions(), })); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { return await this.toolHandler.handleTool( request.params.name, request.params.arguments ); });
  • Instantiation of ToolHandler with required managers (including WorkflowManager which provides listWorkflows).
    this.toolHandler = new ToolHandler( this.workflowsPath, this.workflowManager, this.n8nManager, this.credentialHelper );

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/mckinleymedia/mcflow-mcp'

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