get_file_summary
Extract file structure including exports, functions, classes, and imports to understand code organization without reading full implementation details.
Instructions
⭐ PREFERRED FOR FILE OVERVIEW: Get file structure (exports, functions, classes, imports) without reading full content. Use this INSTEAD OF Read when you need to understand what's in a file without seeing implementation details. Saves 90% tokens.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path to the file relative to repository root |
Implementation Reference
- src/retriever.ts:175-208 (handler)The actual implementation logic for get_file_summary tool.
async getFileSummary(filePath: string): Promise<string> { const fileIndex = this.indexer.getFileIndex(filePath); if (!fileIndex) { return `File "${filePath}" not found in index.\nMake sure the file exists and the repository is indexed.`; } let summary = `File: ${filePath}\n`; summary += `Language: ${fileIndex.language}\n`; summary += `Lines: ${fileIndex.lines}\n`; summary += `Size: ${this.formatBytes(fileIndex.size)}\n\n`; if (fileIndex.imports.length > 0) { summary += `Imports (${fileIndex.imports.length}):\n`; summary += fileIndex.imports.slice(0, 10).map((imp) => ` - ${imp}`).join('\n'); if (fileIndex.imports.length > 10) { summary += `\n ... and ${fileIndex.imports.length - 10} more`; } summary += '\n\n'; } if (fileIndex.exports.length > 0) { summary += `Exports (${fileIndex.exports.length}):\n`; summary += fileIndex.exports.map((exp) => ` - ${exp}`).join('\n') + '\n\n'; } if (fileIndex.symbols.length > 0) { const byType = this.groupByType(fileIndex.symbols); for (const [type, symbols] of Object.entries(byType)) { summary += `${type}s (${symbols.length}):\n`; summary += symbols .map((s) => ` - ${s.name} (line ${s.line})${s.signature ? `: ${s.signature}` : ''}`) .join('\n'); - src/index.ts:239-252 (schema)Tool registration and schema definition for get_file_summary.
{ name: 'get_file_summary', description: '⭐ PREFERRED FOR FILE OVERVIEW: Get file structure (exports, functions, classes, imports) without reading full content. Use this INSTEAD OF Read when you need to understand what\'s in a file without seeing implementation details. Saves 90% tokens.', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the file relative to repository root', }, }, required: ['filePath'], }, }, - src/index.ts:485-502 (registration)The request handler switch-case that calls the retriever.getFileSummary function.
case 'get_file_summary': { const a = args as any; const filePath: string = a.filePath || a.path || a.file; if (!filePath) { return { content: [{ type: 'text', text: 'Error: filePath is required.' }], isError: true, }; } const result = await retriever.getFileSummary(filePath); return { content: [ { type: 'text', text: result, }, ], };