delete_branch_restriction
Remove branch restrictions in Bitbucket repositories to allow specific branch operations by deleting existing rules.
Instructions
Delete a branch restriction.
Args:
repo_slug: Repository slug
restriction_id: Restriction ID (from list_branch_restrictions)
Returns:
Confirmation of deletion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_slug | Yes | ||
| restriction_id | Yes |
Implementation Reference
- src/server.py:1419-1434 (handler)MCP tool handler and registration for 'delete_branch_restriction'. This decorated function is called by the MCP server when the tool is invoked. It validates inputs via type hints (used as schema), calls the Bitbucket client helper, and formats the response.@mcp.tool() @handle_bitbucket_error @formatted def delete_branch_restriction(repo_slug: str, restriction_id: int) -> dict: """Delete a branch restriction. Args: repo_slug: Repository slug restriction_id: Restriction ID (from list_branch_restrictions) Returns: Confirmation of deletion """ client = get_client() client.delete_branch_restriction(repo_slug, restriction_id) return {}
- src/bitbucket_client.py:1435-1451 (helper)Core helper method in BitbucketClient class that performs the actual DELETE API request to Bitbucket to remove the specified branch restriction.def delete_branch_restriction( self, repo_slug: str, restriction_id: int ) -> bool: """Delete a branch restriction. Args: repo_slug: Repository slug restriction_id: Restriction ID to delete Returns: True if deleted successfully """ self._request( "DELETE", self._repo_path(repo_slug, "branch-restrictions", str(restriction_id)), ) return True
- src/models.py:600-623 (schema)Pydantic model for branch restrictions. Used in list_branch_restrictions tool to parse API responses and obtain restriction_id for deletion.class BranchRestriction(BaseModel): """Branch restriction info.""" id: int kind: str pattern: str = "" branch_match_kind: Optional[str] = None branch_type: Optional[str] = None value: Optional[int] = None users: list[str] = [] groups: list[str] = [] @classmethod def from_api(cls, data: dict) -> "BranchRestriction": return cls( id=data.get("id", 0), kind=data.get("kind", ""), pattern=data.get("pattern", ""), branch_match_kind=data.get("branch_match_kind"), branch_type=data.get("branch_type"), value=data.get("value"), users=[u.get("display_name", "") for u in data.get("users", [])], groups=[g.get("name", "") for g in data.get("groups", [])], )