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
| Name | Required | Description | Default |
|---|---|---|---|
| close_source_branch | No | Close source branch after merge | |
| description | No | Pull request description | |
| destination_branch | No | Branch you want to merge into | main |
| repo_slug | Yes | Repository slug/name | |
| source_branch | Yes | Branch containing your changes | |
| title | Yes | Pull request title | |
| workspace | No | Repository workspace (defaults to kallows) | kallows |
Input Schema (JSON Schema)
{
"properties": {
"close_source_branch": {
"default": true,
"description": "Close source branch after merge",
"type": "boolean"
},
"description": {
"description": "Pull request description",
"type": "string"
},
"destination_branch": {
"default": "main",
"description": "Branch you want to merge into",
"type": "string"
},
"repo_slug": {
"description": "Repository slug/name",
"type": "string"
},
"source_branch": {
"description": "Branch containing your changes",
"type": "string"
},
"title": {
"description": "Pull request title",
"type": "string"
},
"workspace": {
"default": "kallows",
"description": "Repository workspace (defaults to kallows)",
"type": "string"
}
},
"required": [
"repo_slug",
"title",
"source_branch"
],
"type": "object"
}
Implementation Reference
- src/mcp_bitbucket/server.py:788-829 (handler)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 )]
- src/mcp_bitbucket/server.py:356-396 (registration)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"] } )