generate_folder_map
Create or update a _map.md file for any folder to document its structure and contents, ensuring organized and accessible project navigation.
Instructions
Generate or update a _map.md file for a specific folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folderPath | Yes | Path to the folder to generate map for |
Implementation Reference
- src/index.ts:725-735 (registration)Registration of the 'generate_folder_map' tool in the MCP server's tool list, including name, description, and input schema definition.{ name: 'generate_folder_map', description: 'Generate or update a _map.md file for a specific folder', inputSchema: { type: 'object', properties: { folderPath: { type: 'string', description: 'Path to the folder to generate map for' } }, required: ['folderPath'] } },
- src/index.ts:902-906 (handler)MCP CallToolRequest handler case for 'generate_folder_map' that validates arguments, calls FolderMapper.generateFolderMap(folderPath), and returns success message.case 'generate_folder_map': { const folderPath = args.folderPath as string; const folderMap = await this.folderMapper.generateFolderMap(folderPath); return { content: [{ type: 'text', text: `Folder map generated successfully for: ${folderPath}` }] }; }
- src/folder-mapper.ts:116-149 (handler)Core implementation of generateFolderMap in FolderMapper class: scans folder for code files, analyzes each using TypeScript ESTree parser to extract exports/imports, builds FolderMap structure with stats and inferences, generates and writes _map.md markdown file.async generateFolderMap(folderPath: string): Promise<FolderMap> { const folderName = path.basename(folderPath); console.log(chalk.blue(`📁 Generating map for: ${folderName}`)); const files = await this.getFilesInFolder(folderPath); const fileInfos: FileInfo[] = []; for (const file of files) { try { const fileInfo = await this.analyzeFile(file); if (fileInfo.exports.length > 0) { fileInfos.push(fileInfo); } } catch (error) { console.log(chalk.yellow(`⚠️ Could not analyze ${file}: ${error}`)); } } const folderMap: FolderMap = { folderPath, folderName, purpose: this.inferFolderPurpose(folderName, fileInfos), files: fileInfos, dependencies: this.extractUniqueDependencies(fileInfos), tests: await this.findRelatedTests(folderPath), lastGenerated: new Date().toISOString(), totalClasses: this.countByType(fileInfos, 'class'), totalInterfaces: this.countByType(fileInfos, 'interface'), totalFunctions: this.countByType(fileInfos, 'function') }; await this.writeMapFile(folderPath, folderMap); return folderMap; }