get_file_info
Retrieve file metadata including size, timestamps, type, and permissions without reading file contents. Use this tool to inspect file details on your PC.
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 function for get_file_info tool that retrieves file stats using fs.stat and returns formatted JSON with file metadata including type, size, timestamps, and 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 (schema)Tool schema definition including name, description, and input schema requiring a 'path' parameter.{ 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"], }, },
- src/index.ts:261-263 (registration)Registration of listTools handler that returns the TOOLS array containing get_file_info.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS }; });