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
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | Yes | The workspace slug | |
| repo_slug | Yes | The repository slug | |
| branch_name | Yes | The branch name to delete |
Implementation Reference
- src/tools/index.ts:1000-1004 (handler)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' }; }
- src/tools/index.ts:169-173 (schema)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'), }),
- src/tools/index.ts:613-625 (registration)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'], }, },
- src/api/branches.ts:49-53 (helper)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)}` ); }