Skip to main content
Glama
lofcz

MCP Smart Filesystem Server

by lofcz

get_file_info

Retrieve file metadata like size and line count without accessing file contents. Helps determine optimal reading strategies for large files by analyzing file characteristics first.

Instructions

Get file metadata without reading contents. Useful to check size/line count before reading. For large files, provides reading strategy recommendations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path to get info about

Implementation Reference

  • Main handler for 'get_file_info' tool. Validates input, retrieves file stats, detects if binary, identifies language, counts lines, and provides reading strategy for large files using imported helpers.
    case 'get_file_info': { const schema = z.object({ path: z.string() }); const { path } = schema.parse(args); const validatedPath = await validatePath(path); const stats = await getFileStats(validatedPath); const isBinary = await isBinaryFile(validatedPath); const language = detectLanguage(validatedPath); let lines: number | undefined; let readingStrategy: any = undefined; if (!isBinary && stats.isFile) { try { const content = await readFileContent(validatedPath); lines = countLines(content); if (shouldPaginate(lines)) { readingStrategy = { recommendation: `File is large (${lines} lines). Suggested approach:`, options: generateReadingSuggestions(lines) }; } } catch { // Ignore read errors } } return { content: [{ type: 'text', text: JSON.stringify({ path: validatedPath, size: { bytes: stats.size, readable: `${stats.size} bytes` }, lines, type: stats.isDirectory ? 'directory' : 'file', language, isBinary, lastModified: stats.modified.toISOString(), permissions: stats.permissions, readingStrategy }, null, 2) }] }; }
  • index.ts:235-248 (registration)
    Registration of the 'get_file_info' tool in the tools array, including name, description, and input schema definition.
    { name: 'get_file_info', description: 'Get file metadata without reading contents. Useful to check size/line count before reading. For large files, provides reading strategy recommendations.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File path to get info about' } }, required: ['path'] } },
  • Input schema definition for the 'get_file_info' tool.
    inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File path to get info about' } }, required: ['path'] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lofcz/mcp-filesystem-smart'

If you have feedback or need assistance with the MCP directory API, please join our Discord server