Skip to main content
Glama

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), } }

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