fs_get_file_info
Retrieve detailed file or directory information including size, permissions, and timestamps for development environment analysis.
Instructions
Get detailed information about a file or directory (size, permissions, timestamps, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute or relative path to the file or directory |
Implementation Reference
- src/tools/filesystem.ts:345-384 (handler)The handler function that implements the core logic for 'fs_get_file_info', using fs.stat and fs.realpath to fetch file stats and returning formatted JSON response.export async function getFileInfo(args: z.infer<typeof getFileInfoSchema>): Promise<ToolResponse> { try { const stats = await fs.stat(args.path); const realPath = await fs.realpath(args.path); return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, path: args.path, realPath: realPath, type: stats.isDirectory() ? 'directory' : stats.isSymbolicLink() ? 'symlink' : 'file', size: stats.size, created: stats.birthtime, modified: stats.mtime, accessed: stats.atime, permissions: stats.mode.toString(8), uid: stats.uid, gid: stats.gid }, null, 2) } ] }; } catch (error) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : String(error) }, null, 2) } ], isError: true }; } }
- src/tools/filesystem.ts:51-53 (schema)Zod input validation schema used for parsing arguments before calling the handler.export const getFileInfoSchema = z.object({ path: z.string().describe('Absolute or relative path to the file or directory') });
- src/index.ts:333-336 (registration)Registration and dispatch in the main MCP CallToolRequest handler, matching tool name and invoking the validated handler.if (name === 'fs_get_file_info') { const validated = getFileInfoSchema.parse(args); return await getFileInfo(validated); }
- src/tools/filesystem.ts:604-617 (schema)MCP tool metadata definition including JSON inputSchema, used for tool listing and discovery.{ name: 'fs_get_file_info', description: 'Get detailed information about a file or directory (size, permissions, timestamps, etc.)', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Absolute or relative path to the file or directory' } }, required: ['path'] } },