Skip to main content
Glama

generate_folder_map

Create or update a structured map file for any folder to document its contents and organization.

Instructions

Generate or update a _map.md file for a specific folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderPathYesPath to the folder to generate map for

Implementation Reference

  • MCP tool handler for 'generate_folder_map' that extracts folderPath argument and delegates to FolderMapper.generateFolderMap
    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/index.ts:726-735 (registration)
    Registration of the 'generate_folder_map' tool including name, description, and input schema in the MCP server's tools list
      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']
      }
    },
  • Input schema definition for the generate_folder_map tool: requires folderPath string
    inputSchema: {
      type: 'object',
      properties: {
        folderPath: { type: 'string', description: 'Path to the folder to generate map for' }
      },
      required: ['folderPath']
    }
  • Main implementation logic for generating folder maps: scans files in folder, analyzes exports/imports using TypeScript parser, builds FolderMap object, generates and writes _map.md 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/keleshteri/mcp-memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server