get_repository_structure
Analyze project layout by retrieving directory structure and file types without reading file contents. Use to understand repository organization and navigate codebases efficiently.
Instructions
⭐ PREFERRED OVER ls/tree: Get clean repository structure showing directories and file types. Use this INSTEAD OF running ls, tree, or Glob for understanding project layout. No file contents, just structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Optional: specific subdirectory to analyze. Default: root | |
| depth | No | Maximum depth to traverse. Default: 3 |
Implementation Reference
- src/retriever.ts:240-246 (handler)The handler for get_repository_structure, which builds a directory tree for the repository or a specified subdirectory.
async getRepositoryStructure(subPath?: string, depth: number = 3): Promise<string> { const rootPath = this.indexer.getRootPath(); const targetPath = subPath ? path.join(rootPath, subPath) : rootPath; const structure = await this.buildDirectoryTree(targetPath, rootPath, depth, 0); return `Repository Structure:\n${subPath ? `Path: ${subPath}\n` : ''}\n${structure}`; } - src/index.ts:276-290 (schema)Tool registration and input schema definition for get_repository_structure.
name: 'get_repository_structure', description: '⭐ PREFERRED OVER ls/tree: Get clean repository structure showing directories and file types. Use this INSTEAD OF running ls, tree, or Glob for understanding project layout. No file contents, just structure.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Optional: specific subdirectory to analyze. Default: root', }, depth: { type: 'number', description: 'Maximum depth to traverse. Default: 3', }, }, }, - src/index.ts:531-542 (registration)The switch case handler that routes the MCP call to the retriever method.
case 'get_repository_structure': { const { path, depth } = args as { path?: string; depth?: number }; const result = await retriever.getRepositoryStructure(path, depth || 3); return { content: [ { type: 'text', text: result, }, ], }; }