Skip to main content
Glama
Lexmata

Bitbucket Cloud MCP Server

by Lexmata

delete_branch

Remove branches from Bitbucket Cloud repositories to manage codebase structure and clean up unused or merged branches.

Instructions

Delete a branch from a repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceYesThe workspace slug
repo_slugYesThe repository slug
branch_nameYesThe branch name to delete

Implementation Reference

  • Handler case in ToolHandler.handleTool for the delete_branch tool. Parses arguments using the schema, calls BranchesAPI.delete, and returns a success message.
    case 'delete_branch': {
      const params = toolSchemas.delete_branch.parse(args);
      await this.branches.delete(params.workspace, params.repo_slug, params.branch_name);
      return { success: true, message: 'Branch deleted' };
    }
  • Zod input schema definition for the delete_branch tool in toolSchemas.
    delete_branch: z.object({
      workspace: z.string().describe('The workspace slug'),
      repo_slug: z.string().describe('The repository slug'),
      branch_name: z.string().describe('The branch name to delete'),
    }),
  • Registration of the delete_branch tool in the toolDefinitions array used for MCP, including name, description, and JSON schema for inputs.
    {
      name: 'delete_branch',
      description: 'Delete a branch from a repository.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          workspace: { type: 'string', description: 'The workspace slug' },
          repo_slug: { type: 'string', description: 'The repository slug' },
          branch_name: { type: 'string', description: 'The branch name to delete' },
        },
        required: ['workspace', 'repo_slug', 'branch_name'],
      },
    },
  • Core implementation in BranchesAPI.delete: sends DELETE request to Bitbucket API endpoint to delete the branch.
    async delete(workspace: string, repo_slug: string, branch_name: string): Promise<void> {
      await this.client.delete(
        `/repositories/${workspace}/${repo_slug}/refs/branches/${encodeURIComponent(branch_name)}`
      );
    }

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/Lexmata/bitbucket-mcp'

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