Skip to main content
Glama
Kallows

MCP Bitbucket Python

by Kallows

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

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYesThe repository slug to delete
workspaceNoTarget workspace (defaults to kallows, can use ~ for personal workspace)kallows

Implementation Reference

  • 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
            )]
  • 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"]
        }
    ),
Install Server

Other Tools

Related Tools

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

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