Skip to main content
Glama
akshat12000

File System Explorer MCP Server

by akshat12000

get_file_info

Retrieve detailed metadata about files or directories including size, type, permissions, and modification dates to analyze file system contents.

Instructions

Get detailed information about a file or directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe file or directory path to get info about

Implementation Reference

  • The handler for the 'get_file_info' tool. It validates the input path, resolves it safely, fetches file stats, checks if it's a directory and counts contents if so, then returns formatted file information including path, type, size, timestamps, and permissions.
    case "get_file_info": { const { path: targetPath } = FileInfoArgsSchema.parse(args); const safePath = validatePath(targetPath); const stats = await fs.stat(safePath); const isDirectory = stats.isDirectory(); let additionalInfo = ""; if (isDirectory) { try { const entries = await fs.readdir(safePath); additionalInfo = `\nContains: ${entries.length} items`; } catch (error) { additionalInfo = "\nUnable to read directory contents"; } } return { content: [ { type: "text", text: `Path: ${safePath}\n` + `Type: ${isDirectory ? 'Directory' : 'File'}\n` + `Size: ${formatFileSize(stats.size)}\n` + `Created: ${stats.birthtime.toLocaleString()}\n` + `Modified: ${stats.mtime.toLocaleString()}\n` + `Accessed: ${stats.atime.toLocaleString()}\n` + `Permissions: ${stats.mode.toString(8)}${additionalInfo}` } ] }; }
  • Zod input validation schema for the 'get_file_info' tool, defining the required 'path' parameter.
    const FileInfoArgsSchema = z.object({ path: z.string().describe("The file or directory path to get info about") });
  • src/index.ts:172-185 (registration)
    Tool registration in the ListTools handler, providing name, description, and input schema for 'get_file_info'.
    { name: "get_file_info", description: "Get detailed information about a file or directory", inputSchema: { type: "object", properties: { path: { type: "string", description: "The file or directory path to get info about" } }, required: ["path"] } },

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/akshat12000/FileSystem-MCPServer'

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