/bitbucket-mcp:bitbucket-pull-requestsfrom Bitbucket Cloud pull requests
Review, create and merge Bitbucket Cloud pull requests, and diagnose failed Bitbucket Pipelines builds, through the bitbucket-mcp MCP server. Use when a task touches a Bitbucket pull request — reading a diff, leaving inline comments or tasks, approving or requesting changes, opening a pull request from a branch, merging or declining one — or when a Bitbucket build or pipeline is failing and the question is why, or still running and the work waits on it, and the bitbucket-mcp tools (`listPullRequests`, `getPullRequestDiff`, `addPullRequestComment`, `mergePullRequest`, `listPipelines`, `getPipelineStepLog` and the rest) are attached. Covers the order the calls go in: diffstat before diff content, snippet-anchored inline comments, a mergeability check before a merge, the failing step before its log, and when to ask local git instead of spending an API call.
Ships in Bitbucket Cloud pull requests. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The server's initialize instructions already state the conventions — slugs, opaque cursors,
snippet anchors, reviewer UUIDs — and every tool's schema carries its own rules. This file holds
what neither can: the order the calls go in, and what to do when one of them fails.
listPullRequests — find it. Open ones only unless state says otherwise, most recently
updated first. sourceBranch answers "does this branch already have one?", reviewer "what
is waiting on my review?", destinationBranch "what is going into main?".getPullRequest — description, reviewers, their approvals, and url. Read it before writing
anything to it.getPullRequestDiff with no paths — the changed-file list. Always this first. A
whole-pull-request diff is what Bitbucket answers 555 to on a large one, and what burns the
context window when it succeeds.getPullRequestDiff with paths=[...] — only the files worth reading, spelled exactly as the
file list spelled them. paths on its own selects diff mode; naming mode="diffstat" beside it
is refused rather than ignored. Read truncated on the way out: a truncated diff is not the
change.getPullRequestComments — what has already been said, before saying it again. A comment's id
is the parentCommentId that makes the next one a reply.addPullRequestComment with path and codeSnippet — the line's text copied verbatim out of
the diff. The snippet beats a line number because the server resolves it against that file's
diff and reports ambiguity with the candidate lines, instead of commenting on the wrong line.
line plus lineType is the fallback for a line whose text repeats.addPullRequestTask for anything that has to actually be done, with commentId to hang it off
the remark rather than restating it. A comment can be read and forgotten; Bitbucket counts
tasks, and a repository can require them resolved before it merges. Check listPullRequestTasks
first — calling twice makes two tasks.setPullRequestReviewStatus — APPROVED, CHANGES_REQUESTED, or UNAPPROVED to withdraw
both. It moves your own stance and nobody else's; comment posts the reasoning in the same
call. Name the sourceCommit you reviewed in it ("Reviewed at 3f9a1c2"): Bitbucket keeps no
record of which commit a review saw, and that line is how a later session finds where to
re-review from.Coming back to a review you already left:
getPullRequestComments with unresolvedOnly=true — the threads still waiting for an answer,
without the settled ones.updatePullRequestTask with state="RESOLVED" ticks a task off. resolvePullRequestComment
marks the thread resolved. Do both — they are separate counters, and a repository can gate on
either.getPullRequestDiff with sinceCommit — the sourceCommit you reviewed, from your own review
comment if this session did not see it — for only what changed since: the same two steps, no
paths for the files and then paths for their diffs. range.to is the sinceCommit of the
round after. With the branch checked out, git diff <sinceCommit> origin/<sourceBranch> is the
same answer for free.range.hint saying sinceCommit is not an ancestor means the branch was rebased or
force-pushed: the diff then also holds what the new base brought in, so check a change that
surprises you against the whole pull request's diff before putting it to the author. A
sinceCommit the force-push discarded is refused with a 404; review the whole pull request
again.updatePullRequestComment
with content to correct it, or delete=true to withdraw it — not a second comment below the
first. An edited inline comment keeps its line; to move it, delete it and add it again.getPullRequest to confirm it is the pull request you think it is.getPullRequestMergeability before the decision: Bitbucket's own dry run of the merge —
approvals, builds, tasks, conflicts, your permission, the merge queue — with the blocking checks
first. A check that failed but is not blocking is a warning, not a stop.listPullRequestStatuses when it is a build that blocks, for which one and its link. Bitbucket
merges over a failing build when the repository does not require it, and an empty list means
nothing has reported yet — which is not the same as passing.mergePullRequest — not undoable from here. Omit mergeStrategy to take the repository's
default; a strategy it has disabled is rejected, not substituted, and a conflict is a 409 rather
than a half-merge.QUEUED result is a merge under way, not a failure. Bitbucket is merging in the background
or holding the pull request in its branch's merge queue, which can take as long as the queue's
builds. Never call mergePullRequest again to wait: getPullRequest shows MERGED once it lands,
and getPullRequestMergeability shows whether it is still queued and what holds it. A client
with MCP tasks runs the merge as a task that follows the queue for up to 30 minutes, so QUEUED
is rare there.declinePullRequest closes without merging and cannot be reopened through this server. When the
author is expected to keep working, setPullRequestReviewStatus with CHANGES_REQUESTED is the
tool instead.listPullRequests with sourceBranch and state="ALL" — the deduplication check.
createPullRequest is not idempotent: called twice it opens two pull requests.createPullRequest leaves the field out when reviewers is unset. Where
the repository or its project carries a default-reviewer rule and the user does not want it,
pass reviewers: [], which is the one way to say "nobody". When reviewers are wanted,
listDefaultReviewers is where their UUIDs come from — braced account UUIDs and nothing else,
never a display name turned into one by guessing. Listing them is not a reason to add them.createPullRequest — title and sourceBranch are the only required arguments, and omitting
destinationBranch targets the main branch. The result carries url: the link to hand a human,
and the one value that cannot be derived.updatePullRequest to amend it afterwards. reviewers REPLACES the list, so send the existing
ones too — or [] to remove everyone — and the call overwrites anything edited in the browser
meanwhile, so read first. It is
also the only way to reach closeSourceBranch and draft once the pull request exists:
draft=false marks a draft ready for review, and closeSourceBranch=true makes the merge delete
the branch. An omitted flag keeps its current value, so either one is a complete update on its
own — no need to resend the title to make the call legal.waitForPipeline once with commit set to the commit just pushed, instead of
polling listPipelines or getPipeline. It picks up that commit's newest run once Bitbucket has
created it, and returns the run finished, in getPipeline's shape — so step 3 below is done.completed is false, call it
again with the pipeline its hint names, and do other work in between when there is some.PAUSED run is waiting for someone to start a manual step. Waiting will not end it, so say so
instead of calling again.bitbucket-pipelines.yml matched the
commit's branch, or Pipelines is off for the repository. Waiting longer changes neither.The order matters more here than anywhere else, because the last step is the expensive one and is usually unnecessary.
listPullRequestStatuses, if the starting point is a pull request — it says whether CI is red
without spending a pipeline call.listPipelines to find the run. targetBranch is the pull request's sourceBranch; commit
is its sourceCommit, which is more precise when the branch has moved on. status takes the
same words results report (FAILED, SUCCESSFUL, RUNNING, …), and an unrecognised one is
refused rather than silently matching nothing. An empty list means the repository has never run
a pipeline — not that the build failed.getPipeline on that run. It returns the steps and failedStepUuid in one call. Read the
failing step's errorMessage before going further: "the step timed out", "the image could not
be pulled" and their kind are the whole answer, and reading a log to rediscover them wastes a
large fraction of the context budget. When the failed step runs tests, pass
includeTestReport=true. Its counts say whether the tests are what failed, and failedTests
names the ones that did, with the message and the stack trace that point at the file and line:
read that code locally rather than the log. Search the step's log with pattern set to the
test framework's failure line (FAIL, FAILED, Tests run:) only for what the list leaves
out, which the hint names. When every test passed, the step broke somewhere else.listCodeInsights with the run's commitHash — often faster than any log, because a linter,
scanner or test reporter names the file, the line and the message directly. It also needs no
scope the pull-request tools do not already have, so it works when step 5 answers 403.getPipelineStepLog last, with stepUuid set to failedStepUuid. It returns the end of
the log by default, which is where a step running under set -e reports what broke. When the
failure is not at the end, pass pattern — a literal, case-insensitive substring, not a regular
expression — to search the whole log instead; supplying it selects search mode on its own.
mode="head" is only for a container that died before producing output of its own.Never ask for a whole log. The response is always capped at maxLines, and a cut is marked inside
the text and flagged by truncated — a truncated log must never be reported as the whole log. If
the answer is not in the tail, search for it; do not raise maxLines repeatedly.
nextCursor back as cursor, byte for byte; never edit,
decode or invent one. Every filter is already encoded inside it.workspace and repository are URL slugs — the two segments of
bitbucket.org/{workspace}/{repository}, not display names. A 404 on a repository you can see in
a browser is usually this.pageSize is clamped to 1–50. Fetch a second page because the first one
ran out, not to be thorough.git is free and instant, and every tool here is a
network round trip against an hourly rate limit. Use the server for what lives on bitbucket.org —
pull request state, reviewers, comments, tasks, build statuses.getPullRequestDiff with no paths, then name
files.codeSnippet. The error lists the candidate lines: copy more of
the line and repeat, or fall back to line plus lineType. Do not guess a line number.pipeline OAuth scope, or read:pipeline:bitbucket on an
API token. Widening an OAuth consumer does not widen a grant that was already cached, so it takes
bitbucket-mcp logout then bitbucket-mcp login; an API token's scopes cannot be edited at all,
so it takes a new token. listCodeInsights needs neither and often answers the question anyway.getPipelineStepLog. The step has produced no log yet, or never started. Check the
step's state with getPipeline rather than retrying.bitbucket-mcp login, or the token environment variables — see
Authentication in the server's README.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub lahma/bitbucket-mcp --plugin bitbucket-mcp