Skip to main content
Glama

get_repository_tree

Retrieve the file and directory structure of a GitLab project to explore repository contents, navigate codebases, and understand project organization.

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

  • Zod input schema defining parameters for the 'get_repository_tree' MCP tool, matching GitLab's repository tree API endpoints.
    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)"), });
  • Output/response schema for repository tree data in 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.
    export const GitLabTreeItemSchema = z.object({ id: z.string(), name: z.string(), type: z.enum(["tree", "blob"]), path: z.string(), mode: z.string(), });

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