Skip to main content
Glama
rawr-ai

Filesystem MCP Server

list_directory

Retrieve detailed file and directory listings from a specified path, using [FILE] and [DIR] prefixes for clear differentiation. Essential for analyzing directory structures and locating specific files within permitted directories.

Instructions

Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The main handler function for list_directory tool. Parses arguments, validates path, reads directory contents using fs.readdir, formats as [DIR]/[FILE] list, and returns as text content.
    export async function handleListDirectory(
      args: unknown,
      allowedDirectories: string[],
      symlinksMap: Map<string, string>,
      noFollowSymlinks: boolean
    ) {
      const parsed = parseArgs(ListDirectoryArgsSchema, args, 'list_directory');
      const validPath = await validatePath(parsed.path, allowedDirectories, symlinksMap, noFollowSymlinks);
      const entries = await fs.readdir(validPath, { withFileTypes: true });
      const formatted = entries
        .map((entry) => `${entry.isDirectory() ? "[DIR]" : "[FILE]"} ${entry.name}`)
        .join("\n");
      return {
        content: [{ type: "text", text: formatted }],
      };
    }
  • Input schema definition for list_directory: requires a 'path' string parameter.
    export const ListDirectoryArgsSchema = Type.Object({
      path: Type.String(),
    });
    export type ListDirectoryArgs = Static<typeof ListDirectoryArgsSchema>;
  • index.ts:208-209 (registration)
    Registers the list_directory tool handler by binding the handleListDirectory function with context parameters in the toolHandlers object.
    list_directory: (a: unknown) =>
      handleListDirectory(a, allowedDirectories, symlinksMap, noFollowSymlinks),
  • index.ts:307-307 (registration)
    Declares the list_directory tool metadata (name and description) in the allTools array, used for conditional registration based on permissions.
    { name: "list_directory", description: "List directory contents" },
  • Maps the ListDirectoryArgsSchema to the 'list_directory' key in the central toolSchemas export, making it available for registration.
    list_directory: ListDirectoryArgsSchema,
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: it lists files and directories with [FILE] and [DIR] prefixes, and it only works within allowed directories. However, it doesn't mention potential side effects (e.g., read-only, no mutations), error handling, rate limits, or output format details beyond the prefixes. For a tool with no annotations, this adds some context but leaves gaps in behavioral transparency.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by details on output format and usage context. Each sentence adds value (e.g., prefixes, allowed directories), with minimal redundancy. It could be slightly more concise by merging some clauses, but overall it's efficient and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (1 parameter, no annotations, no output schema), the description is somewhat complete but has gaps. It covers the basic operation, output format hints, and access restrictions, but lacks details on error cases, pagination, or exact return structure. Without an output schema, more information on what the listing includes (e.g., file sizes, timestamps) would be helpful. It's adequate but not fully comprehensive.

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

Parameters4/5

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

The input schema has 1 parameter with 0% description coverage, so the description must compensate. It adds meaning by specifying that the 'path' parameter is for a 'specified path' to list files and directories, and implies it must be within allowed directories. This clarifies the parameter's purpose beyond the bare schema, though it doesn't detail path format or constraints. With low schema coverage, the description does a good job of adding semantic value.

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 tool's purpose: 'Get a detailed listing of all files and directories in a specified path.' It specifies the verb ('Get'), resource ('files and directories'), and scope ('in a specified path'), though it doesn't explicitly differentiate from siblings like 'directory_tree' or 'search_files' beyond mentioning it's for 'understanding directory structure and finding specific files.' This makes it clear but not fully sibling-distinctive.

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

Usage Guidelines3/5

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

The description provides some implied usage context: 'This tool is essential for understanding directory structure and finding specific files within a directory' and 'Only works within allowed directories.' However, it doesn't explicitly state when to use this tool versus alternatives like 'directory_tree' (which might show a tree structure) or 'search_files' (which might filter content), nor does it mention prerequisites or exclusions beyond the allowed directories note. This offers basic guidance but lacks explicit alternatives.

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

Related 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/rawr-ai/mcp-filesystem'

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