Skip to main content
Glama

gitlab_delete_branch

Delete a branch from a GitLab project to manage repository structure and remove outdated code.

Instructions

Deletes a branch from a GitLab project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.
branchNameYesThe name of the branch to delete.

Implementation Reference

  • Handler function for the 'gitlab_delete_branch' tool that extracts parameters and calls GitLabService.deleteBranch to perform the deletion.
    case 'gitlab_delete_branch': {
      if (!gitlabService) {
        throw new Error('GitLab service is not initialized.');
      }
      const { projectPath, branchName } = args as { projectPath: string; branchName: string };
      await gitlabService.deleteBranch(projectPath, branchName);
      return {
        content: [
          {
            type: 'text',
            text: `Branch ${branchName} deleted successfully.`,
          },
        ],
      };
    }
  • src/index.ts:791-808 (registration)
    Registers the 'gitlab_delete_branch' tool in the allTools array, including its name, description, and input schema.
    {
      name: 'gitlab_delete_branch',
      description: 'Deletes a branch from a GitLab project.',
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: {
            type: 'string',
            description: 'The path of the GitLab project.',
          },
          branchName: {
            type: 'string',
            description: 'The name of the branch to delete.',
          },
        },
        required: ['projectPath', 'branchName'],
      },
    },
  • GitLabService method that performs the actual API call to delete the specified branch from the project.
    async deleteBranch(projectPath: string, branchName: string): Promise<void> {
      const encodedProjectPath = encodeURIComponent(projectPath);
      const encodedBranchName = encodeURIComponent(branchName);
      await this.callGitLabApi<any>(
        `projects/${encodedProjectPath}/repository/branches/${encodedBranchName}`,
        'DELETE',
      );
    }

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