analyze
Analyze workflow structure and dependencies to identify connections and optimize automation processes in McFlow.
Instructions
Analyze a workflow structure and dependencies
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the workflow file relative to workflows root |
Implementation Reference
- src/workflows/analyzer.ts:4-39 (handler)The core handler function that implements the 'analyze' tool logic: reads the workflow JSON, extracts key metrics (node count, list of nodes, connections, triggers, error handling), and returns formatted analysis.export async function analyzeWorkflow(workflowsPath: string, workflowPath: string): Promise<any> { try { const fullPath = path.join(workflowsPath, workflowPath); const content = await fs.readFile(fullPath, 'utf-8'); const workflow = JSON.parse(content); const analysis = { name: workflow.name, nodeCount: workflow.nodes?.length || 0, nodes: workflow.nodes?.map((node: any) => ({ id: node.id, name: node.name, type: node.type, position: node.position, })) || [], connections: workflow.connections || {}, triggers: workflow.nodes?.filter((node: any) => node.type.includes('trigger') || node.type.includes('Trigger') ).map((node: any) => node.name) || [], hasErrorHandling: workflow.nodes?.some((node: any) => node.type.includes('error') || node.name.toLowerCase().includes('error') ) || false, }; return { content: [ { type: 'text', text: JSON.stringify(analysis, null, 2), }, ], }; } catch (error) { throw new Error(`Failed to analyze workflow: ${error}`); } }
- src/tools/registry.ts:73-86 (registration)Registers the 'analyze' tool in the MCP tool definitions array, including name, description, and input schema requiring the 'path' parameter.{ name: 'analyze', description: 'Analyze a workflow structure and dependencies', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the workflow file relative to workflows root', }, }, required: ['path'], }, },
- src/tools/handler.ts:48-50 (handler)Dispatches the 'analyze' tool call to the analyzeWorkflow implementation in the main ToolHandler.handleTool switch statement.case 'analyze': return await analyzeWorkflow(this.workflowsPath, args?.path as string);
- src/tools/registry.ts:76-85 (schema)Defines the input schema for the 'analyze' tool: object with required 'path' string property.inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the workflow file relative to workflows root', }, }, required: ['path'], },