list_project_branches
Retrieve and search through branches within a GitLab project to view available development lines and manage code versions effectively.
Instructions
List branches in a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| per_page | No | Number of results per page (max 100) | |
| project_id | Yes | Project ID or path | |
| search | No | Search branches by name |
Implementation Reference
- src/handlers/repository.ts:12-32 (handler)The main handler function that executes the logic for the 'list_project_branches' tool by querying the GitLab API for project branches and returning the JSON response.async listProjectBranches(args: ListProjectBranchesParams) { const params = new URLSearchParams(); if (args.search) params.append("search", args.search); params.append("per_page", String(args.per_page || 20)); const data = await this.client.get( `/projects/${encodeURIComponent( args.project_id )}/repository/branches?${params.toString()}` ); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- src/tools/repository.ts:4-27 (registration)Registration of the 'list_project_branches' tool, defining its name, description, and input schema for the MCP server.{ name: "list_project_branches", description: "List branches in a project", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "Project ID or path", }, search: { type: "string", description: "Search branches by name", }, per_page: { type: "number", description: "Number of results per page (max 100)", maximum: 100, default: 20, }, }, required: ["project_id"], }, },
- src/types.ts:314-318 (schema)TypeScript interface defining the input parameters for the list_project_branches tool, imported and used by the handler.export interface ListProjectBranchesParams { project_id: string; search?: string; per_page?: number; }
- src/server.ts:269-272 (registration)Dispatch/registration in the MCP server switch statement that routes calls to the 'list_project_branches' handler.case "list_project_branches": return await this.repositoryHandlers.listProjectBranches( args as unknown as ListProjectBranchesParams );