Skip to main content
Glama
ai-yliu

Filesystem MCP Server

by ai-yliu

list_directory

Browse and view contents of directories by listing files and folders with clear type indicators for easy navigation.

Instructions

List directory contents with [FILE] or [DIR] prefixes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the directory to list

Implementation Reference

  • The handler for the 'list_directory' tool. It validates the path, reads the directory contents, stats each entry to determine if it's a file or directory, formats with [DIR] or [FILE] prefixes, and returns the list as text.
    case 'list_directory': {
      const { path: dirPath } = request.params.arguments as { path: string };
      validatePath(dirPath);
      
      const entries = await fs.readdir(dirPath);
      const formattedEntries = await Promise.all(
        entries.map(async (entry) => {
          const entryPath = path.join(dirPath, entry);
          const stats = await fs.stat(entryPath);
          const prefix = stats.isDirectory() ? '[DIR]' : '[FILE]';
          return `${prefix} ${entry}`;
        })
      );
      
      return {
        content: [
          {
            type: 'text',
            text: formattedEntries.join('\n'),
          },
        ],
      };
    }
  • src/index.ts:158-171 (registration)
    Registration of the 'list_directory' tool in the list of tools provided by ListToolsRequestSchema, including its name, description, and input schema.
    {
      name: 'list_directory',
      description: 'List directory contents with [FILE] or [DIR] prefixes',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the directory to list',
          },
        },
        required: ['path'],
      },
    },
  • The input schema definition for the 'list_directory' tool, specifying the required 'path' parameter.
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'Path to the directory 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 mentions that items are prefixed with '[FILE]' or '[DIR]', which adds some context about output format. However, it fails to disclose critical behaviors such as error handling (e.g., what happens if the path doesn't exist), permissions required, or whether the operation is read-only (implied but not stated). This leaves significant gaps for a tool that interacts with a filesystem.

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 extremely concise—a single sentence that efficiently conveys the core functionality and output format. Every word earns its place, with no redundant information or fluff, making it easy for an agent 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?

Given the complexity of filesystem operations and the lack of annotations and output schema, the description is incomplete. It doesn't explain return values (beyond the prefixes), error conditions, or behavioral traits like safety or side effects. For a tool with no structured safety hints, this leaves the agent under-informed about critical operational aspects.

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 information about the parameter beyond what the schema provides (e.g., no examples of valid paths or constraints). Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 verb ('List') and resource ('directory contents'), specifying what the tool does. It distinguishes itself from siblings like 'get_file_info' or 'search_files' by focusing on listing contents rather than retrieving metadata or searching. However, it doesn't explicitly differentiate from 'list_allowed_directories', which might have overlapping functionality.

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 'list_allowed_directories' or 'search_files'. It lacks context on prerequisites (e.g., directory existence), exclusions, or specific scenarios where this tool is preferred, leaving the agent to infer usage from the name 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/ai-yliu/filesystem-mcp-server'

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