Skip to main content
Glama
abhishekbhakat

mcp-server-code-assist

file_tree

Generate a visual directory tree structure with Git tracking information to analyze project organization and version control status.

Instructions

Lists directory tree structure with git tracking support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The core handler function for the 'file_tree' tool. Generates a directory tree visualization, optionally using git-tracked files or gitignore patterns to filter contents.
    async def file_tree(self, path: str) -> tuple[str, int, int]:
        """Generate tree view of directory structure.
    
        Args:
            path: Root directory path
    
        Returns:
            Tree view as string
        """
        path = await self.validate_path(path)
        base_path = path
    
        # Try git tracking first
        tracked_files = self._get_tracked_files(path)
        gitignore = self._load_gitignore(path) if tracked_files is None else []
    
        def gen_tree(path: Path, prefix: str = "") -> tuple[list[str], int, int]:
            entries = []
            dir_count = 0
            file_count = 0
    
            items = sorted(path.iterdir(), key=lambda x: (x.is_file(), x.name))
            for i, item in enumerate(items):
                rel_path = str(item.relative_to(base_path))
    
                # Skip if file should be ignored
                if tracked_files is not None:
                    if rel_path not in tracked_files and not any(str(p.relative_to(base_path)) in tracked_files for p in item.rglob("*") if p.is_file()):
                        continue
                else:
                    # Use gitignore
                    if self._should_ignore(rel_path, gitignore):
                        continue
    
                is_last = i == len(items) - 1
                curr_prefix = "└── " if is_last else "├── "
                curr_line = prefix + curr_prefix + item.name
    
                if item.is_dir():
                    next_prefix = prefix + ("    " if is_last else "│   ")
                    subtree, sub_dirs, sub_files = gen_tree(item, next_prefix)
                    if tracked_files is not None and not subtree:
                        continue
                    entries.extend([curr_line] + subtree)
                    dir_count += 1 + sub_dirs
                    file_count += sub_files
                else:
                    if tracked_files is not None and rel_path not in tracked_files:
                        continue
                    entries.append(curr_line)
                    file_count += 1
    
            return entries, dir_count, file_count
    
        tree_lines, _, _ = gen_tree(path)
        return "\n".join(tree_lines)
  • Pydantic schema/model defining the input for the file_tree tool: a path string.
    class FileTree(BaseModel):
        path: str
  • Tool registration in @server.list_tools(), defining name, description, and input schema for 'file_tree'.
    Tool(
        name=CodeAssistTools.FILE_TREE,
        description="Lists directory tree structure with git tracking support",
        inputSchema=ListDirectory.model_json_schema(),
    ),
  • Tool dispatch/execution handler in @server.call_tool() for 'file_tree', validating input with FileTree model and calling the file_tools.file_tree method.
    case CodeAssistTools.FILE_TREE:
        model = FileTree(path=arguments["path"])
        result = await file_tools.file_tree(model.path)
        return [TextContent(type="text", text=result)]
  • Enum value definition for the 'file_tree' tool name in CodeAssistTools.
    FILE_TREE = "file_tree"
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. It mentions 'git tracking support,' hinting at additional functionality beyond basic listing, but doesn't specify what that entails (e.g., shows git status per file, includes untracked files, or handles git repositories only). It lacks details on output format, error handling, or any constraints, making it insufficient for a mutation-free tool.

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: 'Lists directory tree structure with git tracking support.' It's front-loaded with the core purpose and includes the key feature without unnecessary words. Every part earns its place, making it highly concise and well-structured.

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 the tool's moderate complexity (directory tree with git support), no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It doesn't explain the output (e.g., tree format, git indicators), error cases, or how git tracking integrates, leaving significant gaps for an AI agent to use it correctly.

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

Parameters2/5

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

The input schema has 1 parameter ('path') with 0% description coverage, so the schema provides no semantic details. The description adds no information about the parameter—it doesn't explain what 'path' represents (e.g., absolute vs. relative, default to current directory), its format, or any constraints. This fails to compensate for the low schema coverage.

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: 'Lists directory tree structure with git tracking support.' It specifies the verb ('Lists') and resource ('directory tree structure'), and adds the unique feature of 'git tracking support.' However, it doesn't explicitly distinguish it from sibling tools like 'list_directory' or 'git_status,' which prevents a perfect score.

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. It doesn't mention when to choose 'file_tree' over 'list_directory' (which might list files without tree structure or git info) or 'git_status' (which might show git status without a full tree). No exclusions or prerequisites are stated, leaving usage unclear.

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/abhishekbhakat/mcp_server_code_assist'

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