Skip to main content
Glama
Kallows

MCP Bitbucket Python

by Kallows

bb_create_branch

Create a new branch in a Bitbucket repository by specifying the repository slug, branch name, and optional start point or workspace. Simplifies repository management tasks.

Instructions

Create a new branch in a Bitbucket repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchYesName for the new branch
repo_slugYesRepository slug/name
start_pointNoBranch/commit to create from (defaults to main)main
workspaceNoRepository workspace (defaults to kallows)kallows

Implementation Reference

  • Handler implementation for the bb_create_branch tool. It fetches the hash of the start point branch, then creates a new branch from that hash using Bitbucket API.
    elif name == "bb_create_branch":
        workspace = arguments.get("workspace", "kallows")
        repo_slug = arguments.get("repo_slug")
        branch_name = arguments.get("branch")
        start_point = arguments.get("start_point", "main")
    
        # First get the hash of the start point
        ref_url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches/{start_point}"
        ref_response = requests.get(ref_url, auth=auth, headers=headers)
        
        if ref_response.status_code != 200:
            return [types.TextContent(
                type="text",
                text=f"Failed to get start point reference: {ref_response.status_code}\n{format_permission_error(ref_response.text)}",
                isError=True
            )]
        
        start_hash = ref_response.json()['target']['hash']
        
        # Create the new branch
        url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/refs/branches"
        payload = {
            "name": branch_name,
            "target": {
                "hash": start_hash
            }
        }
        
        response = requests.post(url, json=payload, auth=auth, headers=headers)
    
        if response.status_code in (200, 201):
            branch_url = response.json().get('links', {}).get('html', {}).get('href', '')
            return [types.TextContent(
                type="text",
                text=f"Branch '{branch_name}' created successfully\nURL: {branch_url}"
            )]
        else:
            return [types.TextContent(
                type="text",
                text=f"Failed to create branch: {response.status_code}\n{format_permission_error(response.text)}",
                isError=True
            )]
  • Registration of the bb_create_branch tool in the list_tools handler, including description and input schema definition.
    types.Tool(
        name="bb_create_branch",
        description="Create a new branch in a Bitbucket repository",
        inputSchema={
            "type": "object", 
            "properties": {
                "workspace": {
                    "type": "string",
                    "description": "Repository workspace (defaults to kallows)",
                    "default": "kallows"
                },
                "repo_slug": {
                    "type": "string",
                    "description": "Repository slug/name"
                },
                "branch": {
                    "type": "string",
                    "description": "Name for the new branch"
                },
                "start_point": {
                    "type": "string", 
                    "description": "Branch/commit to create from (defaults to main)",
                    "default": "main"
                }
            },
            "required": ["repo_slug", "branch"]
        }
    ),        
  • Input schema definition for the bb_create_branch tool, specifying parameters like workspace, repo_slug, branch, and start_point.
    inputSchema={
        "type": "object", 
        "properties": {
            "workspace": {
                "type": "string",
                "description": "Repository workspace (defaults to kallows)",
                "default": "kallows"
            },
            "repo_slug": {
                "type": "string",
                "description": "Repository slug/name"
            },
            "branch": {
                "type": "string",
                "description": "Name for the new branch"
            },
            "start_point": {
                "type": "string", 
                "description": "Branch/commit to create from (defaults to main)",
                "default": "main"
            }
        },
        "required": ["repo_slug", "branch"]
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool creates a branch but doesn't mention permissions required, whether it's a destructive operation (though implied as non-destructive), rate limits, or what happens on success/failure. This leaves significant gaps for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain behavioral aspects like permissions, error conditions, or return values, which are crucial for safe and effective use. The high schema coverage helps but doesn't compensate for these gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score of 3 for adequate but no extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new branch') and resource ('in a Bitbucket repository'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like bb_create_repository or bb_create_pull_request, which also create resources in Bitbucket repositories but different types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing repository access), exclusions, or comparisons with sibling tools like bb_create_pull_request that might involve branch creation. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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