get_file_info
Retrieve details about Proton Drive files and folders, including metadata and properties, by specifying the file path.
Instructions
Get information about a file or folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file or folder |
Implementation Reference
- src/index.ts:412-444 (handler)The handler logic for the 'get_file_info' tool, which validates the path, retrieves file stats, formats the information, and returns it as JSON.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}` ); } }
- src/index.ts:208-217 (schema)The input schema definition for the 'get_file_info' tool, specifying a required 'path' parameter.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 in the ListTools response, including name, description, and 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'], }, },
- src/index.ts:467-475 (helper)Helper function to format file size in human-readable bytes, used in get_file_info.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]; }