
Connects Claude, Copilot, and Cursor to Bitbucket Cloud through 45 tools covering repos, pull requests, comments, pipelines, and build statuses. You can review PRs, post inline comments, approve or request changes, run pipelines, and query CI status all through natural language. The server strips API noise for lower token usage and lets you filter diffs by file path to cut tokens by 95% on large PRs. Ships with safety guards on destructive operations like merging and pipeline stops. Runs via uvx with zero install, supports scoped API tokens, and includes batch review and draft PR workflows. Built for teams doing code review and CI monitoring from their AI assistant.
Public tool metadata for what this MCP can expose to an agent.
BITBUCKET_CREATE_BRANCHCreates a new branch in a Bitbucket repository from a target commit hash; the branch name must be unique, adhere to Bitbucket's naming conventions, and not include the 'refs/heads/' prefix.4 paramsCreates a new branch in a Bitbucket repository from a target commit hash; the branch name must be unique, adhere to Bitbucket's naming conventions, and not include the 'refs/heads/' prefix.
namestringrepo_slugstringtarget_hashstringworkspacestringBITBUCKET_CREATE_ISSUECreates a new issue in a Bitbucket repository, setting the authenticated user as reporter; ensures assignee (if provided) has repository access, and that any specified milestone, version, or component IDs exist.11 paramsCreates a new issue in a Bitbucket repository, setting the authenticated user as reporter; ensures assignee (if provided) has repository access, and that any specified milestone, version, or component IDs exist.
assigneestringcomponent_idintegercontentstringdue_onstringkindstringmilestone_idintegerprioritystringrepo_slugstringtitlestringversion_idintegerworkspacestringBITBUCKET_CREATE_ISSUE_COMMENTAdds a new comment with markdown support to an existing Bitbucket issue.4 paramsAdds a new comment with markdown support to an existing Bitbucket issue.
contentstringissue_idstringrepo_slugstringworkspacestringBITBUCKET_CREATE_PULL_REQUESTCreates a new pull request in a specified Bitbucket repository, ensuring the source branch exists and is distinct from the (optional) destination branch.8 paramsCreates a new pull request in a specified Bitbucket repository, ensuring the source branch exists and is distinct from the (optional) destination branch.
close_source_branchbooleandescriptionstringdestination_branchstringrepo_slugstringreviewersarraysource_branchstringtitlestringworkspacestringBITBUCKET_CREATE_REPOSITORYCreates a new Bitbucket 'git' repository in a specified workspace, defaulting to the workspace's oldest project if `project_key` is not provided.9 paramsCreates a new Bitbucket 'git' repository in a specified workspace, defaulting to the workspace's oldest project if `project_key` is not provided.
descriptionstringfork_policystringallow_forks · no_public_forks · no_forksdefault: allow_forkshas_issuesbooleanhas_wikibooleanis_privatebooleanlanguagestringproject_keystringrepo_slugstringworkspacestringBITBUCKET_CREATE_SNIPPET_COMMENTPosts a new top-level comment or a threaded reply to an existing comment on a specified Bitbucket snippet.4 paramsPosts a new top-level comment or a threaded reply to an existing comment on a specified Bitbucket snippet.
contentstringencoded_idstringparent_idintegerworkspacestringBITBUCKET_DELETE_ISSUEPermanently deletes a specific issue, identified by its `issue_id`, from the repository specified by `repo_slug` within the given `workspace`.3 paramsPermanently deletes a specific issue, identified by its `issue_id`, from the repository specified by `repo_slug` within the given `workspace`.
issue_idstringrepo_slugstringworkspacestringBITBUCKET_DELETE_REPOSITORYPermanently deletes a specified Bitbucket repository; this action is irreversible and does not affect forks.2 paramsPermanently deletes a specified Bitbucket repository; this action is irreversible and does not affect forks.
repo_slugstringworkspacestringBITBUCKET_GET_CURRENT_USERRetrieves the profile information (UUID, display name, links, creation date) for the currently authenticated Bitbucket user.Retrieves the profile information (UUID, display name, links, creation date) for the currently authenticated Bitbucket user.
No parameter schema in public metadata yet.
BITBUCKET_GET_FILE_FROM_REPOSITORYRetrieves a specific file's content from a Bitbucket repository at a given commit (hash, branch, or tag), failing if the file path is invalid for that commit.4 paramsRetrieves a specific file's content from a Bitbucket repository at a given commit (hash, branch, or tag), failing if the file path is invalid for that commit.
commitstringpathstringrepo_slugstringworkspacestringBITBUCKET_GET_PULL_REQUESTGet a single pull request by ID with complete details.3 paramsGet a single pull request by ID with complete details.
pull_request_idintegerrepo_slugstringworkspacestringBITBUCKET_GET_SNIPPETRetrieves a specific Bitbucket snippet by its encoded ID from an existing workspace, returning its metadata and file structure.3 paramsRetrieves a specific Bitbucket snippet by its encoded ID from an existing workspace, returning its metadata and file structure.
accept_formatstringencoded_idstringworkspacestringBITBUCKET_LIST_PULL_REQUESTSLists pull requests in a specified, accessible Bitbucket repository, optionally filtering by state (OPEN, MERGED, DECLINED).5 paramsLists pull requests in a specified, accessible Bitbucket repository, optionally filtering by state (OPEN, MERGED, DECLINED).
pageintegerpagelenintegerrepo_slugstringstatestringOPEN · MERGED · DECLINEDworkspacestringBITBUCKET_LIST_REPOSITORIES_IN_WORKSPACELists repositories in a specified Bitbucket workspace, accessible to the authenticated user, with options to filter by role or query string, and sort results.4 paramsLists repositories in a specified Bitbucket workspace, accessible to the authenticated user, with options to filter by role or query string, and sort results.
qstringrolestringsortstringworkspacestringBITBUCKET_LIST_WORKSPACE_MEMBERSLists all members of a specified Bitbucket workspace; the workspace must exist.1 paramsLists all members of a specified Bitbucket workspace; the workspace must exist.
workspacestringBITBUCKET_LIST_WORKSPACESLists Bitbucket workspaces accessible to the authenticated user, optionally filtered and sorted.2 paramsLists Bitbucket workspaces accessible to the authenticated user, optionally filtered and sorted.
qstringsortstringBITBUCKET_UPDATE_ISSUEUpdates an existing issue in a Bitbucket repository by modifying specified attributes; requires `workspace`, `repo_slug`, `issue_id`, and at least one attribute to update.12 paramsUpdates an existing issue in a Bitbucket repository by modifying specified attributes; requires `workspace`, `repo_slug`, `issue_id`, and at least one attribute to update.
assignee_account_idstringcomponentstringcontentstringissue_idstringkindstringmilestonestringprioritystringrepo_slugstringstatestringtitlestringversionstringworkspacestringConnect Claude Code, OpenAI Codex, Cursor, VS Code (GitHub Copilot), and any MCP-compatible AI assistant to your Bitbucket Cloud repositories. Review pull requests, monitor pipelines, and manage your code — all through natural language.
readOnlyHint / destructiveHint / idempotentHint / openWorldHint + a human-readable title, so clients (Claude Code, Cursor) auto-include read-only tools and warn before destructive operationsconfigs/tools.json or BITBUCKET_TOOLS_CONFIG env varThe recommended way to run the server is via uvx (zero install, isolated environment):
# Always latest version
uvx --from bitbucket-mcp-py bitbucket-mcp
# Pin a specific version
uvx --from bitbucket-mcp-py==1.8.1 bitbucket-mcp
Why
--from? The PyPI package isbitbucket-mcp-pybut the command entry point isbitbucket-mcp. The--fromflag tells uvx which package to install.
| Mode | Command | Best for |
|---|---|---|
| pip global | pip install bitbucket-mcp-py | Simple, persistent install |
| Local dev | pip install -e . in project dir | Contributing to the project |
| Docker | See Docker section | Container-based workflows |
Set the following environment variables (or use a .env file — see Credentials):
| Variable | Description |
|---|---|
BITBUCKET_USERNAME | Your Bitbucket email |
BITBUCKET_TOKEN | Your Bitbucket API token |
BITBUCKET_WORKSPACE | Your workspace slug |
Get your API token at: https://id.atlassian.com/manage-profile/security/api-tokens
⚠️ Use a scoped token, not a global one. When creating the token, select specific scopes (e.g.
Repositories: Read,Pull requests: Read/Write). Global tokens without explicit scopes do not work with this MCP server.
Option A — CLI (fastest):
claude mcp add bitbucket-mcp \
-e BITBUCKET_USERNAME=your-email@example.com \
-e BITBUCKET_TOKEN=your-api-token \
-e BITBUCKET_WORKSPACE=your-workspace \
-- uvx --from bitbucket-mcp-py bitbucket-mcp
Option B — JSON config (~/.claude.json or project .mcp.json):
{
"mcpServers": {
"bitbucket-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "bitbucket-mcp-py", "bitbucket-mcp"],
"env": {
"BITBUCKET_USERNAME": "your-email@example.com",
"BITBUCKET_TOKEN": "your-api-token",
"BITBUCKET_WORKSPACE": "your-workspace"
}
}
}
}
Option A — CLI (fastest):
codex mcp add bitbucket-mcp \
--env BITBUCKET_USERNAME=your-email@example.com \
--env BITBUCKET_TOKEN=your-api-token \
--env BITBUCKET_WORKSPACE=your-workspace \
-- uvx --from bitbucket-mcp-py bitbucket-mcp
Option B — TOML config (~/.codex/config.toml):
[mcp_servers.bitbucket-mcp]
command = "uvx"
args = ["--from", "bitbucket-mcp-py", "bitbucket-mcp"]
env = { BITBUCKET_USERNAME = "your-email@example.com", BITBUCKET_TOKEN = "your-api-token", BITBUCKET_WORKSPACE = "your-workspace" }
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"bitbucket-mcp": {
"command": "uvx",
"args": ["--from", "bitbucket-mcp-py", "bitbucket-mcp"],
"env": {
"BITBUCKET_USERNAME": "your-email@example.com",
"BITBUCKET_TOKEN": "your-api-token",
"BITBUCKET_WORKSPACE": "your-workspace"
}
}
}
}
Add to .vscode/mcp.json (workspace) or ~/Library/Application Support/Code/User/mcp.json (global, macOS):
{
"servers": {
"bitbucket-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "bitbucket-mcp-py", "bitbucket-mcp"],
"env": {
"BITBUCKET_USERNAME": "your-email@example.com",
"BITBUCKET_TOKEN": "your-api-token",
"BITBUCKET_WORKSPACE": "your-workspace"
}
}
}
}
| Category | Tools |
|---|---|
| Repositories | list_repositories, get_repository, get_repository_tags |
| Pull Requests | get_pull_requests, get_pull_request, create_pull_request, update_pull_request, approve_pull_request, unapprove_pull_request, request_changes_pull_request, unrequest_changes_pull_request, decline_pull_request, merge_pull_request |
| Comments | get_pull_request_comments, add_pull_request_comment, get_pull_request_comment, update_pull_request_comment, delete_pull_request_comment, resolve_pull_request_comment, reopen_pull_request_comment, get_pull_request_activity |
| Tasks PR | get_pull_request_tasks, get_pull_request_task, create_pull_request_task, update_pull_request_task, delete_pull_request_task |
| Diff / Review | get_pull_request_diff, get_pull_request_patch, get_pull_request_diffstat, get_pull_request_commits |
| PR Discovery | get_pull_requests_pending_review |
| Build / CI | get_pull_request_statuses, get_commit_statuses |
| Pipelines | list_pipeline_runs, get_pipeline_run, get_pipeline_steps, get_pipeline_step_logs, run_pipeline, stop_pipeline |
| Pipelines Config | get_pipeline_config, list_pipeline_variables, get_pipeline_variable, create_pipeline_variable, update_pipeline_variable, delete_pipeline_variable, list_pipeline_schedules, get_pipeline_schedule, list_pipeline_schedule_executions, create_pipeline_schedule, update_pipeline_schedule, delete_pipeline_schedule, list_pipeline_caches, delete_pipeline_cache |
| Reviewers | get_effective_default_reviewers, suggest_pull_request_reviewers |
| Draft PR | create_draft_pull_request, publish_draft_pull_request, convert_pull_request_to_draft |
| Batch Review | submit_pull_request_batch_review |
| Review Summary | get_pull_request_review_summary |
| Issues | list_issues, get_issue, create_issue, update_issue, delete_issue, get_issue_comments, get_issue_comment, add_issue_comment, update_issue_comment, delete_issue_comment |
| Commits | list_commits, get_commit, get_commit_comments, get_commit_comment, add_commit_comment |
| Source | get_file_content, list_directory |
| Deployments | list_environments, get_environment, create_environment, delete_environment, list_deployments, get_deployment, list_deployment_variables, create_deployment_variable, update_deployment_variable, delete_deployment_variable |
| Branch Restrictions | list_branch_restrictions, get_branch_restriction, create_branch_restriction, update_branch_restriction, delete_branch_restriction |
| Workspace | list_workspace_members, get_workspace_member, list_workspace_permissions, list_repository_permissions |
Disabled by default:
merge_pull_request(safety),stop_pipeline(safety),get_pull_request_patch(git am format — not useful for AI review),convert_pull_request_to_draft(not supported by Bitbucket API),delete_issue(safety),delete_issue_comment(safety),add_commit_comment(write op),create_pipeline_variable/update_pipeline_variable/delete_pipeline_variable(write ops),create_pipeline_schedule/update_pipeline_schedule/delete_pipeline_schedule(write ops),delete_pipeline_cache(safety),create_environment/delete_environment/create_deployment_variable/update_deployment_variable/delete_deployment_variable(write ops),create_branch_restriction/update_branch_restriction/delete_branch_restriction(write ops). Enable inconfigs/tools.json.
Governance scopes — Branch restriction read tools need the
repositoryscope (repository:adminmay be required depending on repo config); the write tools needrepository:admin. Workspace member/permission tools need theaccountscope. The/membersendpoint lists users without a per-user permission (uselist_workspace_permissionsfor roles).
Deployments scopes — the read tools (
list_environments,get_environment,list_deployments,get_deployment,list_deployment_variables) need thedeploymentscope; the write tools needdeployment:write. Bitbucket has no server-side filter for deployments by environment (BCLOUD-18729) — filter on theenvironmentfield oflist_deploymentsinstead. There is noupdate_environmenttool: Bitbucket exposes noPUTfor environments (onlyPOST .../changesfor locking).
By default the server reads configs/tools.json bundled with the package. You can point to a custom file at runtime without rebuilding:
export BITBUCKET_TOOLS_CONFIG=/path/to/my-tools.json
Fallback chain (first match wins):
BITBUCKET_TOOLS_CONFIG environment variableconfigs/tools.jsonFail-safe behaviour — If
BITBUCKET_TOOLS_CONFIGis set but the file is missing or contains invalid JSON, the server raises an error on startup (explicit failure rather than silently ignoring the override). If the built-in default is missing, all tools are enabled.
Token tip —
get_pull_request_diffaccepts an optionalpathparameter to filter the diff to a single file, reducing token usage by ~95% on large PRs:get_pull_request_diff(repo_slug, pull_request_id, path="src/services/myService.ts")Token tip —
get_pipeline_step_logsreturns only the trailing 100 KiB of a step log by default (raw logs run to several MB on long steps). The response carries atruncatedflag; widen the window with the absolute byte rangestart/end, or passmax_bytes=nullfor the whole log. Pass a service container UUID aslog_uuidto read that service's log instead of the build container's. This endpoint needs a real pipeline UUID — resolve it viaget_pipeline_runif you only have a build number.get_pipeline_step_logs(repo_slug, pipeline_uuid="{adab6a1f-...}", step_uuid="{84fc6465-...}")
The server also exposes MCP Prompts — parameterised templates that compatible clients (Claude Code, Cursor, ...) surface as slash commands. Instead of remembering tool names, you invoke a prompt and the assistant orchestrates the right tools for you. They appear in the client's prompt picker (prompts/list).
| Prompt | Arguments | What it does |
|---|---|---|
review_pull_request | repo_slug, pull_request_id | Full AI review: metadata → diffstat → diff → comments → tasks, then Summary / Risk / Quality / Security / Recommendation |
debug_pipeline_failure | repo_slug, pipeline_uuid | Diagnose a failed pipeline: run → steps → failed-step logs, then Root cause / Failed step / Error / Fix |
summarize_repository | repo_slug | Repo overview: info → recent commits → open PRs → CI → issues, then Purpose / Activity / Health / Contributors |
onboard_reviewer | repo_slug, pull_request_id | Help a new reviewer: PR context → commits → diff → review history, then Context / Changes / Review-so-far / Focus |
Prompts are enabled/disabled in configs/tools.json under the top-level prompts key (separate from tools).
.env file (recommended)cp .env.example .env
# Edit .env with your credentials
pip install 'bitbucket-mcp-py[keyring]'
python3 -c "import keyring; keyring.set_password('bitbucket-mcp', 'bitbucket_token', 'YOUR_TOKEN')"
If you prefer running the server in a container:
docker build -t bitbucket-mcp-py .
docker run -d --name bitbucket-mcp --env-file .env bitbucket-mcp-py
Then configure your AI assistant to use docker exec:
{
"mcpServers": {
"bitbucket-mcp": {
"command": "docker",
"args": ["exec", "-i", "bitbucket-mcp", "python", "-m", "src.main", "--transport", "stdio"]
}
}
}
The server speaks stdio by default (the standard transport for local MCP clients). For a network deployment it also supports Streamable HTTP (MCP spec 2025-03-26):
# Streamable HTTP on 0.0.0.0:8080
python -m src.main --transport http --host 0.0.0.0 --port 8080
Clients connect to
http://<host>:<port>/mcp(e.g.http://localhost:8080/mcp).
--transport sse(legacy Server-Sent Events) is still accepted but deprecated — it emits aDeprecationWarning. Prefer--transport http.
--stateless runs the Streamable HTTP transport without server-side sessions: no Mcp-Session-Id, a fresh transport per HTTP request. Any instance behind a load balancer can serve any request — no sticky sessions required.
python -m src.main --transport http --host 0.0.0.0 --port 8080 --stateless
⚠️ Single-tenant by default. Without
--multi-tenantthe server serves its own process-wide Bitbucket token to every caller. Deploy it on a private network or behind an authenticated reverse proxy — or use multi-tenant mode, where each caller brings their own credentials.
--stateless requires --transport http (it is rejected on stdio and on the legacy sse, whose app ignores the setting). It also forces a single JSON response instead of an SSE stream, because edge/serverless runtimes cannot hold a streaming response open — there is currently no way to combine stateless with streaming.
A liveness endpoint is exposed on both HTTP transports for load balancers:
curl http://localhost:8080/healthz # {"status": "ok"}
In a container — the image's default CMD keeps it idle for exec-based stdio usage, so server mode is started by overriding the command:
podman run -d --name bitbucket-mcp-http -p 8000:8000 --env-file .env bitbucket-mcp-py \
python -m src.main --transport http --host 0.0.0.0 --port 8000 --stateless
Works identically with
docker run. The image exposes port 8000.
| Environment variable | Default | Purpose |
|---|---|---|
BITBUCKET_ALLOWED_HOSTS | (unset) | Comma-separated Host allowlist. Enables DNS-rebinding protection when set. |
BITBUCKET_ALLOWED_ORIGINS | (unset) | Comma-separated Origin allowlist. |
BITBUCKET_MAX_PAGES_HARD_CAP | 10 | Max pages a single tool call may fetch in stateless mode. Beyond it the response carries truncated: true — never a silent cut. |
The two allowlists must be set together: an empty
Hostallowlist rejects every request (421), and an emptyOriginallowlist rejects every browser client (403). Setting only one is refused at startup rather than silently locking the server out.
export BITBUCKET_ALLOWED_HOSTS="mcp.example.com"
export BITBUCKET_ALLOWED_ORIGINS="https://app.example.com"
With neither allowlist set, no DNS-rebinding protection is applied — appropriate for a server reached through a private network or a trusted proxy. Set them as soon as the server is exposed on a real hostname.
By default an HTTP deployment is single-tenant: every caller acts with the process-wide Bitbucket token. --multi-tenant changes that — each request carries the caller's own Bitbucket OAuth access token as Authorization: Bearer, and runs under that identity. The server holds no Bitbucket credential of its own.
BITBUCKET_RESOURCE_SERVER_URL=https://mcp.example.com \
python -m src.main --transport http --host 0.0.0.0 --port 8080 --stateless --multi-tenant
The token is verified against GET /2.0/user, which yields the caller's account_id and default workspace; the same token is then reused for the downstream API calls, so no credential is ever stored or mapped. Unauthenticated requests get a 401 with a WWW-Authenticate challenge pointing at /.well-known/oauth-protected-resource.
What this buys you:
(identity, workspace); two callers never share one, and there is no process token to fall back on.workspace=None means your workspace — resolved from the caller's memberships, never from BITBUCKET_WORKSPACE. With zero or several memberships there is no default and calls must name their workspace.bitbucket_mcp.audit logger with the tool, the account_id and the workspace. Never credentials.destructiveHint are refused unless explicitly enabled.| Environment variable | Default | Purpose |
|---|---|---|
BITBUCKET_RESOURCE_SERVER_URL | (required) | This server's public URL — the OAuth resource identifier |
BITBUCKET_OAUTH_ISSUER_URL | https://bitbucket.org | Advertised authorization server |
BITBUCKET_CLIENT_CACHE_SIZE / _TTL | 128 / 900 | Bound on the per-identity client cache (LRU + TTL, seconds). TTL 0 builds a fresh client per request |
BITBUCKET_TOKEN_CACHE_SIZE / _TTL | 256 / 300 | Bound on cached token verifications. The TTL is the revocation window — set it to 0 to verify every request |
BITBUCKET_MULTITENANT_ALLOW_DESTRUCTIVE | (off) | Allow merge, decline, delete_*, stop_pipeline |
BITBUCKET_MULTITENANT_READ_ONLY | (off) | Expose read-only tools only |
Not supported in this mode: Bitbucket Repository/Workspace Access Tokens — they are not bound to a user account, so no identity can be derived. Use single-tenant HTTP for that. Bearer tokens require TLS: terminate HTTPS in front of the server.
stdio is unaffected — it stays single-user with environment variables, exactly as documented above.
See docs/deployment-modes.md for the full matrix of the three deployment modes and the threat model of each.
# Install dev dependencies
uv sync --extra dev
# Run tests
uv run pytest tests/ -v
# Run specific test
uv run pytest tests/test_client.py -v
MIT