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
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The ID or URL-encoded path of the project | |
| path | No | The path inside the repository | |
| ref | No | The name of a repository branch or tag. Defaults to the default branch. | |
| recursive | No | Boolean value to get a recursive tree | |
| per_page | No | Number of results to show per page | |
| page_token | No | The tree record ID for pagination | |
| pagination | No | Pagination method (keyset) |
Implementation Reference
- schemas.ts:382-393 (schema)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)"), });
- schemas.ts:395-398 (schema)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), });
- schemas.ts:374-380 (schema)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(), });