Skip to main content
Glama
lofcz

MCP Smart Filesystem Server

by lofcz

get_file_info

Retrieve file metadata like size and line count without accessing file contents. Helps determine optimal reading strategies for large files by analyzing file characteristics first.

Instructions

Get file metadata without reading contents. Useful to check size/line count before reading. For large files, provides reading strategy recommendations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to get info about

Implementation Reference

  • Main handler for 'get_file_info' tool. Validates input, retrieves file stats, detects if binary, identifies language, counts lines, and provides reading strategy for large files using imported helpers.
    case 'get_file_info': {
      const schema = z.object({ path: z.string() });
      const { path } = schema.parse(args);
      const validatedPath = await validatePath(path);
      
      const stats = await getFileStats(validatedPath);
      const isBinary = await isBinaryFile(validatedPath);
      const language = detectLanguage(validatedPath);
      
      let lines: number | undefined;
      let readingStrategy: any = undefined;
      
      if (!isBinary && stats.isFile) {
        try {
          const content = await readFileContent(validatedPath);
          lines = countLines(content);
          
          if (shouldPaginate(lines)) {
            readingStrategy = {
              recommendation: `File is large (${lines} lines). Suggested approach:`,
              options: generateReadingSuggestions(lines)
            };
          }
        } catch {
          // Ignore read errors
        }
      }
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify({
            path: validatedPath,
            size: {
              bytes: stats.size,
              readable: `${stats.size} bytes`
            },
            lines,
            type: stats.isDirectory ? 'directory' : 'file',
            language,
            isBinary,
            lastModified: stats.modified.toISOString(),
            permissions: stats.permissions,
            readingStrategy
          }, null, 2)
        }]
      };
    }
  • index.ts:235-248 (registration)
    Registration of the 'get_file_info' tool in the tools array, including name, description, and input schema definition.
    {
      name: 'get_file_info',
      description: 'Get file metadata without reading contents. Useful to check size/line count before reading. For large files, provides reading strategy recommendations.',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'File path to get info about'
          }
        },
        required: ['path']
      }
    },
  • Input schema definition for the 'get_file_info' tool.
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'File path to get info about'
        }
      },
      required: ['path']
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: it's a read-only operation ('get'), non-destructive, provides metadata only, and offers performance guidance for large files. However, it doesn't mention potential errors (e.g., file not found) or rate limits.

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

Conciseness5/5

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

The description is front-loaded with the core purpose in the first sentence, followed by usage context and behavioral details. Every sentence adds value without redundancy, and the structure efficiently communicates essential information in just three clauses.

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

Completeness4/5

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

For a simple read tool with one parameter and no output schema, the description is mostly complete: it covers purpose, usage, and key behaviors. However, it lacks details on return values (e.g., what metadata fields are included) and doesn't mention error handling, which would be helpful given the absence of annotations and output schema.

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 'path' well-documented in the schema. The description doesn't add any parameter-specific details beyond what the schema provides, such as path format examples or constraints, so it meets the baseline for high schema coverage.

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

Purpose5/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 file metadata') and distinguishes it from sibling tools like 'read_file' by emphasizing it doesn't read contents. It also specifies the resource ('file') and scope ('metadata').

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('to check size/line count before reading') and when not to use it ('without reading contents'). It also implicitly suggests alternatives like 'read_file' for actual content reading and addresses large file scenarios with strategy recommendations.

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/lofcz/mcp-filesystem-smart'

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