Skip to main content
Glama

gitlab_list_branches

List all branches in a GitLab repository with latest commit information. Use to check available branches, find feature branches, or filter results by search criteria.

Instructions

List repository branches Returns: All branches with latest commit info Use when: Checking branches, finding feature branches Optional: Search filter

Example response: [{ "name": "main", "protected": true, "merged": false, "can_push": true, "default": true, "commit": { "id": "abc123...", "short_id": "abc123", "title": "Latest commit" } }]

Related tools:

  • gitlab_create_branch: Create new branch

  • gitlab_delete_branch: Remove branch

  • gitlab_compare_refs: Compare branches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoProject ID or path (optional - auto-detects from git)

Implementation Reference

  • Handler function that implements the gitlab_list_branches tool by resolving the project ID (auto-detecting from git if not provided) and calling GitLabClient.get_branches() to retrieve the list of branches.
    def handle_list_branches(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Any:
        """Handle listing branches"""
        project_id = require_project_id(client, arguments)
        return client.get_branches(project_id)
  • MCP tool registration in server.list_tools() including name, description from tool_descriptions, and input schema allowing optional project_id.
    types.Tool(
        name=TOOL_LIST_BRANCHES,
        description=desc.DESC_LIST_BRANCHES,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": "Project ID or path (optional - auto-detects from git)"}
            }
        }
    ),
  • Tool schema definition in tool_definitions.py (duplicate/alternative to server.py) defining input schema for project_id.
    types.Tool(
        name=TOOL_LIST_BRANCHES,
        description=desc.DESC_LIST_BRANCHES,
        inputSchema={
            "type": "object",
            "properties": {
                "project_id": {"type": "string", "description": "Project ID or path (optional - auto-detects from git)"}
            }
        }
  • Registration of the handler function in the TOOL_HANDLERS dictionary used by server.call_tool() for dispatching.
    TOOL_LIST_BRANCHES: handle_list_branches,
  • Constant defining the tool name string used throughout the codebase.
    TOOL_LIST_BRANCHES = "gitlab_list_branches"

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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/Vijay-Duke/mcp-gitlab'

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