Skip to main content
Glama
gabrielmaialva33

MCP Filesystem Server

get_file_info

Retrieve detailed metadata for files or directories, including size, permissions, and timestamps. Understand file characteristics without accessing content. Works within predefined secure directory paths.

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

  • The handler implementation for the 'get_file_info' tool. It parses input arguments using the schema, validates the path against allowed directories, retrieves file stats using the getFileStats helper, and returns formatted metadata as text.
    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'),
          },
        ],
      }
    }
  • Zod schema defining the input parameters for the get_file_info tool, requiring a 'path' string.
    const GetFileInfoArgsSchema = z.object({
      path: z.string().describe('Path to the file or directory to get information about'),
    })
  • src/index.ts:317-324 (registration)
    Registration of the get_file_info tool in the list_tools response, including name, description, and input schema.
      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,
    },
  • Helper function that fetches and formats detailed file system stats for a given path, returning size, timestamps, type flags, and permissions.
    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),
      }
    }
Behavior3/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 mentions the tool is read-only ('without reading the actual content') and includes a constraint ('Only works within allowed directories'), which adds useful context. However, it lacks details on error handling, permissions needed, or rate limits, leaving gaps for a tool that interacts with file systems.

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 value: detailing returned information, clarifying use case, and specifying constraints. There is no wasted text, making it efficient and easy to parse.

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 moderate complexity (file system interaction) and no output schema, the description provides a good overview of what information is returned and usage constraints. However, it lacks details on output format, error cases, or dependencies on other tools like list_allowed_directories, which could enhance completeness for an AI agent.

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 does not add any additional meaning beyond the schema, such as format examples or constraints on the path. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

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 verb ('Retrieve') and resource ('detailed metadata about a file or directory'), distinguishing it from siblings like read_file (which reads content) and list_directory (which lists contents). It specifies the type of information returned (size, creation time, etc.), making the purpose specific and 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'), which helps differentiate it from tools like read_file. However, it does not explicitly name alternatives or specify when not to use it, such as comparing to list_directory for directory contents versus metadata.

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

Related 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/gabrielmaialva33/mcp-filesystem'

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