Skip to main content
Glama
transparentlyok

MCP Context Manager

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
NameRequiredDescriptionDefault
filePathYesPath to the file relative to repository root

Implementation Reference

  • 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');
  • 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,
          },
        ],
      };

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/transparentlyok/mcp-context-manager'

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