Bitbucket Pull Requests & Code Review
Lets an agent review pull requests on Bitbucket Cloud: read the PR, its diff, diffstat, commits and comments, then post general or inline comments and approve or request changes once a person agrees. It can also create branches, open, update, merge or decline pull requests and read files at any commit. Curated from Atlassian's official Bitbucket Cloud OpenAPI specification.
Connect this API to an AI agent Browse all specs
What you can do with Bitbucket Pull Requests & Code Review via MCP
Every endpoint below becomes a governed tool your AI agent (Claude, ChatGPT, or a customer-facing VX agent) can call — with scoped permissions, sandbox testing, and audit logs.
| Method | Path | Operation | Description |
|---|---|---|---|
| GET | /repositories/{workspace}/{repo_slug} |
getRepository | Get a repository's details, including its main branch |
| GET | /repositories/{workspace}/{repo_slug}/pullrequests |
listPullRequests | List pull requests in a repository (open by default) |
| POST | /repositories/{workspace}/{repo_slug}/pullrequests |
createPullRequest | Open a new pull request from one branch into another |
| GET | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id} |
getPullRequest | Get one pull request with its description, branches and reviewers |
| PUT | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id} |
updatePullRequest | Change a pull request's title, description, destination or reviewers |
| GET | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/diffstat |
getPullRequestDiffstat | List the files changed in a pull request with lines added and removed |
| GET | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/diff |
getPullRequestDiff | Get the full text diff of a pull request |
| GET | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/commits |
listPullRequestCommits | List the commits in a pull request |
| GET | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/comments |
listPullRequestComments | List general and inline comments on a pull request |
| POST | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/comments |
createPullRequestComment | Post a general comment or an inline comment on a line of the diff |
| POST | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/approve |
approvePullRequest | Approve a pull request (only after the user confirms) |
| DELETE | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/approve |
removePullRequestApproval | Withdraw your approval of a pull request |
| POST | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/request-changes |
requestPullRequestChanges | Mark a pull request as needing changes (only after the user confirms) |
| DELETE | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/request-changes |
removePullRequestChangeRequest | Withdraw your request for changes on a pull request |
| POST | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/merge |
mergePullRequest | Merge a pull request (only after the user confirms) |
| POST | /repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/decline |
declinePullRequest | Decline (close without merging) a pull request (only after the user confirms) |
| GET | /repositories/{workspace}/{repo_slug}/refs/branches |
listBranches | List the open branches of a repository |
| POST | /repositories/{workspace}/{repo_slug}/refs/branches |
createBranch | Create a new branch from a commit |
| GET | /repositories/{workspace}/{repo_slug}/src/{commit}/{path} |
getFileContent | Read a file or list a folder at a given commit or branch |
Authentication
basic
HTTP Basic
HTTP Basic auth: username = your Atlassian account email, password = an Atlassian API token with scopes for Bitbucket.
How to get a credential
- Sign in at https://id.atlassian.com/manage-profile/security/api-tokens.
- Click Create API token with scopes, give it a name and an expiry date.
- Choose the app Bitbucket.
- Select the scopes in the table below and create the token.
- Copy the token (shown once). Use your Atlassian account email as the username and the token as the password.
Bitbucket app passwords are deprecated and being replaced by API tokens; do not use them for new setups. Repository or workspace access tokens are sent as Authorization: Bearer instead and are not used by this credential.
Permissions used
| Scope | Operations |
|---|---|
| read:repository:bitbucket | getRepository, listBranches, getFileContent |
| write:repository:bitbucket | createBranch |
| read:pullrequest:bitbucket | listPullRequests, getPullRequest, getPullRequestDiff, getPullRequestDiffstat, listPullRequestCommits, listPullRequestComments |
| write:pullrequest:bitbucket | createPullRequestComment, approvePullRequest, removePullRequestApproval, requestPullRequestChanges, removePullRequestChangeRequest, createPullRequest, updatePullRequest, mergePullRequest, declinePullRequest |
Common errors
- 401 Unauthorized: wrong email/token pair, an expired token, or a Bitbucket username used instead of the email; recreate the token and use the account email.
- 403 Forbidden: a scope above is missing, or your account has no write access to the repository (merge also needs branch permissions); create a token with the missing scope.
- 400 Bad Request: invalid body, e.g. inline comment without
inline.path, or a branch name that already exists. - 429 Too Many Requests: hourly rate limit reached; wait and retry later.
Store the email and token as a VX Agents credential for this connector; never paste the token into chat.
Usage guide
Setup
- Credential: Atlassian account email as username + an Atlassian API token with Bitbucket scopes as password (read/write pull requests, read/write repositories). App passwords are being replaced by API tokens.
- Preset
workspaceandrepo_slugif the agent always works on one repository (both appear in the repository URLbitbucket.org/<workspace>/<repo_slug>).
Review a pull request
getPullRequest— title, description, source/destination branches, reviewers.getPullRequestDiffstat— which files changed and how much (paginated: follownext).getPullRequestDiff— the full unified diff as text. For context on a file usegetFileContentwithcommit= source branch name or commit hash.listPullRequestComments(andlistPullRequestCommitsif needed) — do not repeat points already raised.- Post findings with
createPullRequestComment: general comment ={content: {raw}}; inline comment addsinline: {path, to}wheretois the line in the new file (usefromfor a removed line). Reply to a thread withparent: {id}. - Only after the user confirms:
approvePullRequestorrequestPullRequestChanges(undo withremovePullRequestApproval/removePullRequestChangeRequest).
Open, update, merge
- New branch:
listBranches→createBranchwithnameandtarget.hash(commit hash of the base). Committing files is not supported by this spec. createPullRequestwithtitle,source.branch.name, optionaldestination.branch.name,summary.raw,reviewers(uuidincl. braces).updatePullRequestto change title/description/reviewers (a reviewers list replaces the current one).mergePullRequest(merge_strategy,message) anddeclinePullRequest— ALWAYS confirm with the user first.
Good to know
- Confirm with the user before any write that posts comments, approves, requests changes, creates/merges/declines a PR or creates a branch.
pull_request_idis the number in the PR URL. Lists page withpage/pagelen(max 50) and returnnextwhen more exist.- Times are ISO 8601 UTC. User UUIDs are written with braces, e.g.
{1234-…}.
How to use this spec
- Create a free VX Agents account (sandbox tools included).
- Open the marketplace and connect “Bitbucket Pull Requests & Code Review” to an agent.
- Expose it as an MCP server for Claude/ChatGPT, or chat with it directly.