fast_get_file_info
Retrieve detailed metadata for any file or directory, including size, type, and timestamps, to quickly assess file properties without opening them.
Instructions
Gets detailed information about a file or directory
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to get info for |
Implementation Reference
- api/server.ts:611-660 (handler)The actual handler function 'handleGetFileInfo' that executes the 'fast_get_file_info' tool logic. It resolves the path via safePath, reads file stats using fs.stat, and returns detailed file/directory info including path, name, type, size, timestamps, permissions, and for files: extension, MIME type, and chunking guide for large files; for directories: item count and pagination guide.
async function handleGetFileInfo(args: any) { const { path: targetPath } = args; const safePath_resolved = safePath(targetPath); const stats = await fs.stat(safePath_resolved); const info = { path: safePath_resolved, name: path.basename(safePath_resolved), type: stats.isDirectory() ? 'directory' : 'file', size: stats.size, size_readable: formatSize(stats.size), created: stats.birthtime.toISOString(), modified: stats.mtime.toISOString(), accessed: stats.atime.toISOString(), permissions: stats.mode, is_readable: true, is_writable: true }; if (stats.isFile()) { (info as any).extension = path.extname(safePath_resolved); (info as any).mime_type = getMimeType(safePath_resolved); if (stats.size > CLAUDE_MAX_CHUNK_SIZE) { (info as any).claude_guide = { message: 'File is large, consider using chunked reading', recommended_chunk_size: CLAUDE_MAX_CHUNK_SIZE, total_chunks: Math.ceil(stats.size / CLAUDE_MAX_CHUNK_SIZE) }; } } else if (stats.isDirectory()) { try { const entries = await fs.readdir(safePath_resolved); (info as any).item_count = entries.length; if (entries.length > CLAUDE_MAX_DIR_ITEMS) { (info as any).claude_guide = { message: 'Directory has many items, consider using pagination', recommended_page_size: CLAUDE_MAX_DIR_ITEMS, total_pages: Math.ceil(entries.length / CLAUDE_MAX_DIR_ITEMS) }; } } catch { (info as any).item_count = 'Unable to count'; } } return info; } - api/server.ts:156-165 (schema)Input schema definition for the 'fast_get_file_info' tool. Defines that it accepts a single required 'path' parameter of type string.
name: 'fast_get_file_info', description: '파일/디렉토리 상세 정보를 조회합니다', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '조회할 경로' } }, required: ['path'] } }, - api/server.ts:332-334 (registration)Registration of 'fast_get_file_info' in the tools/call switch statement, routing to handleGetFileInfo handler.
case 'fast_get_file_info': result = await handleGetFileInfo(args); break; - api/server.ts:38-43 (helper)The 'safePath' helper function used to validate and resolve the input path, checking it against allowed directories.
function safePath(inputPath: string): string { if (!isPathAllowed(inputPath)) { throw new Error(`Access denied to path: ${inputPath}`); } return path.resolve(inputPath); } - api/server.ts:943-961 (helper)The 'getMimeType' helper function used to determine MIME type based on file extension.
function getMimeType(filePath: string): string { const ext = path.extname(filePath).toLowerCase(); const mimeTypes: {[key: string]: string} = { '.txt': 'text/plain', '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript', '.json': 'application/json', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.pdf': 'application/pdf', '.zip': 'application/zip', '.md': 'text/markdown' }; return mimeTypes[ext] || 'application/octet-stream'; }