bitbucket-mcp
Provides tools for managing Bitbucket Cloud pull requests, including reading PR metadata and diffs, posting and replying to comments (general and inline), editing PR titles and descriptions, and viewing pipeline step logs to debug build failures.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@bitbucket-mcp summarize PR 42 in this repo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
bitbucket-mcp
A Model Context Protocol server for Bitbucket Cloud, optimized for use with Claude Code. Lets the agent read pull request diffs, read and write PR comments (including file + line inline comments), edit the PR Overview (title and description), resolve and unresolve comment threads, find Pipelines builds and read their step logs, check whether a commit is green, and re-run a build.
Status: alpha. Distributed on npm as @mcpkits/bitbucket.
Tools
Read-only:
Tool | Description |
| Fetch a PR's metadata (title, state, author, branches, URL). |
| List PRs filtered by state, author, or branch. |
| Unified diff for a PR, with |
| All comments on a PR (general + inline). |
| Find pipelines by PR, branch, commit, or build number, with each step's UUID and pass/fail. |
| Log output for a pipeline step, with |
| Commit build statuses rolled up to one verdict — "is this commit green?". |
Write:
Tool | Description |
| Post a general comment on a PR. |
| Post a comment on a specific file + line in a PR's diff. |
| Post a threaded reply to an existing PR comment (general or inline). |
| Open a new PR. Defaults source to the current git branch. |
| Update a PR's title, description (Overview), and/or reviewers list. |
| Mark a PR as draft or ready for review. |
| Mark a PR comment resolved or unresolved. |
| Start a build: re-run a branch's pipeline or run a |
All tools accept optional workspace and repo. When you run the server from inside a git checkout, those are inferred from the origin remote. PR-scoped tools accept an optional pr_id; when omitted, the server resolves it by listing open PRs whose source branch matches the current checked-out branch.
Finding pipelines
Most repos have no pull-requests: section in bitbucket-pipelines.yml, so their builds fire on branch push and Bitbucket cannot attribute any pipeline to a PR. list_pipelines handles that: when nothing is attributable to the PR it falls back to the most recent pipelines on the PR's source branch and reports what it did.
match: "pr_head_commit"— the pipeline was PR-triggered or built the PR's head commit.match: "branch_fallback"— these built the source branch, not the PR. Each entry carriesis_requested_commitso you can tell whether it built the commit you asked about.match: "none"— no pipeline ran at all. Distinct from the fallback case, and never silently an empty list.
You can also scope it directly with branch, commit (short or full SHA), or build_number. Steps come back with their UUIDs and pass/fail state, which is what get_pipeline_step_log needs — and it accepts a plain build number in the pipeline_uuid slot, with or without curly braces on UUIDs.
Output size
Diffs and logs are the two things that can blow a context window, so both are capped and both can be narrowed:
get_pr_diff—stat_only: truefor a per-file summary,paths: ["src/foo"]to fetch part of a diff,max_bytes(default 100 KB, keeps the head) otherwise.get_pipeline_step_log—tail_lines: 50for just the end of a failing step,max_bytes(default 100 KB, keeps the tail). To learn only whether a step passed, uselist_pipelinesinstead: it returns each step's state, result, and duration without fetching any log.
Deliberately not included
There is no merge_pr and no set_pr_approval. Merging into a shared branch and approving someone's code are decisions we want a human to keep making, so this server cannot do either.
Related MCP server: Bitbucket MCP Server
Setup
Requires Node 22+.
Solo (you create your own OAuth consumer)
npx -y @mcpkits/bitbucket setupThe wizard:
Opens your browser to your workspace's OAuth consumers page; you create a private consumer with the listed scopes and paste back its key + secret.
Opens the browser again to authorize; you click Grant access.
Detects
claudeonPATHand offers to register the server with Claude Code automatically (user scope).
Restart Claude Code (or open a new session) and you're done.
Team (shared OAuth consumer)
If your team already keeps a Bitbucket OAuth consumer in your password manager, pass the key and secret as env vars and setup will skip the consumer-creation step:
BITBUCKET_CLIENT_KEY=... \
BITBUCKET_CLIENT_SECRET=... \
npx -y @mcpkits/bitbucket setupYou'll be prompted to confirm before the env vars are used.
Migrating from a previous local-build install
Just run npx -y @mcpkits/bitbucket setup. It detects an existing local-dist registration in ~/.claude.json, skips OAuth (your tokens in ~/.config/bitbucket-mcp/config.json are reused), and rewrites the registration to use npx. No re-auth needed.
Other MCP hosts (Claude Desktop, Cursor, etc.)
Add this to your host's MCP config:
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["-y", "@mcpkits/bitbucket"]
}
}
}For the OAuth credentials and tokens, run npx -y @mcpkits/bitbucket setup once first; they're stored in ~/.config/bitbucket-mcp/config.json and used by every invocation regardless of host.
Config file
Stored at $XDG_CONFIG_HOME/bitbucket-mcp/config.json if XDG_CONFIG_HOME is set, otherwise ~/.config/bitbucket-mcp/config.json. Mode 0600; parent dir mode 0700.
{
"clientKey": "...",
"clientSecret": "...",
"tokens": {
"accessToken": "...",
"refreshToken": "...",
"expiresAt": 1712345678000,
"scopes": [
"account",
"repository",
"pullrequest",
"pullrequest:write",
"pipeline",
"pipeline:write"
]
}
}Never commit this file. Never share it.
Usage
Once registered and loaded, ask the agent things like:
"Summarize PR 42 in this repo."
"What did my latest pipeline fail on?" → the model calls
list_pipelines, thenget_pipeline_step_logon the failing step (or with nostep_uuidat all, which picks the failing step for it)."Is this commit green?" →
get_build_status."Re-run the build, that step is flaky." →
run_pipeline."Leave a comment on line 17 of
src/foo.tsin PR 42 saying 'this needs a null check'." → the model callsadd_pr_inline_comment.
If you're inside a git checkout of the Bitbucket repo, you typically don't need to pass workspace, repo, or pr_id — the server infers them.
Build
End users don't need to clone or build — install via
npx -y @mcpkits/bitbucket setup. This section is for contributors.
Requires Node 22+ and Vite+ (vp).
vp install # install deps
vp check # lint + typecheck
vp test # run tests
vp pack # bundle to dist/bitbucket-mcp.mjsThe build produces a single executable file at dist/bitbucket-mcp.mjs with a #!/usr/bin/env node shebang and the executable bit set.
Subcommands
bitbucket-mcp(no args) /serve— run the MCP server over stdio.setup— interactive wizard. Detects existing OAuth tokens and Claude Code registration to choose between fresh install, migration, or re-registration. HonorsBITBUCKET_CLIENT_KEY+BITBUCKET_CLIENT_SECRETenv vars for team-shared OAuth consumers (asks before using).credentials --key <KEY>— non-interactive: read the secret from stdin (or$BITBUCKET_CLIENT_SECRET), persist both to the config file.authorize— run the OAuth flow using stored credentials; open browser, wait for callback, persist tokens.print-config— emit the JSON payload forclaude mcp add-json bitbucket --scope user.help— show usage.
Security notes
OAuth tokens and consumer secret live in a
0600file in your home directory. No env vars, no shell history.The OAuth callback listener binds only to
127.0.0.1. Thestateparameter is a 32-byte cryptographic random and compared in constant time.Tokens are refreshed transparently. If a refresh fails (e.g. the consumer was revoked), the MCP clears the tokens and asks you to re-run
npx -y @mcpkits/bitbucket setup.run_pipelineneeds thepipeline:writescope. If you set this server up before that scope was requested, re-runnpx -y @mcpkits/bitbucket setup, tick Pipelines → Write on the consumer, and re-authorize. Everything else keeps working without it.This is a Bitbucket Cloud client — Bitbucket Server / Data Center is not supported.
License
MIT
Available Tools
15 toolsadd_pr_commentAdd PR commentA
Post a general comment on a pull request (not tied to a specific file or line). For inline file/line comments, use add_pr_inline_comment.
Inputs: body (required), repo, pr_id, workspace.
add_pr_inline_commentAdd PR inline commentA
Post a comment on a specific file and line within a pull request's diff. Use get_pr_diff first if you need to confirm line numbers are present in the diff. For general PR comments, use add_pr_comment.
Inputs: body (required), line (required), path (required), repo, +3 more.
create_prCreate PRA
Open a new pull request. source_branch defaults to the current git branch when run from inside a checkout. destination_branch defaults to the repository's configured main branch on Bitbucket. description is interpreted as Markdown. reviewers is a list of Bitbucket account UUIDs (including the curly braces).
Inputs: title (required), repo, reviewers, workspace, +4 more.
get_build_statusGet build statusARead-onlyIdempotent
Answer "is this commit green?" in one call, using Bitbucket's commit build statuses (Pipelines results plus anything else that posts a status). Pass commit (a SHA) or pr_id; with neither, it uses the current checkout's HEAD. verdict is FAILED / INPROGRESS / STOPPED / SUCCESSFUL / NO_STATUSES. NO_STATUSES means nothing posted a status — check list_pipelines before concluding a build did not run.
Inputs: repo, pr_id, commit, workspace.
get_pipeline_step_logGet pipeline step logARead-onlyIdempotent
Fetch the log output of a pipeline step. pipeline_uuid accepts either a pipeline UUID or a plain build number (e.g. 27419); UUIDs work with or without curly braces. Omit step_uuid to get the first failed step's log (or the last step when everything passed). Use tail_lines when you only need the end of the log — that is where failures are. Output is capped at max_bytes (default 100 KB), keeping the end of the log. If you only need whether a step passed, use list_pipelines instead — it returns step state without any log.
Inputs: pipeline_uuid (required), repo, max_bytes, step_uuid, +2 more.
get_prGet PRARead-onlyIdempotent
Fetch a Bitbucket pull request's metadata (title, state, author, branches, description, URL).
Inputs: repo, pr_id, workspace.
get_pr_diffGet PR diffARead-onlyIdempotent
Fetch the unified diff for a pull request. For a large PR, start with stat_only: true to see which files changed and how big the diff is, then pass paths to fetch only the parts you need. Output is capped at max_bytes (default 100 KB) and the tail is dropped with a note when it overflows.
Inputs: repo, paths, pr_id, max_bytes, +2 more.
list_pipelinesList pipelinesARead-onlyIdempotent
Find Bitbucket Pipelines builds and their per-step pass/fail state. Scope it with build_number (exact build), commit (SHA, short or full), branch, or pr_id — with none of those it uses the PR for the current branch. PR lookups do not require the repo to have a pull-requests: trigger: when no pipeline is attributable to the PR, this falls back to the most recent pipelines on the PR's source branch and says so in match and note. match: "none" means no pipeline ran at all — distinct from a fallback. Steps include their UUIDs, so this is where you get the arguments for get_pipeline_step_log.
Inputs: repo, limit, pr_id, branch, +4 more.
list_pr_commentsList PR commentsARead-onlyIdempotent
List all comments on a pull request, including general and inline (file+line) comments. Returns comments sorted oldest-first.
Inputs: repo, limit, pr_id, workspace.
list_prsList PRsARead-onlyIdempotent
List pull requests in a Bitbucket repository. Filter by state, author UUID, or branch. Returns up to limit results sorted newest first.
Inputs: repo, limit, state, author, +2 more.
reply_to_pr_commentReply to PR commentA
Reply to an existing PR comment, creating a threaded reply. For inline comments, the path and line are inherited from the parent — do not use add_pr_inline_comment to reply, since that posts a sibling comment instead of a threaded reply.
Inputs: body (required), comment_id (required), repo, pr_id, +1 more.
resolve_pr_commentResolve PR commentAIdempotent
Mark a PR comment as resolved or unresolved. Defaults to resolved=true. Use list_pr_comments to see current resolution state.
Inputs: comment_id (required), repo, pr_id, resolved, +1 more.
run_pipelineRun pipelineADestructive
Start a Bitbucket pipeline — a re-run of a branch's build, or a definition from the custom: section of bitbucket-pipelines.yml. branch defaults to the current git branch; commit pins the build to a specific SHA instead of the branch tip. Consumes build minutes and can deploy, so confirm with the user before running a custom pipeline you did not pick out together. Requires the pipeline:write OAuth scope (re-run bitbucket-mcp setup if the server was set up before that scope existed).
Inputs: repo, branch, commit, variables, +2 more.
set_pr_draft_stateSet PR draft stateAIdempotent
Mark a pull request as draft or ready for review. Pass draft: true to convert to draft, or draft: false to mark ready.
Inputs: draft (required), repo, pr_id, workspace.
update_prUpdate PRA
Update a pull request's title, description (the PR Overview), and/or reviewers. Pass any combination — fields you omit are left unchanged. The description is interpreted as Markdown. reviewers replaces the full reviewer list with the given Bitbucket account UUIDs (including the curly braces); pass an empty array to clear all reviewers.
Inputs: repo, pr_id, title, reviewers, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Every tool targets a distinct action and resource (e.g., general vs. inline vs. threaded replies for PR comments, pipeline listing vs. step logs vs. build status). Descriptions explicitly cross-reference related tools to prevent misselection, such as clarifying when to use list_pipelines over get_build_status.
All tool names follow a consistent verb_noun snake_case convention (e.g., get_pr, list_prs, add_pr_comment, run_pipeline). The verbs are clear and reused predictably across resource types, and pluralization follows natural language without breaking the pattern.
With 15 tools, the server covers a broad but focused domain—pull requests and pipelines. Each tool provides a distinct capability, and the count sits at the upper boundary of the optimal 3–15 range without feeling bloated or sparse.
The surface covers the full PR lifecycle (create, read, update, draft state, diff, comments) and pipeline operations (list, logs, run, build status). There are no obvious dead ends; even edge cases like large diffs and pipeline fallback behavior are addressed with dedicated parameters.
Maintenance
Related MCP Connectors
The Buildkite MCP server exposes Buildkite product data (pipelines, builds, jobs, and test data) to AI tools, editors, and agents through the Model Context Protocol. It provides capabilities including pipeline creation and management, build monitoring with specialized tools like 'wait_for_build', efficient log querying using Apache Parquet conversion and caching, and OAuth-based authentication for both read-write and read-only access to Buildkite's REST API.
A Model Context Protocol (MCP) application for automated GitHub PR analysis and issue management.…
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseDqualityDmaintenanceA Model Context Protocol server that enables AI assistants to interact with Bitbucket repositories, pull requests, and other resources through Bitbucket Cloud and Server APIs.36,532 npm168MIT
- AlicenseBqualityCmaintenanceAn MCP server that enables interaction with Bitbucket repositories through the Model Context Protocol, supporting both Bitbucket Cloud and Server with features for PR lifecycle management and code review.208,411 npm30MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that integrates Cursor IDE with Bitbucket Cloud, allowing developers to fetch repository information and commit data directly from their Bitbucket workspace.15181 npm4MIT
- AlicenseBqualityCmaintenanceA Model Context Protocol (MCP) server that provides tools for interacting with Bitbucket repositories, pull requests, issues, and more.1741 npmISC