Skip to main content
Glama

list_directory

Browse and view the contents of directories in your notes system to locate files and folders. Specify a relative path to explore specific note collections.

Instructions

List the contents of a directory in your notes. Shows all files and directories with clear labels. Specify path relative to your notes directory (e.g., 'Log' or 'Rollups').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoDirectory path relative to notes directory (defaults to root notes directory if not provided)

Implementation Reference

  • The handler function that implements the list_directory tool logic: reads the directory using fs.readdir, formats entries with [DIR]/[FILE] prefixes, ensures path security, and returns formatted content.
    export async function handleListDirectory(notesPath: string, args: ListDirectoryArgs): Promise<ToolCallResult> {
      try {
        // Use provided path or default to NOTES_PATH root
        const dirPath = args.path ? path.join(notesPath, args.path) : notesPath;
        
        // Ensure the path is within allowed directory
        if (!dirPath.startsWith(notesPath)) {
          throw new Error("Access denied - path outside notes directory");
        }
        
        try {
          const entries = await fs.readdir(dirPath, { withFileTypes: true });
          const formatted = entries
            .map((entry) => `${entry.isDirectory() ? "[DIR]" : "[FILE]"} ${entry.name}`)
            .join("\n");
            
          const relativePath = path.relative(notesPath, dirPath) || '.';
          
          return {
            content: [{ 
              type: "text", 
              text: `Contents of ${relativePath}:\n\n${formatted || "No files or directories found."}` 
            }]
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          throw new Error(`Error reading directory: ${errorMessage}`);
        }
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [{ type: "text", text: `Error listing directory: ${errorMessage}` }],
          isError: true
        };
      }
  • Tool definition including name, description, and input schema (optional 'path' parameter) for the list_directory tool, exported via getFilesystemToolDefinitions().
    {
      name: "list_directory",
      description: "List the contents of a directory in your notes. " +
        "Shows all files and directories with clear labels. " +
        "Specify path relative to your notes directory (e.g., 'Log' or 'Rollups').",
      inputSchema: {
        type: "object",
        properties: {
          path: { 
            type: "string",
            description: "Directory path relative to notes directory (defaults to root notes directory if not provided)",
            default: ""
          }
        }
      },
    },
  • TypeScript interface defining the input arguments for the list_directory handler.
    interface ListDirectoryArgs {
      path?: string;
    }
  • Registration in the main handleToolCall switch statement, dispatching list_directory calls to the handler.
    case "list_directory":
      return await handleListDirectory(notesPath, args);
  • Includes filesystem tools (containing list_directory definition) in the main getToolDefinitions() array for tool registration.
    ...filesystemTools
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 of behavioral disclosure. It describes the output ('Shows all files and directories with clear labels') and the path handling, but lacks details on permissions, error handling, or format specifics. This is adequate but has gaps for a tool with no annotations.

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 front-loaded with the core purpose in the first sentence, followed by essential details in two concise sentences. Every sentence adds value without redundancy, making it efficiently structured and easy to parse.

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

Completeness4/5

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

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is mostly complete, covering purpose, usage, and output behavior. However, it lacks explicit error cases or return format details, which slightly reduces completeness for a tool with no structured output schema.

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, so the schema already documents the 'path' parameter thoroughly. The description adds minimal value by reiterating the path specification with examples, but does not provide additional syntax or constraints beyond what the schema states, meeting the baseline for high schema coverage.

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 action ('List the contents of a directory') and resource ('in your notes'), distinguishing it from sibling tools like read_note or search_files. It specifies what is shown ('all files and directories with clear labels'), making the purpose explicit and differentiated.

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 ('Specify path relative to your notes directory') and implies usage for browsing directory contents. However, it does not explicitly state when not to use it or name alternatives like search_files for filtering, which prevents a perfect score.

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/mikeysrecipes/mcp-notes'

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