get_file_info
Retrieve detailed metadata for files or directories, including size, permissions, and timestamps, within permitted paths using the MCP server integration.
Instructions
Retrieve detailed metadata about a file or directory including size, creation time, last modified time, permissions, and type. Only works within allowed directories.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/tools/filesystem.ts:137-150 (handler)The main handler function `getFileInfo` that validates the file path using `validatePath` and retrieves comprehensive file/directory metadata including size, birthtime, mtime, atime, directory/file flags, and octal permissions.export async function getFileInfo(filePath: string): Promise<Record<string, any>> { const validPath = await validatePath(filePath); const stats = await fs.stat(validPath); return { size: stats.size, created: stats.birthtime, modified: stats.mtime, accessed: stats.atime, isDirectory: stats.isDirectory(), isFile: stats.isFile(), permissions: stats.mode.toString(8).slice(-3), }; }
- src/tools/schemas.ts:63-65 (schema)Zod schema for tool input validation, requiring a single 'path' string parameter.export const GetFileInfoArgsSchema = z.object({ path: z.string(), });
- src/server.ts:180-187 (registration)Tool registration in the ListTools response: defines name, description, and converts Zod schema to JSON schema for input.{ name: "get_file_info", description: "Retrieve detailed metadata about a file or directory including size, " + "creation time, last modified time, permissions, and type. " + "Only works within allowed directories.", inputSchema: zodToJsonSchema(GetFileInfoArgsSchema), },
- src/server.ts:315-326 (registration)Dispatch handler in CallToolRequest switch statement: parses input args, calls the getFileInfo handler, and formats the result as a text response.case "get_file_info": { const parsed = GetFileInfoArgsSchema.parse(args); const info = await getFileInfo(parsed.path); return { content: [{ type: "text", text: Object.entries(info) .map(([key, value]) => `${key}: ${value}`) .join('\n') }], }; }