get_file_info
Retrieve file metadata including size, timestamps, type, and permissions without accessing file contents. Use to inspect file properties for system management and analysis.
Instructions
Retrieve detailed metadata about a file or directory, including size, creation time, modification time, access time, type, and permissions. This does not read file contents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The path to the file/directory |
Implementation Reference
- src/index.ts:427-455 (handler)Handler implementation for 'get_file_info' tool. Uses fs.stat to get file/directory stats and returns JSON metadata including path, type, size, timestamps, permissions.case "get_file_info": { const filePath = args.path as string; const stats = await fs.stat(filePath); const info = { path: filePath, type: stats.isDirectory() ? "directory" : stats.isFile() ? "file" : "other", size: stats.size, created: stats.birthtime.toISOString(), modified: stats.mtime.toISOString(), accessed: stats.atime.toISOString(), permissions: stats.mode.toString(8).slice(-3), isReadable: fsSync.constants.R_OK, isWritable: fsSync.constants.W_OK, }; return { content: [ { type: "text", text: JSON.stringify(info, null, 2), }, ], }; }
- src/index.ts:158-171 (registration)Tool registration in TOOLS array, defining name, description, and input schema for 'get_file_info' (used for listTools response).{ name: "get_file_info", description: "Retrieve detailed metadata about a file or directory, including size, creation time, modification time, access time, type, and permissions. This does not read file contents.", inputSchema: { type: "object", properties: { path: { type: "string", description: "The path to the file/directory", }, }, required: ["path"], }, },