Skip to main content
Glama
akshat12000

File System Explorer MCP Server

by akshat12000

get_file_info

Retrieve detailed metadata about files or directories, including size, type, and permissions, to analyze file system contents and properties.

Instructions

Get detailed information about a file or directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe file or directory path to get info about

Implementation Reference

  • The handler for the 'get_file_info' tool. It validates the input path using FileInfoArgsSchema, resolves it safely, retrieves file/directory stats using fs.stat, optionally lists directory contents, formats the information including size, timestamps, permissions, and returns it as formatted text content.
    case "get_file_info": {
      const { path: targetPath } = FileInfoArgsSchema.parse(args);
      const safePath = validatePath(targetPath);
      
      const stats = await fs.stat(safePath);
      const isDirectory = stats.isDirectory();
      
      let additionalInfo = "";
      if (isDirectory) {
        try {
          const entries = await fs.readdir(safePath);
          additionalInfo = `\nContains: ${entries.length} items`;
        } catch (error) {
          additionalInfo = "\nUnable to read directory contents";
        }
      }
    
      return {
        content: [
          {
            type: "text",
            text: `Path: ${safePath}\n` +
                  `Type: ${isDirectory ? 'Directory' : 'File'}\n` +
                  `Size: ${formatFileSize(stats.size)}\n` +
                  `Created: ${stats.birthtime.toLocaleString()}\n` +
                  `Modified: ${stats.mtime.toLocaleString()}\n` +
                  `Accessed: ${stats.atime.toLocaleString()}\n` +
                  `Permissions: ${stats.mode.toString(8)}${additionalInfo}`
          }
        ]
      };
    }
  • Zod schema used for input validation in the get_file_info handler.
    const FileInfoArgsSchema = z.object({
      path: z.string().describe("The file or directory path to get info about")
    });
  • src/index.ts:172-185 (registration)
    Tool registration in the ListToolsRequestHandler response, defining name, description, and input schema.
    {
      name: "get_file_info",
      description: "Get detailed information about a file or directory",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "The file or directory path to get info about"
          }
        },
        required: ["path"]
      }
    },
  • Helper function to safely resolve paths, used in get_file_info handler to prevent directory traversal.
    function validatePath(inputPath: string): string {
      // Resolve the path to prevent directory traversal
      const resolved = path.resolve(inputPath);
      
      // For security, you might want to restrict to certain directories
      // This is a basic example - in production, implement proper access controls
      
      return resolved;
    }
  • Helper function to format file sizes in human-readable format, used in the get_file_info response.
    function formatFileSize(bytes: number): string {
      const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
      if (bytes === 0) return '0 B';
      const i = Math.floor(Math.log(bytes) / Math.log(1024));
      return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
    }
Behavior2/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 states the action ('Get detailed information') but doesn't specify what information is returned (e.g., metadata, permissions, size), whether it's read-only (implied but not stated), or any constraints like rate limits or authentication needs. This leaves significant gaps for a tool with no structured safety hints.

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 without unnecessary words. It could be slightly more structured by hinting at return values, but it earns its place by being direct and clear, with no wasted verbiage.

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 nested objects) and high schema coverage, the description is minimally adequate. However, with no output schema and no annotations, it should ideally explain what 'detailed information' includes to compensate. It meets the basic threshold but lacks depth for full contextual understanding.

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?

The input schema has 100% description coverage, with the 'path' parameter clearly documented. The description adds no additional parameter details beyond what the schema provides, such as path format examples or constraints. Since the schema does the heavy lifting, 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 verb ('Get') and resource ('detailed information about a file or directory'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_directory' (which might list contents) or 'search_files' (which might search across files), so it doesn't reach the highest score.

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 like 'list_directory' or 'search_files'. It doesn't mention prerequisites, such as needing a valid path, or clarify if it works for both files and directories, leaving usage context implied rather than explicit.

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/akshat12000/FileSystem-MCPServer'

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