Skip to main content
Glama
ai-yliu

Filesystem MCP Server

by ai-yliu

get_file_info

Retrieve detailed metadata for files or directories by specifying their paths. Provides essential information for filesystem operations within allowed paths.

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, formats the information using 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)
    Registration of the 'get_file_info' tool in the listTools handler, including name, description, and input schema.
    { 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 used by get_file_info to format fs.Stats into a readable 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, } }; }

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

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