Skip to main content
Glama

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
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.

Implementation Reference

  • 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'], }, },
  • 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), }, ], };
  • 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'], },
  • 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; } }

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

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