Skip to main content
Glama

fast_get_directory_tree

Generate a visual directory tree structure from a specified path, with configurable depth, hidden file visibility, and file inclusion options.

Instructions

Gets the directory tree structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesRoot directory path
max_depthNoMaximum depth
show_hiddenNoShow hidden files
include_filesNoInclude files in the tree

Implementation Reference

  • The main handler function for 'fast_get_directory_tree' that recursively builds a directory tree structure up to the specified max_depth, filtering hidden files and excluded paths, and optionally including files.
    async function handleGetDirectoryTree(args: any) {
      const { path: rootPath, max_depth = 3, show_hidden = false, include_files = true } = args;
      
      const safePath_resolved = safePath(rootPath);
      
      async function buildTree(currentPath: string, currentDepth: number): Promise<any> {
        if (currentDepth > max_depth) return null;
        
        try {
          const stats = await fs.stat(currentPath);
          const name = path.basename(currentPath);
          
          if (!show_hidden && name.startsWith('.')) return null;
          if (shouldExcludePath(currentPath)) return null;
          
          const node: any = {
            name: name,
            path: currentPath,
            type: stats.isDirectory() ? 'directory' : 'file',
            size: stats.size,
            size_readable: formatSize(stats.size),
            modified: stats.mtime.toISOString()
          };
          
          if (stats.isDirectory()) {
            node.children = [];
            
            try {
              const entries = await fs.readdir(currentPath, { withFileTypes: true });
              
              for (const entry of entries) {
                const childPath = path.join(currentPath, entry.name);
                
                if (entry.isDirectory()) {
                  const childNode = await buildTree(childPath, currentDepth + 1);
                  if (childNode) node.children.push(childNode);
                } else if (include_files) {
                  const childNode = await buildTree(childPath, currentDepth + 1);
                  if (childNode) node.children.push(childNode);
                }
              }
            } catch {
              // 권한 없는 디렉토리
              node.error = 'Access denied';
            }
          }
          
          return node;
        } catch {
          return null;
        }
      }
      
      const tree = await buildTree(safePath_resolved, 0);
      
      return {
        tree: tree,
        root_path: safePath_resolved,
        max_depth: max_depth,
        show_hidden: show_hidden,
        include_files: include_files,
        timestamp: new Date().toISOString()
      };
    }
  • Input schema defining the parameters for the fast_get_directory_tree tool: path (required), max_depth, show_hidden, include_files.
    inputSchema: {
      type: 'object',
      properties: {
        path: { type: 'string', description: '루트 디렉토리 경로' },
        max_depth: { type: 'number', description: '최대 깊이', default: 3 },
        show_hidden: { type: 'boolean', description: '숨김 파일 표시', default: false },
        include_files: { type: 'boolean', description: '파일 포함', default: true }
      },
      required: ['path']
    }
  • api/server.ts:193-206 (registration)
    Registration of the fast_get_directory_tree tool in the MCP_TOOLS array, including name, description, and input schema.
    {
      name: 'fast_get_directory_tree',
      description: '디렉토리 트리 구조를 가져옵니다',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: '루트 디렉토리 경로' },
          max_depth: { type: 'number', description: '최대 깊이', default: 3 },
          show_hidden: { type: 'boolean', description: '숨김 파일 표시', default: false },
          include_files: { type: 'boolean', description: '파일 포함', default: true }
        },
        required: ['path']
      }
    },
  • api/server.ts:341-343 (registration)
    Dispatch registration in the switch statement for tools/call method, calling the handleGetDirectoryTree handler.
    case 'fast_get_directory_tree':
      result = await handleGetDirectoryTree(args);
      break;
Behavior2/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 of behavioral disclosure. 'Gets' implies a read operation, but the description doesn't specify whether this requires specific permissions, how large directories are handled, what the output format looks like, or any performance characteristics. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and front-loaded with the core purpose, making it easy 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 no annotations and no output schema, the description is incomplete for a tool with 4 parameters. It doesn't explain the return format (e.g., hierarchical vs. flat list), error conditions, or how parameters like 'max_depth' and 'include_files' impact the output. For a tool that likely returns complex data, more context is needed.

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%, so all parameters are documented in the schema. The description adds no additional meaning beyond the schema's parameter descriptions (e.g., it doesn't explain what 'tree structure' entails or how parameters affect it). This meets the baseline of 3 where the schema does the heavy lifting, but no extra value is provided.

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

Purpose3/5

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

The description 'Gets the directory tree structure' clearly states the verb ('Gets') and resource ('directory tree structure'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'fast_list_directory' or 'fast_list_allowed_directories' that might also list directory contents, leaving some ambiguity about what makes this tool unique.

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. With siblings like 'fast_list_directory' and 'fast_list_allowed_directories' that likely serve similar purposes, there's no indication of when this tree-structured output is preferred over a simple listing, nor any mention of prerequisites or exclusions.

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/efforthye/fast-filesystem-mcp'

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