Skip to main content
Glama

get_file_summary

Generate statistical summaries for files, including line counts, character metrics, and word frequency analysis.

Instructions

Get comprehensive statistical summary of a file including line stats, character stats, and word count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file

Implementation Reference

  • Core implementation of get_file_summary tool. Streams the file to compute detailed statistics: line counts (total, empty, non-empty, max/avg length), character categories (alphabetic, numeric, whitespace, special), and word count for text/markdown files.
    static async getSummary(filePath: string): Promise<FileSummary> {
      await this.verifyFile(filePath);
    
      const metadata = await this.getMetadata(filePath);
    
      let emptyLines = 0;
      let maxLength = 0;
      let totalLength = 0;
      let alphabetic = 0;
      let numeric = 0;
      let whitespace = 0;
      let special = 0;
      let wordCount = 0;
    
      return new Promise((resolve, reject) => {
        const stream = fs.createReadStream(filePath);
        const rl = readline.createInterface({
          input: stream,
          crlfDelay: Infinity,
        });
    
        rl.on('line', (line) => {
          if (line.trim() === '') {
            emptyLines++;
          } else {
            wordCount += line.split(/\s+/).filter(w => w.length > 0).length;
          }
    
          maxLength = Math.max(maxLength, line.length);
          totalLength += line.length;
    
          // Character analysis
          for (const char of line) {
            if (/[a-zA-Z]/.test(char)) alphabetic++;
            else if (/\d/.test(char)) numeric++;
            else if (/\s/.test(char)) whitespace++;
            else special++;
          }
        });
    
        rl.on('close', () => {
          const total = alphabetic + numeric + whitespace + special;
    
          resolve({
            metadata,
            lineStats: {
              total: metadata.totalLines,
              empty: emptyLines,
              nonEmpty: metadata.totalLines - emptyLines,
              maxLength,
              avgLength: metadata.totalLines > 0
                ? Math.round(totalLength / metadata.totalLines)
                : 0,
            },
            charStats: {
              total,
              alphabetic,
              numeric,
              whitespace,
              special,
            },
            wordCount: metadata.fileType === FileType.TEXT ||
                       metadata.fileType === FileType.MARKDOWN
              ? wordCount
              : undefined,
          });
        });
    
        rl.on('error', reject);
      });
    }
  • src/server.ts:198-211 (registration)
    Registers the get_file_summary tool in the MCP server by including it in the list of available tools returned by getTools(). Includes tool name, description, and input schema.
    {
      name: 'get_file_summary',
      description: 'Get comprehensive statistical summary of a file including line stats, character stats, and word count.',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: {
            type: 'string',
            description: 'Absolute path to the file',
          },
        },
        required: ['filePath'],
      },
    },
  • Server-side handler wrapper for get_file_summary. Extracts filePath from arguments, calls FileHandler.getSummary, and formats response as JSON.
    private async handleGetSummary(
      args: Record<string, unknown>
    ): Promise<{ content: Array<{ type: string; text: string }> }> {
      const filePath = args.filePath as string;
    
      const summary: FileSummary = await FileHandler.getSummary(filePath);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(summary, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining the structure of the FileSummary output returned by the get_file_summary tool.
    export interface FileSummary {
      /** File metadata */
      metadata: FileMetadata;
      /** Line statistics */
      lineStats: {
        total: number;
        empty: number;
        nonEmpty: number;
        maxLength: number;
        avgLength: number;
      };
      /** Character statistics */
      charStats: {
        total: number;
        alphabetic: number;
        numeric: number;
        whitespace: number;
        special: number;
      };
      /** Word count (for text files) */
      wordCount?: number;
      /** Top file patterns (e.g., most common lines) */
      patterns?: Array<{ pattern: string; count: number }>;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes what the tool does but lacks critical behavioral details: it doesn't specify if this is a read-only operation, what happens with invalid file paths, performance characteristics, or output format. For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Get comprehensive statistical summary') and specifies key details. There is no wasted text, and it appropriately sized for a simple tool. However, it could be slightly more structured by separating the statistical components for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is minimally complete. It states what the tool does but lacks context on output format, error handling, or usage scenarios. Without annotations or output schema, the description should provide more behavioral context to be fully helpful, but it meets basic adequacy.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'filePath' fully documented in the schema as 'Absolute path to the file'. The description adds no additional parameter semantics beyond what the schema provides, such as file format constraints or path examples. With high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get comprehensive statistical summary') and identifies the resource ('a file'), including what statistics are provided ('line stats, character stats, and word count'). It distinguishes from siblings by focusing on summary statistics rather than structure, navigation, reading, or searching. However, it doesn't explicitly contrast with specific sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when this summary tool is preferable to reading the file directly with sibling tools like 'read_large_file_chunk' or 'stream_large_file', nor does it specify prerequisites or exclusions. Usage context is implied but not stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/willianpinho/large-file-mcp'

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