Skip to main content
Glama
ai-yliu

Filesystem MCP Server

by ai-yliu

get_file_info

Retrieve metadata for files or directories, including details like size, type, and permissions, to analyze and manage filesystem content.

Instructions

Get detailed file/directory metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file or directory

Implementation Reference

  • Handler for the 'get_file_info' tool. Validates the path, retrieves file stats using fs.stat, formats the information using the formatFileInfo helper, and returns it as JSON-formatted text content.
    case 'get_file_info': { const { path: filePath } = request.params.arguments as { path: string }; validatePath(filePath); const stats = await fs.stat(filePath); const fileInfo = formatFileInfo(filePath, stats); return { content: [ { type: 'text', text: JSON.stringify(fileInfo, null, 2), }, ], }; }
  • src/index.ts:208-221 (registration)
    Tool registration in the listTools response, including name, description, and input schema definition.
    { name: 'get_file_info', description: 'Get detailed file/directory metadata', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file or directory', }, }, required: ['path'], }, },
  • Helper function that transforms fs.Stats object into a detailed file information object with path, size, type, timestamps, and permissions.
    function formatFileInfo(filePath: string, stats: Stats): Record<string, any> { return { path: filePath, size: stats.size, type: stats.isDirectory() ? 'directory' : 'file', created: stats.birthtime.toISOString(), modified: stats.mtime.toISOString(), accessed: stats.atime.toISOString(), permissions: { readable: stats.mode & fs.constants.R_OK ? true : false, writable: stats.mode & fs.constants.W_OK ? true : false, executable: stats.mode & fs.constants.X_OK ? true : false, } }; }

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

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