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;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the action ('Lists') but lacks details on output format (e.g., list of branch names, pagination, sorting), permissions required, rate limits, or error conditions. For a read operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero waste—it states the core action and resource without fluff. It's appropriately sized for a simple list operation and front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a simple input schema, the description is incomplete. It doesn't explain what the tool returns (e.g., branch names, details), handling of large result sets, or authentication needs. For a tool that lists data, this lack of output context is a significant gap, making it inadequate for full understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'projectPath' documented in the schema. The description adds no additional meaning beyond implying the tool operates on a project, which is already clear from the schema. Baseline is 3 since the schema adequately covers parameter semantics without extra value from the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Lists') and resource ('all branches in a GitLab project'), making the purpose immediately understandable. It distinguishes from siblings like gitlab_get_branch_details (which retrieves details for a specific branch) and gitlab_create_branch/gitlab_delete_branch (which modify branches). However, it doesn't explicitly mention the scope (e.g., all branches vs. filtered) beyond 'all', which slightly limits differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing project access), contrast with gitlab_get_branch_details for single-branch info, or suggest scenarios like exploring project structure. Usage is implied by the name but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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