Skip to main content
Glama
harshmaur

GitLab MCP Server

by harshmaur

get_repository_tree

List files and directories in a GitLab project repository to view its structure and contents.

Instructions

Get the repository tree for a GitLab project (list files and directories)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe ID or URL-encoded path of the project
pathNoThe path inside the repository
refNoThe name of a repository branch or tag. Defaults to the default branch.
recursiveNoBoolean value to get a recursive tree
per_pageNoNumber of results to show per page
page_tokenNoThe tree record ID for pagination
paginationNoPagination method (keyset)

Implementation Reference

  • Input schema (GetRepositoryTreeSchema) for the 'get_repository_tree' tool, which validates the parameters for fetching the repository tree from GitLab API.
    export const GetRepositoryTreeSchema = z.object({
      project_id: z.string().describe("The ID or URL-encoded path of the project"),
      path: z.string().optional().describe("The path inside the repository"),
      ref: z
        .string()
        .optional()
        .describe("The name of a repository branch or tag. Defaults to the default branch."),
      recursive: z.boolean().optional().describe("Boolean value to get a recursive tree"),
      per_page: z.number().optional().describe("Number of results to show per page"),
      page_token: z.string().optional().describe("The tree record ID for pagination"),
      pagination: z.string().optional().describe("Pagination method (keyset)"),
    });
  • Response schema (GitLabTreeSchema) defining the structure of the repository tree returned by the 'get_repository_tree' tool.
    export const GitLabTreeSchema = z.object({
      id: z.string(), // Changed from sha to match GitLab API
      tree: z.array(GitLabTreeItemSchema),
    });
  • Schema for individual tree items (files/directories) used in the repository tree response of the 'get_repository_tree' tool.
    export const GitLabTreeItemSchema = z.object({
      id: z.string(),
      name: z.string(),
      type: z.enum(["tree", "blob"]),
      path: z.string(),
      mode: z.string(),
    });
  • Type definition for the input options of the 'get_repository_tree' tool derived from its Zod schema.
    export type GetRepositoryTreeOptions = z.infer<typeof GetRepositoryTreeSchema>;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the action but lacks behavioral details: it doesn't mention pagination behavior (implied by parameters but not described), rate limits, authentication needs, whether it's read-only (implied by 'Get' but not explicit), or error conditions. The description adds minimal context beyond the basic action.

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 that front-loads the core purpose with a clarifying parenthetical. There is zero waste or redundancy, making it easy to parse quickly for an AI agent.

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 has 7 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like pagination, authentication, or error handling, and lacks usage guidelines. For a tool with this complexity and no structured safety or output information, the description should provide more context to be fully helpful.

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 parameters are fully documented in the schema. The description adds no additional meaning about parameters beyond implying a tree structure with 'list files and directories'. It doesn't explain parameter interactions (e.g., how 'path' and 'recursive' combine) or provide examples, so it meets the baseline for high 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 verb ('Get') and resource ('repository tree for a GitLab project'), with the parenthetical clarifying it lists files and directories. It distinguishes from siblings like 'get_file_contents' (specific file) or 'list_projects' (projects not trees), but doesn't explicitly contrast with similar tools like 'search_repositories'.

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?

No guidance on when to use this tool versus alternatives is provided. It doesn't mention prerequisites (e.g., needing project access), exclusions, or compare with siblings like 'get_file_contents' for single files or 'list_projects' for project metadata. Usage is implied by the name and description alone.

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

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