read
Retrieve and parse n8n workflow JSON files to access automation configurations and structure for development and deployment.
Instructions
Read a specific n8n workflow JSON file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the workflow file relative to workflows root |
Implementation Reference
- src/tools/registry.ts:19-32 (schema)Defines the schema, name, and description for the MCP 'read' tool.{ name: 'read', description: 'Read a specific n8n workflow JSON file', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the workflow file relative to workflows root', }, }, required: ['path'], }, },
- src/tools/handler.ts:32-33 (handler)ToolHandler.handleTool switch case that dispatches 'read' tool calls to WorkflowManager.readWorkflow.case 'read': return await this.workflowManager.readWorkflow(args?.path as string);
- src/workflows/manager.ts:385-422 (handler)Core implementation of reading the workflow file: constructs full path, reads and parses JSON, formats output for MCP response.async readWorkflow(workflowPath: string, options?: { format?: boolean; raw?: boolean }): Promise<any> { try { const fullPath = path.join(this.workflowsPath, workflowPath); const content = await fs.readFile(fullPath, 'utf-8'); const workflow = JSON.parse(content); // Return raw JSON if requested if (options?.raw) { return { content: [ { type: 'text', text: content, }, ], }; } // Format the workflow for better readability const formatted = this.formatter.formatWorkflow(workflow, { colorize: true, indent: 2, compact: false, showNodeDetails: true }); return { content: [ { type: 'text', text: formatted, }, ], }; } catch (error) { throw new Error(`Failed to read workflow: ${error}`); } }
- src/server/mcflow.ts:76-78 (registration)Registers the list of available tools (including 'read') via ListToolsRequestSchema using getToolDefinitions() from registry.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions(), }));
- src/server/mcflow.ts:80-85 (registration)Registers the generic tool execution handler via CallToolRequestSchema, which routes to ToolHandler.handleTool for 'read' execution.this.server.setRequestHandler(CallToolRequestSchema, async (request) => { return await this.toolHandler.handleTool( request.params.name, request.params.arguments ); });