gitlab_list_branches
List all branches in a GitLab project to view available development paths and manage code versions.
Instructions
Lists all branches in a GitLab project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | The path of the GitLab project. |
Implementation Reference
- src/gitlab.service.ts:607-610 (handler)Core handler function that executes the GitLab API call to list branches for a project.async listBranches(projectPath: string): Promise<any[]> { const encodedProjectPath = encodeURIComponent(projectPath); return this.callGitLabApi<any[]>(`projects/${encodedProjectPath}/repository/branches`); }
- src/index.ts:756-768 (registration)MCP tool registration including name, description, and input schema.name: 'gitlab_list_branches', description: 'Lists all branches in a GitLab project.', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, }, required: ['projectPath'], }, },
- src/index.ts:1889-1902 (handler)MCP server handler that processes the tool call by invoking the GitLab service's listBranches method.case 'gitlab_list_branches': { if (!gitlabService) { throw new Error('GitLab service is not initialized.'); } const { projectPath } = args as { projectPath: string }; const result = await gitlabService.listBranches(projectPath); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], };
- src/index.ts:758-767 (schema)Input schema definition for the gitlab_list_branches tool.inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, }, required: ['projectPath'], },
- src/gitlab.service.ts:22-51 (helper)Helper method used by listBranches to make authenticated API calls to GitLab.private async callGitLabApi<T>( endpoint: string, method: string = 'GET', body?: object, ): Promise<T> { const url = `${this.config.url}/api/v4/${endpoint}`; const headers = { 'Private-Token': this.config.accessToken, 'Content-Type': 'application/json', }; const options: any = { method, headers, body: body ? JSON.stringify(body) : undefined, }; try { const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); console.error(`GitLab API Error: ${response.status} - ${errorText}`); throw new Error(`GitLab API Error: ${response.status} - ${errorText}`); } return response.json() as Promise<T>; } catch (error) { console.error(`Failed to call GitLab API: ${error}`); throw error; } }