Skip to main content
Glama
modelcontextprotocol

Filesystem MCP Server

Official

Get File Info

get_file_info
Read-only

Retrieve detailed metadata about files or directories, including size, timestamps, permissions, and type, to understand file characteristics without accessing 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
pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes

Implementation Reference

  • The main handler function for the get_file_info tool. It validates the input path, retrieves detailed file statistics using getFileStats, formats the info into a readable text string, and returns it in both content and structuredContent formats as required by MCP.
    async (args: z.infer<typeof GetFileInfoArgsSchema>) => {
      const validPath = await validatePath(args.path);
      const info = await getFileStats(validPath);
      const text = Object.entries(info)
        .map(([key, value]) => `${key}: ${value}`)
        .join("\n");
      return {
        content: [{ type: "text" as const, text }],
        structuredContent: { content: text }
      };
    }
  • Zod schema defining the input arguments for the get_file_info tool, specifically requiring a 'path' string.
    const GetFileInfoArgsSchema = z.object({
      path: z.string(),
    });
  • Registration of the get_file_info tool on the MCP server, including name, title, detailed description, input/output schemas, annotations indicating it's read-only, and reference to the handler function.
    server.registerTool(
      "get_file_info",
      {
        title: "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: {
          path: z.string()
        },
        outputSchema: { content: z.string() },
        annotations: { readOnlyHint: true }
      },
      async (args: z.infer<typeof GetFileInfoArgsSchema>) => {
        const validPath = await validatePath(args.path);
        const info = await getFileStats(validPath);
        const text = Object.entries(info)
          .map(([key, value]) => `${key}: ${value}`)
          .join("\n");
        return {
          content: [{ type: "text" as const, text }],
          structuredContent: { content: text }
        };
      }
    );
Behavior4/5

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

Annotations declare readOnlyHint=true, which the description aligns with by describing a retrieval operation. The description adds valuable context beyond annotations: it specifies the scope ('within allowed directories') and details the type of information returned (e.g., size, permissions), enhancing the agent's understanding of the tool's behavior without contradiction.

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, followed by key details and constraints in three concise sentences. Each sentence adds value: the first defines the action, the second lists return information, and the third sets usage boundaries, with no wasted words.

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

Completeness5/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 (one parameter), the presence of annotations (readOnlyHint), and an output schema (which handles return values), the description is complete. It covers purpose, usage context, and behavioral traits adequately, leaving no significant gaps for the agent to operate effectively.

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 0% description coverage for the single parameter 'path', and the description does not provide any additional details about this parameter (e.g., format, examples, or constraints). Since schema coverage is low, the description fails to compensate, but with only one parameter, the baseline is adjusted to 3 as the impact is minimal.

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 resources ('file or directory'), distinguishing it from siblings like read_file (content reading) or list_directory (listing). It explicitly mentions what information is returned, 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 compare to alternatives like list_directory or search_files, which could help differentiate usage scenarios more precisely.

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/modelcontextprotocol/filesystem'

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