Skip to main content
Glama

gitlab_list_branches

Retrieve a list of branches for a specified GitLab project by providing the project ID and optional search criteria.

Instructions

List branches of a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe ID or URL-encoded path of the project
searchNoSearch branches by name

Implementation Reference

  • The main handler function that implements the gitlab_list_branches tool. It validates the project_id, calls the GitLab API to list branches, and formats the response.
    export const listBranches: ToolHandler = async (params, context) => {
      const { project_id, search } = params.arguments || {};
      if (!project_id) {
        throw new McpError(ErrorCode.InvalidParams, 'project_id is required');
      }
      
      const response = await context.axiosInstance.get(
        `/projects/${encodeURIComponent(String(project_id))}/repository/branches`,
        { params: { search } }
      );
      return formatResponse(response.data);
    };
  • The tool definition object specifying the name, description, and input schema (JSON Schema) for the gitlab_list_branches tool.
    {
      name: 'gitlab_list_branches',
      description: 'List branches of a GitLab project',
      inputSchema: {
        type: 'object',
        properties: {
          project_id: {
            type: 'string',
            description: 'The ID or URL-encoded path of the project'
          },
          search: {
            type: 'string',
            description: 'Search branches by name'
          }
        },
        required: ['project_id']
      }
  • The registration entry in the toolRegistry that maps the tool name 'gitlab_list_branches' to its handler function repoHandlers.listBranches.
    gitlab_list_branches: repoHandlers.listBranches,

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

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