Skip to main content
Glama
Kallows

MCP Bitbucket Python

by Kallows

bb_create_pull_request

Create a pull request in a Bitbucket repository, specifying source and destination branches, title, and description, with optional source branch closure after merging.

Instructions

Create a new pull request in a Bitbucket repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
close_source_branchNoClose source branch after merge
descriptionNoPull request description
destination_branchNoBranch you want to merge intomain
repo_slugYesRepository slug/name
source_branchYesBranch containing your changes
titleYesPull request title
workspaceNoRepository workspace (defaults to kallows)kallows

Implementation Reference

  • Handler function for bb_create_pull_request tool. Creates a pull request in Bitbucket using the Bitbucket API by posting to the pullrequests endpoint with the provided title, description, source and destination branches.
    elif name == "bb_create_pull_request":
        workspace = arguments.get("workspace", "kallows")
        repo_slug = arguments.get("repo_slug")
        title = arguments.get("title")
        description = arguments.get("description", "")
        source_branch = arguments.get("source_branch")
        destination_branch = arguments.get("destination_branch", "main")
        close_source_branch = arguments.get("close_source_branch", True)
    
        url = f"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pullrequests"
        
        payload = {
            "title": title,
            "description": description,
            "source": {
                "branch": {
                    "name": source_branch
                }
            },
            "destination": {
                "branch": {
                    "name": destination_branch
                }
            },
            "close_source_branch": close_source_branch
        }
    
        response = requests.post(url, json=payload, auth=auth, headers=headers)
    
        if response.status_code in (200, 201):
            pr_id = response.json().get('id')
            pr_url = response.json().get('links', {}).get('html', {}).get('href', '')
            return [types.TextContent(
                type="text",
                text=f"Pull request created successfully\nID: {pr_id}\nURL: {pr_url}"
            )]
        else:
            return [types.TextContent(
                type="text",
                text=f"Failed to create pull request: {response.status_code}\n{format_permission_error(response.text)}",
                isError=True
            )]
  • Tool registration for bb_create_pull_request, including name, description, and input schema definition.
    types.Tool(
        name="bb_create_pull_request",
        description="Create a new pull request 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"
                },
                "title": {
                    "type": "string",
                    "description": "Pull request title"
                },
                "description": {
                    "type": "string",
                    "description": "Pull request description"
                },
                "source_branch": {
                    "type": "string",
                    "description": "Branch containing your changes"
                },
                "destination_branch": {
                    "type": "string",
                    "description": "Branch you want to merge into",
                    "default": "main"
                },
                "close_source_branch": {
                    "type": "boolean",
                    "description": "Close source branch after merge",
                    "default": True
                }
            },
            "required": ["repo_slug", "title", "source_branch"]
        }
    )                
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