Skip to main content
Glama

gitlab_list_repository_tree

Browse and list files and directories in a GitLab repository to explore project structure, with options for recursive listing and specific paths.

Instructions

Browse repository directory structure Returns: Array of files and directories Use when: Exploring repo structure, listing files Optional: Recursive listing, specific path

Example response: [{ "name": "src", "type": "tree", "path": "src", "mode": "040000" }, { "name": "README.md", "type": "blob", "path": "README.md", "mode": "100644" }]

Related tools:

  • gitlab_get_file_content: Read file contents

  • gitlab_search_in_project: Search in files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoProject identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted
pathNoDirectory path in repository Type: string Format: Relative path using forward slashes Default: '' (empty string for root) Examples: - '' (repository root) - 'src' (src directory) - 'src/components' (nested directory) - 'tests/unit/models' (deeply nested) Note: Don't include trailing slash
refNoGit reference Type: string Format: branch name, tag name, or commit SHA Optional: Yes - defaults to project's default branch Examples: - 'main' (branch) - 'feature/new-login' (feature branch) - 'v2.0.0' (tag) - 'abc1234' (short commit SHA) - 'e83c5163316f89bfbde7d9ab23ca2e25604af290' (full SHA) Default: Project's default branch (usually 'main' or 'master')
recursiveNoInclude subdirectories Type: boolean Default: false Options: - true: Include all subdirectories recursively - false: Only immediate children Use case: true for full directory tree, false for folder contents

Implementation Reference

  • The main handler function that implements the core logic for the 'gitlab_list_repository_tree' tool. Extracts parameters, resolves project ID (with git detection fallback), and delegates to GitLabClient.get_repository_tree().
    def handle_get_repository_tree(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]:
        """Handle getting repository tree"""
        project_id = require_project_id(client, arguments)
        path = get_argument(arguments, "path", "")
        ref = get_argument(arguments, "ref")
        recursive = get_argument(arguments, "recursive", False)
        
        return client.get_repository_tree(project_id, path, ref, recursive)
  • MCP Tool schema definition including input validation schema, properties (project_id, path, ref, recursive), and description reference.
        name=TOOL_LIST_REPOSITORY_TREE,
        description=desc.DESC_LIST_TREE,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID},
                "path": {"type": "string", "description": desc.DESC_TREE_PATH, "default": ""},
                "ref": {"type": "string", "description": desc.DESC_REF},
                "recursive": {"type": "boolean", "description": desc.DESC_RECURSIVE, "default": False}
            }
        }
    ),
  • Mapping of tool name constant to handler function in the TOOL_HANDLERS dictionary, used by server.call_tool() to dispatch executions.
    TOOL_LIST_REPOSITORY_TREE: handle_get_repository_tree,
  • Tool dispatch logic in MCP server.call_tool() that looks up handler by tool name from TOOL_HANDLERS and executes it.
    handler = TOOL_HANDLERS.get(name)
    if not handler:
        raise ValueError(f"Unknown tool: {name}")
  • Constant definition for the tool name string 'gitlab_list_repository_tree', imported and used across handler registration, schema, and dispatch.
    TOOL_LIST_REPOSITORY_TREE = "gitlab_list_repository_tree"
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 mentions the return type ('Array of files and directories') and includes an example response, which adds value. However, it lacks details on permissions, rate limits, or error handling, which are important for a tool interacting with a repository.

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 well-structured and front-loaded, starting with the core purpose, followed by return type, usage guidelines, optional parameters, an example response, and related tools. Each sentence adds value without redundancy, making it efficient 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 complexity of a repository browsing tool with 4 parameters and no output schema, the description is fairly complete. It covers purpose, usage, optional parameters, and provides an example response. However, it could improve by including more behavioral details like authentication needs or error cases, especially since annotations are absent.

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 schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description adds minimal semantic context by listing 'Optional: Recursive listing, specific path' and mentioning related tools, but it does not provide additional meaning beyond what the schema covers, aligning with the baseline for high 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 tool's purpose with specific verbs ('browse', 'list') and resource ('repository directory structure'), and distinguishes it from siblings by mentioning related tools like gitlab_get_file_content for reading file contents and gitlab_search_in_project for searching in files, which helps differentiate its scope.

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 explicit usage guidance with 'Use when: Exploring repo structure, listing files', which clearly indicates the context for using this tool. However, it does not specify when not to use it or mention alternatives beyond the related tools, which could be more detailed.

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/Vijay-Duke/mcp-gitlab'

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