Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

get_file_info

Retrieve file metadata including size, timestamps, permissions, and type for analysis within Claude Desktop Commander's allowed directories.

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
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The core handler function that validates the file path security and retrieves file/directory stats including size, timestamps, type, and 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),
        };
    }
  • Zod schema for input validation of the get_file_info tool, 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, defining name, description, and input schema for get_file_info.
    {
      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)
    Dispatcher case in CallToolRequestHandler that parses input, calls getFileInfo handler, and formats the 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') 
        }],
      };
    }

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/StrawHatAI/claude-dev-tools'

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