Skip to main content
Glama
andredezzy

deep-filesystem-tree

get_deep_directory_tree

Generate a visual directory tree structure from a specified path with configurable depth and exclusion patterns to analyze file system organization.

Instructions

Get deep directory tree

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to get the directory tree (preferably absolute path)
optionsNoTree generation options

Implementation Reference

  • The tool handler function that invokes getDirectoryTree with the provided path and options, then returns the directory structure as text content.
    async ({ path, options }) => {
      const directoryStructure = getDirectoryTree(path, options);
    
      return {
        content: [
          {
            type: "text",
            text: directoryStructure,
          },
        ],
      };
    }
  • Zod schema defining the input parameters: path (string) and options (object with depth and excludePatterns).
    {
      path: z
        .string()
        .describe("Path to get the directory tree (preferably absolute path)"),
      options: z
        .object({
          depth: z.number().default(3).describe("Depth of the directory tree"),
          excludePatterns: z
            .array(z.string())
            .default(["node_modules", ".git", ".turbo", "dist", ".next"])
            .describe(
              "Patterns to exclude from the tree (e.g., ['node_modules', '*.log'])"
            ),
        })
        .default({
          depth: 3,
          excludePatterns: ["node_modules", ".git", ".turbo", "dist", ".next"],
        })
        .describe("Tree generation options"),
    },
  • src/index.ts:70-105 (registration)
    Registration of the 'get_deep_directory_tree' tool using mcp.tool(), including name, description, input schema, and handler function.
    mcp.tool(
      "get_deep_directory_tree",
      "Get deep directory tree",
      {
        path: z
          .string()
          .describe("Path to get the directory tree (preferably absolute path)"),
        options: z
          .object({
            depth: z.number().default(3).describe("Depth of the directory tree"),
            excludePatterns: z
              .array(z.string())
              .default(["node_modules", ".git", ".turbo", "dist", ".next"])
              .describe(
                "Patterns to exclude from the tree (e.g., ['node_modules', '*.log'])"
              ),
          })
          .default({
            depth: 3,
            excludePatterns: ["node_modules", ".git", ".turbo", "dist", ".next"],
          })
          .describe("Tree generation options"),
      },
      async ({ path, options }) => {
        const directoryStructure = getDirectoryTree(path, options);
    
        return {
          content: [
            {
              type: "text",
              text: directoryStructure,
            },
          ],
        };
      }
    );
  • Core helper function that recursively traverses the directory tree up to the specified depth, excludes patterns, and builds a formatted tree string using Unicode characters.
    function getDirectoryTree(
      rootPath: string,
      options: TreeOptions = {
        depth: 3,
        excludePatterns: ["node_modules", ".git", ".turbo", "dist", ".next"],
      }
    ) {
      const tree: string[] = [];
    
      function shouldExclude(file: string): boolean {
        return options.excludePatterns.some((pattern) => {
          if (pattern.includes("*")) {
            const regexPattern = pattern.replace(/\*/g, ".*");
            return new RegExp(regexPattern).test(file);
          }
          return file === pattern;
        });
      }
    
      function traverse(dir: string, currentDepth: number = 0) {
        if (currentDepth >= options.depth) return;
    
        const files = fs.readdirSync(dir);
        const filteredFiles = files.filter((file) => !shouldExclude(file));
    
        filteredFiles.forEach((file, index) => {
          const filePath = path.join(dir, file);
          const stats = fs.statSync(filePath);
          const isLast = index === filteredFiles.length - 1;
          const prefix = isLast ? "└── " : "├── ";
    
          if (stats.isDirectory()) {
            tree.push(`${"  ".repeat(currentDepth)}${prefix}${file}`);
            traverse(filePath, currentDepth + 1);
          } else {
            tree.push(`${"  ".repeat(currentDepth)}${prefix}${file}`);
          }
        });
      }
    
      traverse(rootPath);
      return tree.join("\n");
    }
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 but provides almost none. 'Get' implies a read operation, but the description doesn't mention whether this is a safe operation, what permissions might be required, whether it follows symlinks, what happens with inaccessible directories, or any rate limits. The word 'deep' hints at recursion but doesn't specify depth behavior.

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 extremely concise at just three words, which could be considered efficient. However, this brevity comes at the cost of being under-specified rather than truly well-structured. It's front-loaded in the sense that there's nothing to reorder, but it lacks the substance needed for proper tool understanding.

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 that this is a tool with 2 parameters (one nested), no annotations, and no output schema, the description is woefully incomplete. It doesn't explain what the tool returns, how the tree is formatted, whether it includes file metadata, or any behavioral characteristics. For a tool that presumably returns complex directory structures, the description provides inadequate 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?

The input schema has 100% description coverage, providing thorough documentation for both the 'path' parameter and the nested 'options' object with its 'depth' and 'excludePatterns' properties. The description adds no parameter information beyond what's already in the schema, so it meets the baseline of 3 for high schema coverage without adding value.

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

Purpose2/5

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

The description 'Get deep directory tree' is essentially a tautology that restates the tool name with minimal additional information. It specifies the verb 'Get' and resource 'deep directory tree', but provides no differentiation from potential siblings (though none exist) and lacks specificity about what constitutes 'deep' or the nature of the output.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance on when to use this tool versus alternatives. There are no sibling tools mentioned, but the description fails to indicate any context, prerequisites, or scenarios where this tool would be appropriate versus other directory listing approaches.

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/andredezzy/deep-filesystem-tree-mcp'

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