Skip to main content
Glama
akshat12000

File System Explorer MCP Server

by akshat12000

list_directory

View directory contents to explore file systems. This tool retrieves file and folder listings from specified paths for navigation and analysis.

Instructions

List the contents of a directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe directory path to list

Implementation Reference

  • The main execution logic for the list_directory tool within the CallToolRequestSchema handler. Parses arguments using the schema, validates and lists directory contents with file types, sizes, and modification times, formats output with icons.
    case "list_directory": {
      const { path: dirPath } = ListDirectoryArgsSchema.parse(args);
      const safePath = validatePath(dirPath);
      
      const entries = await fs.readdir(safePath, { withFileTypes: true });
      const items = await Promise.all(
        entries.map(async (entry) => {
          const fullPath = path.join(safePath, entry.name);
          try {
            const stats = await fs.stat(fullPath);
            return {
              name: entry.name,
              type: entry.isDirectory() ? 'directory' : 'file',
              size: entry.isFile() ? formatFileSize(stats.size) : null,
              modified: stats.mtime.toISOString()
            };
          } catch (error) {
            return {
              name: entry.name,
              type: entry.isDirectory() ? 'directory' : 'file',
              size: null,
              modified: null,
              error: 'Unable to read stats'
            };
          }
        })
      );
    
      return {
        content: [
          {
            type: "text",
            text: `Directory listing for: ${safePath}\n\n` +
                  items
                    .sort((a, b) => {
                      // Sort directories first, then files
                      if (a.type !== b.type) {
                        return a.type === 'directory' ? -1 : 1;
                      }
                      return a.name.localeCompare(b.name);
                    })
                    .map(item => {
                      const icon = item.type === 'directory' ? '📁' : '📄';
                      const size = item.size ? ` (${item.size})` : '';
                      const modified = item.modified ? 
                        ` - Modified: ${new Date(item.modified).toLocaleString()}` : '';
                      return `${icon} ${item.name}${size}${modified}`;
                    })
                    .join('\n')
          }
        ]
      };
    }
  • Zod schema defining the input validation for list_directory tool arguments, specifically the 'path' parameter.
    const ListDirectoryArgsSchema = z.object({
      path: z.string().describe("The directory path to list")
    });
  • src/index.ts:144-157 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema for list_directory.
    {
      name: "list_directory",
      description: "List the contents of a directory",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "The directory path to list"
          }
        },
        required: ["path"]
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the basic action but doesn't cover critical aspects like permissions needed, error handling (e.g., for invalid paths), output format, or whether it's read-only or has side effects. This is inadequate for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core purpose, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., list of filenames, metadata), error conditions, or behavioral nuances. This leaves significant gaps for an agent to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'path' parameter clearly documented. The description adds no additional semantic context beyond what the schema provides, such as path format examples or constraints. Given the high schema coverage, a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List') and resource ('contents of a directory'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'search_files' or 'get_file_info' which might also involve directory operations, so it lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_files' or 'get_file_info'. There's no mention of prerequisites, context, or exclusions, leaving the agent to infer usage based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/akshat12000/FileSystem-MCPServer'

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