Skip to main content
Glama

get_file_info

Retrieve file or directory metadata, including size, type, permissions, creation, and modification times, to analyze file characteristics without accessing content. Works within permitted directories.

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

Implementation Reference

  • The handler function for the 'get_file_info' tool. Parses input arguments using the schema, validates the file path, retrieves file statistics using getFileStats utility, and returns formatted metadata as text.
    export async function handleGetFileInfo( args: unknown, allowedDirectories: string[], symlinksMap: Map<string, string>, noFollowSymlinks: boolean ) { const parsed = parseArgs(GetFileInfoArgsSchema, args, 'get_file_info'); const validPath = await validatePath(parsed.path, allowedDirectories, symlinksMap, noFollowSymlinks); const info = await getFileStats(validPath); return { content: [{ type: "text", text: Object.entries(info) .map(([key, value]) => `${key}: ${value}`) .join("\n") }], }; }
  • TypeBox schema definition for GetFileInfoArgs, which requires a 'path' string parameter.
    export const GetFileInfoArgsSchema = Type.Object({ path: Type.String(), }); export type GetFileInfoArgs = Static<typeof GetFileInfoArgsSchema>;
  • index.ts:245-246 (registration)
    Registers the 'get_file_info' tool handler in the toolHandlers object, binding it to FastMCP execution with server context.
    get_file_info: (a: unknown) => handleGetFileInfo(a, allowedDirectories, symlinksMap, noFollowSymlinks),
  • index.ts:311-311 (registration)
    Declares the tool metadata (name and description) in the allTools array used for conditional registration based on permissions.
    { name: "get_file_info", description: "Get file metadata" },
  • Utility function that retrieves and formats file statistics (size, dates, type, permissions) using fs.stat, used by the handler.
    export async function getFileStats(filePath: string): Promise<ImmutableFileInfo> { const stats = await fsPromises.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), }; }

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/rawr-ai/mcp-filesystem'

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