Skip to main content
Glama
A-Niranjan

MCP Filesystem Server

by A-Niranjan

get_file_info

Retrieve file metadata including size, timestamps, permissions, and type to understand file characteristics without reading 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
pathYesPath to the file or directory to get information about

Implementation Reference

  • Input schema definition for the get_file_info tool using Zod.
    const GetFileInfoArgsSchema = z.object({ path: z.string().describe('Path to the file or directory to get information about'), })
  • src/index.ts:316-324 (registration)
    Tool registration in the list_tools response, including name, description, and input schema reference.
    { 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, },
  • Main handler logic in the tool call switch statement: validates input, checks path, gets stats using getFileStats, formats and returns file info.
    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'), }, ], } }
  • Helper function that retrieves detailed file statistics using fs.stat and formats into FileInfo object.
    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), } }

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/A-Niranjan/mcp-filesystem'

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