Skip to main content
Glama
A-Niranjan

MCP Filesystem Server

by A-Niranjan

get_file_info

Retrieve file metadata including size, timestamps, permissions, and type to understand file characteristics without reading content.

Instructions

Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file or directory to get information about

Implementation Reference

  • Input schema definition for the get_file_info tool using Zod.
    const GetFileInfoArgsSchema = z.object({
      path: z.string().describe('Path to the file or directory to get information about'),
    })
  • src/index.ts:316-324 (registration)
    Tool registration in the list_tools response, including name, description, and input schema reference.
    {
      name: 'get_file_info',
      description:
        'Retrieve detailed metadata about a file or directory. Returns comprehensive ' +
        'information including size, creation time, last modified time, permissions, ' +
        'and type. This tool is perfect for understanding file characteristics ' +
        'without reading the actual content. Only works within allowed directories.',
      inputSchema: zodToJsonSchema(GetFileInfoArgsSchema) as ToolInput,
    },
  • Main handler logic in the tool call switch statement: validates input, checks path, gets stats using getFileStats, formats and returns file info.
    case 'get_file_info': {
      const parsed = GetFileInfoArgsSchema.safeParse(a)
      if (!parsed.success) {
        throw new FileSystemError(`Invalid arguments for ${name}`, 'INVALID_ARGS', undefined, {
          errors: parsed.error.format(),
        })
      }
    
      const validPath = await validatePath(parsed.data.path, config)
      const info = await getFileStats(validPath)
      await logger.debug(`Retrieved file info: ${validPath}`)
    
      endMetric()
      return {
        content: [
          {
            type: 'text',
            text: Object.entries(info)
              .map(([key, value]) => `${key}: ${value}`)
              .join('\n'),
          },
        ],
      }
    }
  • Helper function that retrieves detailed file statistics using fs.stat and formats into FileInfo object.
    async function getFileStats(filePath: string): Promise<FileInfo> {
      const stats = await fs.stat(filePath)
      return {
        size: stats.size,
        created: stats.birthtime,
        modified: stats.mtime,
        accessed: stats.atime,
        isDirectory: stats.isDirectory(),
        isFile: stats.isFile(),
        permissions: stats.mode.toString(8).slice(-3),
      }
    }
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 (implied by 'retrieve' and 'without reading the actual content'), returns comprehensive metadata, and has a scope limitation ('Only works within allowed directories'). It lacks details on error handling or performance, but covers the essential behavior well.

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 appropriately sized and front-loaded, with the first sentence stating the core purpose. Each subsequent sentence adds valuable information (what's returned, when to use, constraints) without redundancy. There is no wasted text, making it highly efficient.

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?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is largely complete. It explains the purpose, usage, and constraints effectively. However, without an output schema, it could benefit from more detail on the return format (e.g., structure of the metadata), which slightly limits completeness.

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 fully documented in the schema. The description does not add any additional meaning or context beyond what the schema provides (e.g., format examples or constraints like path syntax), so it meets the baseline score of 3 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 ('retrieve detailed metadata') and resource ('file or directory'), distinguishing it from siblings like read_file (which reads content) or list_directory (which lists contents). It explicitly mentions what information is returned (size, creation time, etc.), making the purpose unambiguous.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('for understanding file characteristics without reading the actual content') and includes a constraint ('Only works within allowed directories'). However, it does not explicitly mention when not to use it or name specific alternatives (e.g., list_directory for directory listings vs. metadata), which prevents a perfect score.

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/A-Niranjan/mcp-filesystem'

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