list_code
Display extracted code nodes from n8n workflows to review and organize automation components for efficient development.
Instructions
List all extracted code nodes
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/registry.ts:361-368 (registration)Registers the 'list_code' tool including its description and input schema (no required inputs). Part of the getToolDefinitions() array export.
{ name: 'list_code', description: 'List all extracted code nodes', inputSchema: { type: 'object', properties: {}, }, }, - src/tools/handler.ts:224-228 (handler)The switch case in ToolHandler.handleTool() that executes the 'list_code' tool by creating a NodeManager instance and calling its listNodes() method.
case 'list_code': const codeListManager = new NodeManager(this.workflowsPath); await codeListManager.initialize(); return await codeListManager.listNodes(); - src/nodes/manager.ts:565-633 (helper)The core implementation in NodeManager.listNodes() that loads metadata from .metadata.json, groups extracted nodes by type (code, prompt, sql, etc.), formats a detailed list output grouped by type with icons and file paths, and returns it in MCP content format.
async listNodes(): Promise<any> { const metadata = await this.loadMetadata(); let output = '📚 Extracted Nodes Library\n\n'; // Group by type const byType: Record<NodeType, any[]> = { code: [], prompt: [], sql: [], template: [], json: [] }; for (const [workflowName, nodes] of Object.entries(metadata)) { for (const node of nodes as any[]) { byType[node.nodeType as NodeType].push({ ...node, workflowName }); } } // Display by type if (byType.code.length > 0) { output += '📜 Code Nodes\n'; for (const node of byType.code) { const icon = node.subType === 'python' ? '🐍' : '☕'; output += ` ${icon} ${node.nodeName} (${node.workflowName})\n`; output += ` 📁 ${node.filePath}\n`; } output += '\n'; } if (byType.prompt.length > 0) { output += '💬 Prompt Nodes\n'; for (const node of byType.prompt) { const icon = node.subType === 'openai' ? '🤖' : '🧠'; output += ` ${icon} ${node.nodeName} (${node.workflowName})\n`; output += ` 📁 ${node.filePath}\n`; } output += '\n'; } if (byType.sql.length > 0) { output += '🗄️ SQL Nodes\n'; for (const node of byType.sql) { output += ` 📊 ${node.nodeName} (${node.workflowName})\n`; output += ` 📁 ${node.filePath}\n`; } output += '\n'; } if (byType.template.length > 0) { output += '📝 Template Nodes\n'; for (const node of byType.template) { const icon = node.subType === 'html' ? '🌐' : '📄'; output += ` ${icon} ${node.nodeName} (${node.workflowName})\n`; output += ` 📁 ${node.filePath}\n`; } output += '\n'; } return { content: [{ type: 'text', text: output || '📭 No nodes extracted yet.\n\nUse "McFlow extract-nodes" to extract nodes from workflows.' }] }; }