Skip to main content
Glama
modelcontextprotocol

Filesystem MCP Server

Official

Get File Info

get_file_info
Read-only

Retrieve detailed metadata about a file or directory: size, creation and modification times, permissions, and type. No content reading required.

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 handler function that executes the get_file_info tool logic - validates the path, calls getFileStats, formats the result as text, and returns it.
      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 for input validation of get_file_info - defines 'path' as a required string.
    const GetFileInfoArgsSchema = z.object({
      path: z.string(),
    });
  • Registration of the 'get_file_info' tool with the MCP server, including title, description, input/output schemas, and readOnlyHint annotation.
    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 }
        };
      }
    );
  • The getFileStats helper function that uses fs.stat to retrieve file metadata (size, created, modified, accessed, isDirectory, isFile, permissions).
    export 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),
      };
    }
  • The FileInfo interface defining the shape of data returned by getFileStats.
    interface FileInfo {
      size: number;
      created: Date;
      modified: Date;
      accessed: Date;
      isDirectory: boolean;
      isFile: boolean;
      permissions: string;
    }
Behavior4/5

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

Annotations already mark readOnlyHint=true. Description adds detail on return fields (size, creation time, etc.) and the constraint 'Only works within allowed directories'. No contradictions. Does not specify error handling but acceptable for metadata retrieval.

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?

Three sentences, each adding value: action+output, listed properties, and usage guidance+constraint. No wasted words, front-loaded with key information.

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?

Has output schema so return values need not be described. Covers purpose, usage hint, and constraint. Missing error behavior (e.g., non-existent path), but overall complete for a simple metadata tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has one parameter 'path' with 0% description coverage. Description implicitly clarifies it's a file/directory path, adding meaning beyond the bare schema. Simple parameter, so description compensates well.

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?

Description clearly states it retrieves metadata for files/directories, listing specific properties (size, timestamps, permissions, type). It distinguishes from siblings by emphasizing 'without reading the actual content', contrasting with read tools like read_file.

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?

States it's 'perfect for understanding file characteristics without reading the actual content', guiding when to use. Implicitly suggests not for content retrieval. Notes restriction to allowed directories. Lacks explicit alternatives but provides sufficient context.

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