read
Access and retrieve n8n workflow JSON files to analyze automation processes, extract code components, and facilitate workflow management and deployment.
Instructions
Read a specific n8n workflow JSON file
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the workflow file relative to workflows root |
Input Schema (JSON Schema)
{
"properties": {
"path": {
"description": "Path to the workflow file relative to workflows root",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}
Implementation Reference
- src/workflows/manager.ts:385-422 (handler)Core handler function that executes the 'read' tool logic: reads the workflow file, parses JSON, optionally formats it, and returns as MCP contentasync 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/tools/handler.ts:32-33 (handler)Entry point handler in ToolHandler.handleTool switch statement that dispatches 'read' tool calls to WorkflowManager.readWorkflowcase 'read': return await this.workflowManager.readWorkflow(args?.path as string);
- src/tools/registry.ts:20-32 (schema)Schema definition specifying input requirements (path parameter) and description for the 'read' toolname: '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/server/mcflow.ts:76-78 (registration)MCP server registration of all tools (including 'read') via getToolDefinitions() from registry.tsthis.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: getToolDefinitions(), }));