delete_branch
Remove a branch from a Bitbucket Cloud repository to clean up your codebase and manage version control effectively.
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:998-1002 (handler)Tool handler in ToolHandler.handleTool that dispatches to BranchesAPI.delete after parsing inputs.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/api/branches.ts:49-53 (handler)BranchesAPI.delete method that performs the actual HTTP DELETE request to Bitbucket API endpoint to delete the specified 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)}` ); }
- src/tools/index.ts:169-173 (schema)Zod schema for validating inputs to the delete_branch tool: workspace, repo_slug, branch_name.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)MCP tool definition registration with 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'], }, },