bb_delete_repository
Removes a specified repository from Bitbucket by providing the repository slug and optional workspace. Simplifies repository management within the MCP Bitbucket Python server.
Instructions
Delete a repository from Bitbucket
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_slug | Yes | The repository slug to delete | |
| workspace | No | Target workspace (defaults to kallows, can use ~ for personal workspace) | kallows |
Input Schema (JSON Schema)
{
"properties": {
"repo_slug": {
"description": "The repository slug to delete",
"type": "string"
},
"workspace": {
"default": "kallows",
"description": "Target workspace (defaults to kallows, can use ~ for personal workspace)",
"type": "string"
}
},
"required": [
"repo_slug"
],
"type": "object"
}
Implementation Reference
- src/mcp_bitbucket/server.py:616-647 (handler)Handler implementation within the main call_tool function. Resolves workspace (handles '~' for personal), sends DELETE request to Bitbucket API endpoint for the repository, handles success (204) and error responses with permission formatting.elif name == "bb_delete_repository": workspace = arguments.get("workspace", "kallows") if workspace == "~": user_url = "https://api.bitbucket.org/2.0/user" user_response = requests.get(user_url, auth=auth, headers=headers) if user_response.status_code != 200: return [types.TextContent( type="text", text=f"Failed to get user info: {user_response.status_code} - {format_permission_error(user_response.text)}", isError=True )] workspace = user_response.json().get('username') repo_slug = arguments.get("repo_slug") url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}" response = requests.delete(url, auth=auth, headers=headers) if response.status_code == 204: return [types.TextContent( type="text", text=f"Repository {repo_slug} deleted successfully from workspace '{workspace}'" )] else: error_msg = format_permission_error(response.text) if workspace == "kallows" and "permission" in error_msg.lower(): error_msg += "\n\nTip: You can try deleting the repository from your personal workspace by setting workspace='~'" return [types.TextContent( type="text", text=f"Failed to delete repository: {response.status_code}\n{error_msg}", isError=True )]
- src/mcp_bitbucket/server.py:150-168 (registration)Tool registration in the list_tools handler, defining the tool name, description, and input schema for validation.types.Tool( name="bb_delete_repository", description="Delete a repository from Bitbucket", # TODO: only works with delete repo priv, see if app password can get delete repo privilege inputSchema={ "type": "object", "properties": { "repo_slug": { "type": "string", "description": "The repository slug to delete" }, "workspace": { "type": "string", "description": "Target workspace (defaults to kallows, can use ~ for personal workspace)", "default": "kallows" } }, "required": ["repo_slug"] } ),