bitbucket-mcp
Provides tools for interacting with Bitbucket Cloud, including browsing workspaces, repositories, branches, and pull requests, as well as creating and updating pull requests and posting pull request comments.
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 list open pull requests in my workspace"
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
MCP (Model Context Protocol) server for Bitbucket Cloud. Exposes workspace, repository, branch, and pull request operations as MCP tools so an MCP client (Claude Code, Codex, etc.) can browse and interact with Bitbucket Cloud on your behalf, plus a small set of local-only tools to manage multiple Bitbucket workspace "profiles" without editing config by hand.
This is an MVP: read-heavy tool surface, a focused set of write tools (comments and pull request creation/update), no merge/approve/decline, issues, pipelines, or webhooks. See Out of scope below.
Quick start
Published on npm — no need to clone this repo. Point your MCP client at it
with npx, passing BITBUCKET_EMAIL and BITBUCKET_TOKEN as environment
variables (see Using this server from an MCP
client for the full config JSON).
See Creating a Bitbucket API token if you
don't have one yet.
{ "command": "npx", "args": ["-y", "@jonathanduran7/bitbucket-mcp"] }Related MCP server: bitbucket-standalone-mcp
Installation
From npm (recommended)
Requires Node.js >= 20. No local clone/build needed — npx downloads and
caches the package on first run:
npx -y @jonathanduran7/bitbucket-mcpFrom source
git clone https://github.com/jonathanduran7/bitbucket-mcp.git
cd bitbucket-mcp
npm install
npm run build # compiles src/ -> dist/ via tscFor local development without building first, you can also run it directly
with npx tsx src/index.ts (requires tsx — not a project dependency by
default, install it ad hoc with npx -y tsx src/index.ts if you don't have
it globally).
Environment variables
Variable | Required | Description |
| Yes | Atlassian account email used for Basic Auth. |
| Yes | Bitbucket API token (see below). Never an app password. |
| No | Overrides where |
| No | Process-level override for workspace resolution. Takes precedence over the active profile's default, but not over an explicit |
The server fails fast at startup if BITBUCKET_EMAIL or BITBUCKET_TOKEN
is missing, naming the missing variable — it never starts accepting tool
calls without valid credentials configured.
Creating a Bitbucket API token
Bitbucket Cloud app passwords are deprecated (disabled starting
2026-06-09). This server authenticates exclusively with an API token
over Basic Auth (email:api_token).
Create a token scoped for Bitbucket. Double-check the exact granular scope names shown at creation time — classic and granular scopes currently coexist, and the names differ slightly. At minimum you need:
account/read:workspace— forlist_workspacesrepository(read) — for repository and branch toolspullrequest(read) — for PR read tools, commits, diff, commentspullrequest:write— forcreate_pr_comment,create_pull_request,update_pull_request
Set
BITBUCKET_EMAILto the Atlassian account email andBITBUCKET_TOKENto the generated token.
Profiles (profiles.json)
Profiles let you keep more than one default workspace (e.g. personal vs
work) without passing workspace on every call, and switch between them
with a tool call instead of editing a file.
Location:
${XDG_CONFIG_HOME:-~/.config}/bitbucket-mcp/profiles.json, overridable viaBITBUCKET_PROFILES_PATH.Format — see
profiles.example.jsonfor a full example with fictitious data:{ "version": 1, "activeProfile": "personal", "profiles": { "personal": { "defaultWorkspace": "my-workspace", "defaultRepo": "my-repo" } } }Credentials never go in this file.
BITBUCKET_EMAIL/BITBUCKET_TOKENalways come from the environment —profiles.jsononly ever stores workspace/repo defaults per named profile.Permissions: the containing directory is created/kept at
0700and the file itself at0600, re-applied on every write (not only on creation). Writes are atomic (profiles.json.tmp+rename) so a crash mid-write never corrupts the file.Missing file → treated as empty state in memory, not an error (no profiles configured yet). Corrupt file → an actionable error naming the file path; the file is left untouched, never overwritten.
This MVP has no
set_active_profile-creates-profile flow — seedprofiles.jsonby copyingprofiles.example.jsoninto place (respecting the permissions above) and editing it before using the profile tools.
Switching the active profile
set_active_profile({ profile: "work" })— switches to an existing profile. Errors with an actionable message (listing available profiles) if the name doesn't exist; the active profile is left unchanged on error.get_active_profile()— returns the current active profile and its resolved defaults, or an explicit "no active profile" result.set_default_workspace({ workspace: "acme-ws" })— persists a default workspace on the active (or an explicitly named) profile.clear_default_workspace()— removes the persisted default. Idempotent: calling it twice with nothing set does not error.
workspace vs repo resolution
workspace has a 4-level precedence: explicit tool argument > process
env override (BITBUCKET_WORKSPACE) > active profile's default > actionable
error (no HTTP request is ever attempted on the error path).
repo is always an explicit, required tool argument on every tool that
needs one — it has no env override and no profile-default
auto-application, even though a profile may record a defaultRepo for your
own reference (surfaced by list_profiles/get_active_profile). This is a
deliberate asymmetry: workspace-level defaults make sense for "my usual
workspace", but silently defaulting the repository you're about to read
or write against was judged too easy to get wrong.
Using this server from an MCP client
The server communicates over stdio. Example configuration (Claude Code / Codex-style JSON config), using the published npm package — no clone or build required:
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["-y", "@jonathanduran7/bitbucket-mcp"],
"env": {
"BITBUCKET_EMAIL": "you@example.com",
"BITBUCKET_TOKEN": "your-api-token-here"
}
}
}
}If you built it from source instead, point command/args at the compiled
output:
{ "command": "node", "args": ["/absolute/path/to/bitbucket-mcp/dist/index.js"] }For local development without a build step, swap command/args for:
{ "command": "npx", "args": ["-y", "tsx", "/absolute/path/to/bitbucket-mcp/src/index.ts"] }Tools
18 tools total: 13 talk to the Bitbucket API, 5 are local-only (never make a
network call, only read/write profiles.json).
Read-only (Bitbucket)
Tool | Description |
| Lists every workspace the credentials can access. No arguments. |
| Lists every repository in a workspace, fully paginated. |
| Details for a single repository ( |
| Lists every branch in a repository, fully paginated. Optional |
| Details for a single branch ( |
| Lists PRs in a repository, filterable by |
| Full metadata for a single PR. |
| Every commit on a PR, fully paginated. |
| Unified diff as plain text, capped at 100,000 chars by default ( |
| Every comment (inline + general) on a PR, fully paginated. |
Write (Bitbucket)
Tool | Description |
| Posts a comment on a PR. Rejects empty content before any Bitbucket call. |
| Opens a PR. Verifies source and destination branches exist first — never leaves a partial PR behind. |
| Updates title/description/destination branch/reviewers only. Explicitly rejects |
Local-only (never touch Bitbucket)
Tool | Description |
| Lists configured profiles and their defaults. |
| Returns the active profile's name and defaults. |
| Switches the active profile (must already exist). |
| Persists a default workspace on a profile. |
| Removes a profile's default workspace. Idempotent. |
set_active_profile, set_default_workspace, and clear_default_workspace
are marked readOnly from Bitbucket's point of view (they never touch the
Bitbucket API) but flagged mutatesLocalConfig: true, so they do write to
profiles.json on disk even though they carry the MCP readOnlyHint
w.r.t. the remote API.
get_pr_diff size limit
get_pr_diff returns a plain-text unified diff. To stay well inside any MCP
client's context budget it is truncated by default at 100,000 characters
(~25k tokens), always cut at the last full line before the limit so no line
is ever split mid-way. Pass maxChars to raise the limit, up to a hard cap
of 400,000. The response always includes { diff, truncated, returnedChars, hint? } — a truncated diff can never be mistaken for the
complete one. On very large diffs Bitbucket itself may time out (HTTP 555);
prefer get_pr_commits for a per-commit view, or retry with a smaller
maxChars, instead of repeatedly retrying the same large diff.
Manual smoke test
Because this server talks to the real Bitbucket API, end-to-end behavior is verified manually against real workspaces rather than with automated integration tests (see Testing below). Checklist:
npm install && npm run build.Set
BITBUCKET_EMAIL/BITBUCKET_TOKEN(API token) in the environment your MCP client launches the server with.Optionally seed
profiles.jsonby copyingprofiles.example.jsoninto${XDG_CONFIG_HOME:-~/.config}/bitbucket-mcp/profiles.jsonand editing it with a real profile name and a workspace slug you have access to.Point your MCP client at
node dist/index.jsas a stdio MCP server (see the config example above).Against at least two real, accessible workspaces, exercise every tool and confirm each response is well-formed with no thrown exceptions and no credential values ever appearing in any response or error message:
list_workspaces,list_profiles,get_active_profile,set_active_profile(including a nonexistent-profile error case),set_default_workspace,clear_default_workspace(including the idempotent no-op case),list_repositories,get_repository(including a not-found case),list_branches,get_branch,list_pull_requests,get_pull_request,get_pr_commits,get_pr_diff,list_pr_comments,create_pr_comment,create_pull_request,update_pull_request(including the rejected-statecase).
Testing
npm run typecheck # tsc --noEmit
npm test # vitest runAutomated tests are unit-only, covering the purest and most
error-prone logic in the system with an injected fetch/ProfileStore —
no real HTTP call is ever made in the test suite:
src/config/context.test.ts— the 4-levelworkspaceprecedence (arg > env > active profile > actionable error).src/bitbucket/pagination.test.ts—next-link traversal (full URL, never a hand-built?page=N), multi-page aggregation, single-page termination.src/bitbucket/errors.test.ts— HTTP status code → typed error mapping (401/403 →AuthError, 404 →NotFoundError, 429 →RateLimitError, 555/5xx →UpstreamTimeoutError, network failure →NetworkError, missing credentials →ConfigErrorbefore any request), plus a check that no thrown error ever contains the configured email or token.
Tool handlers and end-to-end HTTP behavior are not covered by automated tests in this MVP — that's the manual smoke test above.
Out of scope / next steps
Deliberately not implemented in this MVP:
Approving, declining, or merging pull requests (
update_pull_requestexplicitly rejects anystatechange).Issues.
Pipelines.
Webhooks.
A
create_profiletool — profiles are seeded by hand (copyprofiles.example.json, edit, place at the resolvedprofiles.jsonpath).Automated integration/E2E tests against the real Bitbucket API (no fixtures exist for it yet — verification is the manual checklist above).
Available Tools
18 toolsclear_default_workspaceA
Removes the persisted default workspace from the active (or explicitly named) profile. Idempotent. Purely local — never calls Bitbucket.
Inputs: profile.
create_pr_commentA
Posts a new comment on a pull request. Requires non-empty content — validated before any Bitbucket call. WRITE tool.
Inputs: repo (required), pr_id (required), content (required), workspace.
create_pull_requestA
Opens a new pull request. Requires title, sourceBranch, and destinationBranch; both branches are verified to exist before the PR is created so no partial PR is ever left behind. WRITE tool.
Inputs: repo (required), title (required), sourceBranch (required), destinationBranch (required), +5 more.
get_active_profileARead-only
Returns the currently active profile's name and resolved defaults, if any.
Inputs: no named parameters.
get_branchARead-only
Returns details for a specific branch. Requires repo and branch, and resolves workspace via the standard precedence.
Inputs: repo (required), branch (required), workspace.
get_pr_commitsBRead-only
Lists every commit belonging to a pull request, fully paginated. Requires an explicit repo argument.
Inputs: repo (required), pr_id (required), workspace.
get_pr_diffARead-only
Returns the unified diff for a pull request as plain text, capped by default at 100,000 characters (maxChars, hard cap 400,000). Truncation always lands on a line boundary and the response always reports truncated/returnedChars so a truncated diff is never mistaken for the complete one. On very large diffs Bitbucket may time out (HTTP 555); prefer get_pr_commits or a smaller maxChars instead of retrying.
Inputs: repo (required), pr_id (required), maxChars, workspace.
get_pull_requestARead-only
Returns full metadata for a single pull request. Requires repo and pr_id, and resolves workspace via the standard precedence.
Inputs: repo (required), pr_id (required), workspace.
get_repositoryARead-only
Returns details for a specific repository. Requires repo and resolves workspace via the standard precedence.
Inputs: repo (required), workspace.
list_branchesARead-only
Lists every branch in a repository, fully paginated. Resolves workspace via the standard precedence (explicit argument > env override > active profile default > error) if not provided. Requires an explicit repo argument. Accepts an optional name filter (partial match) applied via Bitbucket's query language.
Inputs: repo (required), name, workspace.
list_pr_commentsARead-only
Lists every comment (inline and general) on a pull request, fully paginated. Requires an explicit repo argument.
Inputs: repo (required), pr_id (required), workspace.
list_profilesARead-only
Lists every configured local profile and its defaults. Never contacts Bitbucket.
Inputs: no named parameters.
list_pull_requestsARead-only
Lists pull requests in a repository, fully paginated. Requires an explicit repo argument and resolves workspace via the standard precedence. Filters by state (OPEN | MERGED | DECLINED | SUPERSEDED), defaulting to "OPEN".
Inputs: repo (required), state, workspace.
list_repositoriesARead-only
Lists every repository in a workspace, fully paginated. Resolves workspace via the standard precedence (explicit argument > BITBUCKET_WORKSPACE env override > active profile default > error) if not provided.
Inputs: workspace.
list_workspacesARead-only
Lists every Bitbucket workspace the authenticated credentials can access, fully paginated. Takes no arguments.
Inputs: no named parameters.
set_active_profileA
Switches the active profile to an existing profile. Purely local — never calls Bitbucket.
Inputs: profile (required).
set_default_workspaceA
Persists a default workspace on the active (or explicitly named) profile. Purely local — never calls Bitbucket.
Inputs: workspace (required), profile.
update_pull_requestA
Updates a pull request's title, description, destination branch, and/or reviewers. Does NOT support merge, approve, or decline — passing a state is explicitly rejected. WRITE tool.
Inputs: repo (required), pr_id (required), state, title, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool targets a distinct resource and action: local profile operations are clearly separated from Bitbucket API operations, and list/get/create/update verbs are consistently paired with specific objects like workspaces, repositories, branches, pull requests, and comments. There is no meaningful overlap or ambiguous boundary between tools.
Tool names mostly follow a consistent list_/get_/create_/update_/set_/clear_ verb_noun pattern, which is predictable and readable. The main deviation is mixing 'pr' and 'pull_request' across related tools (e.g. get_pr_commits vs get_pull_request), which slightly weakens consistency.
At 18 tools, the set is slightly above the ideal 3–15 range, but each tool addresses a distinct need across workspaces, repositories, branches, pull requests, comments, and local profile configuration. The count feels slightly heavy but not bloated.
The read side is well covered, and pull request creation plus commenting are supported, but notable lifecycle operations are missing: merge/approve/decline for pull requests, repository/branch write operations, and profile creation/deletion. These gaps prevent full CRUD/lifecycle coverage of the apparent Bitbucket domain.
Maintenance
Related MCP Connectors
One OAuth connector for your team's remote MCP servers, with Tool Packs, guardrails and logs.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
Read and write shared BitsWeave context, projects, tasks, and work sessions through MCP.
Discover, plan and run tools across your connected business systems through one OAuth MCP endpoint
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables MCP-compatible clients to read repositories and source code from Bitbucket. Provides tools for listing workspaces and repositories, browsing directories, reading files, searching code, and inspecting commits and pull requests.12ISC
- FlicenseBqualityCmaintenanceEnables interaction with a Bitbucket Server/Data Center instance, exposing its REST v1.0 API as MCP tools to manage projects, repositories, branches, pull requests, comments, diffs, commits, files, search, and build status.41-
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with Bitbucket Cloud workspaces, repositories, pull requests, branches, commits, and code for listing, retrieval, commenting, searching, diffing, and repository cloning through MCP tools.-
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with Bitbucket Cloud workspaces, repositories, and pull requests by providing MCP tools for listing, reading, creating, commenting, searching, and cloning.MIT