
Bitbucket MCP Server
io.github.lawp09由 GitHub 帳號 lawp09 發布v1.29.2更新於 Oct 26, 2026
MCP server for Bitbucket API - manage repositories, pull requests, comments, pipelines and more
概覽
本機 MCP 伺服器,把 AI 助理連接到 Bitbucket Cloud,用來瀏覽儲存庫、審查拉取請求與監控流水線。
- 可以做什麼
- 瀏覽儲存庫、原始碼檔案、目錄、提交,以及工作區成員與權限
- 讀取、建立、更新、核准、拒絕或合併拉取請求,包含草稿、審查者與批次審查
- 讀取、新增、編輯、解決或刪除拉取請求留言與任務,以及差異、補丁與差異統計
- 檢視並控制 CI:建置狀態、流水線執行、步驟與日誌、流水線變數、排程與快取
- 管理議題與議題留言、部署與部署變數,以及分支限制
- 使用內建提示範本進行 PR 審查、流水線失敗診斷、儲存庫概覽與新審查者上手
- 適用情境
- 適合團隊程式碼託管在 Bitbucket Cloud 的情況:希望助理在對話中直接審查拉取請求、排查 CI 失敗,或回答關於儲存庫與流水線的問題。
- 執行需求
- 需要 Python 3.12+ 與 bitbucket-mcp-py 套件,通常以 uvx 或 pip 執行。需要具備明確權限範圍的 Bitbucket API 權杖,並設定 BITBUCKET_USERNAME、BITBUCKET_TOKEN、BITBUCKET_WORKSPACE 環境變數(或使用系統鑰匙圈)。需要連線至 Bitbucket API 的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Bitbucket MCP Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Bitbucket MCP Server (Python)
[PyPI] [Python] [CI] [CodeQL] [License: MIT]
Connect 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.
Features
- 60+ MCP tools — repositories, pull requests, comments, tasks, diffs, pipelines (runtime + config), build statuses, reviewers, draft PRs, batch review, issue tracker, commits, source/file browsing
- MCP 2025 tool annotations — every tool advertises
readOnlyHint/destructiveHint/idempotentHint/openWorldHint+ a human-readable title, so clients (Claude Code, Cursor) auto-include read-only tools and warn before destructive operations - Slim responses — stripped API noise for lower LLM token usage
- Configurable — enable/disable tools via
configs/tools.jsonorBITBUCKET_TOOLS_CONFIGenv var - Secure credentials — environment variables or system keychain
Quick Start
1. Install
The recommended way to run the server is via uvx (zero install, isolated environment):
Why
--from? The PyPI package isbitbucket-mcp-pybut the command entry point isbitbucket-mcp. The--fromflag tells uvx which package to install.
Alternative install methods
2. Configure credentials
Set the following environment variables — in your MCP client's env block, as shown above, or in the system keychain (see Credentials):
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.
3. Configure your AI assistant
Claude Code (recommended)
Option A — CLI (fastest):
Option B — JSON config (~/.claude.json or project .mcp.json):
OpenAI Codex
Option A — CLI (fastest):
Option B — TOML config (~/.codex/config.toml):
Cursor
Add to ~/.cursor/mcp.json:
VS Code (GitHub Copilot)
Add to .vscode/mcp.json (workspace) or ~/Library/Application Support/Code/User/mcp.json (global, macOS):
Available Tools
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).
Custom tool configuration
By default the server reads configs/tools.json bundled with the package. You can point to a custom file at runtime without rebuilding:
Fallback chain (first match wins):
BITBUCKET_TOOLS_CONFIGenvironment variable- Built-in
configs/tools.json
Fail-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: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.
MCP Prompts
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).
Prompts are enabled/disabled in configs/tools.json under the top-level prompts key (separate from tools).
Credentials
Option 1: environment variables (recommended)
Put them in the env block of your MCP client configuration, as in the examples above, or export them in the shell that launches the server.
Option 2: System keychain (most secure)
About
.env: the server itself never reads a.envfile..env.exampleis a template for containers, which load it with--env-file .envorenv_file:(the Docker, Makefile anddocker-compose.ymlsetups); withuvxorpython -m src.main, use option 1 or 2.
Docker (Alternative)
If you prefer running the server in a container:
Then configure your AI assistant to use docker exec:
Transports
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):
Clients connect to
http://<host>:<port>/mcp(e.g.http://localhost:8080/mcp).
⚠️
--hostdefaults to0.0.0.0, every interface. Without--multi-tenantthe server has no authentication of its own: anyone who can reach the port acts with your Bitbucket token. Bind to127.0.0.1unless the port sits behind an authenticating proxy.
--transport sse(legacy Server-Sent Events) is still accepted but deprecated — it emits aDeprecationWarning. Prefer--transport http.
Stateless HTTP (horizontal scaling / serverless)
--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.
⚠️ 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:
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:
Inside the container
--host 0.0.0.0is required;-p 127.0.0.1:8000:8000is what keeps the published port off the network, since this single-tenant server answers every caller with the.envtoken.
Works identically with
docker run. The image exposes port 8000.
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.
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.
Multi-tenant HTTP (per-request credentials)
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.
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/mcp. Since Bitbucket publishes no OAuth metadata, the server serves /.well-known/oauth-authorization-server itself, pointing at Bitbucket's endpoints — which is what lets it be added to claude.ai as a custom connector (Bitbucket sign-in through the Atlassian login); setup, what was verified and the residual risks in docs/deployment-modes.md.
What this buys you:
- Isolation — one Bitbucket client per
(identity, workspace); two callers never share one, and there is no process token to fall back on. workspace=Nonemeans your workspace — resolved from the caller's memberships, never fromBITBUCKET_WORKSPACE. With zero or several memberships there is no default and calls must name their workspace.- Audit trail — every call is logged to the
bitbucket_mcp.auditlogger with the tool, theaccount_idand the workspace. Never credentials. - Tighter defaults — tools flagged
destructiveHintare refused unless explicitly enabled. The other write tools (comment, approve, create a pull request, run a pipeline…) stay available to every caller: setBITBUCKET_MULTITENANT_READ_ONLY=1for a first deployment.
Spec deviation: the caller's Bitbucket token is accepted without an audience check and forwarded upstream as-is, which the MCP authorization spec (2025-11-25) forbids — trade-offs and residual risks in docs/deployment-modes.md.
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.
Kubernetes (k3s, datacenter, GKE)
Each release publishes a multi-arch image (ghcr.io/lawp09/bitbucket-mcp) and a Helm chart (oci://ghcr.io/lawp09/charts/bitbucket-mcp) that deploy the multi-tenant HTTP mode; publicUrl is the only required value:
Ingress, GKE and network-policy notes: docs/deployment-kubernetes.md.
Development
Requirements
- Python 3.12+
- Bitbucket API token
License
MIT
References
- MCP Registry — Official MCP server registry
- PyPI Package — Python package
- MCP Python SDK
- Bitbucket API 2.0
- FastMCP Framework
來源:README.md,提交 a92ce75
工具
0版本歷史
5- v1.29.2最新Oct 26, 2026
- v1.29.1Oct 9, 2026
- v1.29.0Oct 8, 2026
- v1.28.0Oct 8, 2026
- v1.26.1Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分