Skip to main content
Glama
koopatroopa787

MCP PC Control Server

list_directory

Retrieve a detailed listing of files and directories in a specified path, including names, types, sizes, and modification times to understand directory structure and locate files.

Instructions

Get a detailed listing of all files and directories in a specified path. Results include names, types (file/directory), sizes, and modification times. Useful for understanding directory structure and finding files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe path of the directory to list

Implementation Reference

  • The handler function that executes the 'list_directory' tool. It reads the directory contents using fs.readdir, gets stats for each entry, and returns a JSON-formatted list of items with name, type, size, and modification time.
    case "list_directory": {
      const dirPath = args.path as string;
      const entries = await fs.readdir(dirPath, { withFileTypes: true });
    
      const items = await Promise.all(
        entries.map(async (entry) => {
          const fullPath = path.join(dirPath, entry.name);
          const stats = await fs.stat(fullPath);
          return {
            name: entry.name,
            type: entry.isDirectory() ? "directory" : "file",
            size: stats.size,
            modified: stats.mtime.toISOString(),
          };
        })
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(items, null, 2),
          },
        ],
      };
    }
  • The tool definition including name, description, and input schema for 'list_directory', which specifies the required 'path' parameter.
    {
      name: "list_directory",
      description: "Get a detailed listing of all files and directories in a specified path. Results include names, types (file/directory), sizes, and modification times. Useful for understanding directory structure and finding files.",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "The path of the directory to list",
          },
        },
        required: ["path"],
      },
    },
  • src/index.ts:261-263 (registration)
    The handler for ListToolsRequestSchema that returns the TOOLS array, which includes the 'list_directory' tool registration.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools: TOOLS };
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden. It describes the behavior (listing files/directories with specific metadata) and output format, but doesn't disclose important traits like whether it requires specific permissions, handles symbolic links, has pagination for large directories, or error conditions (e.g., invalid paths). The description adds value but leaves gaps.

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 appropriately sized (two sentences) and front-loaded with the core purpose. Every sentence earns its place: the first states what the tool does and what information it returns, the second provides usage context. Zero waste.

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 (directory listing with metadata), no annotations, and no output schema, the description is adequate but has clear gaps. It explains the purpose and output format well, but lacks details on behavioral traits (permissions, error handling, etc.) that would be needed for robust use. It's complete enough for basic understanding but not for full operational context.

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?

Schema description coverage is 100% (the single parameter 'path' is fully documented in the schema as 'The path of the directory to list'), so the baseline is 3. The description adds no additional parameter semantics beyond what the schema already provides, but doesn't need to compensate for gaps.

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

Purpose5/5

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

The description clearly states the specific verb ('Get a detailed listing') and resource ('files and directories in a specified path'), distinguishing it from siblings like 'search_files' (which filters) or 'get_file_info' (which gets metadata for a single file). It explicitly mentions what information is included in results.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Useful for understanding directory structure and finding files'), which implicitly differentiates it from siblings like 'search_files' (which is for searching with criteria) or 'get_file_info' (which is for single files). However, it doesn't explicitly state when NOT to use it or name 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

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/koopatroopa787/first_mcp'

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