Skip to main content
Glama
anyrxo
by anyrxo

get_file_info

Retrieve detailed metadata about a file or folder stored in Proton Drive, including path, type, and other attributes, using the Model Context Protocol server.

Instructions

Get information about a file or folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file or folder

Implementation Reference

  • The main handler function for the 'get_file_info' tool. It validates the input path, retrieves file or directory stats using fs.promises.stat, constructs an info object with path, name, type, size (raw and formatted), and timestamps, then returns it as JSON-formatted text content. Errors are handled with McpError.
    case 'get_file_info': { const infoPath = validatePath(args?.path as string); try { const stats = await stat(infoPath); const relativePath = getRelativePath(infoPath); const info = { path: relativePath, name: basename(infoPath), type: stats.isDirectory() ? 'folder' : 'file', size: stats.size, sizeFormatted: formatBytes(stats.size), created: stats.birthtime.toISOString(), modified: stats.mtime.toISOString(), accessed: stats.atime.toISOString(), }; return { content: [ { type: 'text', text: JSON.stringify(info, null, 2), }, ], }; } catch (error: any) { throw new McpError( ErrorCode.InternalError, `Cannot get file info: ${error.message}` ); } }
  • The input schema definition for the 'get_file_info' tool, specifying an object with a required 'path' string property.
    inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file or folder' }, }, required: ['path'], },
  • src/index.ts:205-218 (registration)
    The tool registration object for 'get_file_info' returned in the ListTools response, including name, description, and input schema.
    { name: 'get_file_info', description: 'Get information about a file or folder', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file or folder' }, }, required: ['path'], }, },
  • Helper utility function to format file size in human-readable units (Bytes, KB, MB, etc.), specifically used in the get_file_info handler to format the size field.
    function formatBytes(bytes: number): string { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }

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/anyrxo/proton-drive-mcp'

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