mcp-bitbucket
Provides tools for interacting with Bitbucket Server/Data Center to browse repositories, manage pull requests and comments, review diffs, merge or decline pull requests, search code, and more.
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., "@mcp-bitbucketshow me the diff of pull request #12"
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.
mcp-bitbucket
Bitbucket Server for AI agents and the humans next to them. Read pull requests and their diffs without a clone, draft a review and publish it with a verdict, post blocking tasks, browse code and commits, open, merge or decline pull requests — from an MCP client, from a shell, or from your own TypeScript.
Bitbucket Server / Data Center only. Bitbucket Cloud is not supported.
Packages
Package | What it is | Bin |
Bitbucket client, operations, formatters — everything else is a thin adapter over it | — | |
MCP server, 29 tools over stdio or Streamable HTTP |
| |
Shell client for the same operations, infers the repo from your git remote |
| |
Claude Code skill that teaches an agent the | — |
Claude Code / Claude Desktop tool use → mcp. Terminal, scripts, CI, agents that run commands → cli. Building something else → core. They read the same credentials and install side by side.
Related MCP server: Atlassian Bitbucket MCP Server
Prerequisites
Node.js 18+, pnpm 10+ (
corepack enable)A Bitbucket Server Personal Access Token — profile → Manage Account → HTTP Access Tokens, with repository read + pull request write
Windows, macOS and Linux. Only Linux needs a package for
bb login(OS keyring):sudo apt install -y libsecret-1-0 gnome-keyring. Every command also works fromBITBUCKET_TOKEN.
Install
pnpm install
pnpm build # core first, then mcp and cliEntry points: packages/mcp/dist/index.js, packages/cli/dist/index.js.
Quick start
MCP server
claude mcp add mcp-bitbucket \
-e BITBUCKET_URL=https://bitbucket.example.com \
-e BITBUCKET_TOKEN=your-personal-access-token \
-- node /absolute/path/to/mcp-bitbucket/packages/mcp/dist/index.jsOr in .mcp.json (${VAR} is expanded by Claude Code, so no secret is committed):
{
"mcpServers": {
"mcp-bitbucket": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/mcp-bitbucket/packages/mcp/dist/index.js"],
"env": {
"BITBUCKET_URL": "${BITBUCKET_URL}",
"BITBUCKET_TOKEN": "${BITBUCKET_TOKEN}"
}
}
}
}HTTP transport instead of stdio: node packages/mcp/dist/index.js --http (port 3000) or MCP_HTTP_PORT=8080 node …. Routes: POST /mcp, GET /mcp (SSE), DELETE /mcp.
bb CLI
pnpm --filter @cuonghuunguyen/cli link --global
bb login # or export BITBUCKET_URL / BITBUCKET_TOKEN
bb whoami # proves authentication — `bb ping` only proves reachability
bb pr get 42 # repository comes from the git origin remoteCommand surface: packages/cli/README.md or bb --help.
Claude Code skill
npx skills add . -a claude-code -g # global: ~/.claude/skills
npx skills add . -a claude-code # project scope: ./.claude/skillsRun from packages/skill. skills works on
Windows, macOS and Linux, and installs into any of its 75+ supported agents.
Needs bb on PATH and a resolvable credential.
Configuration
Environment variables. A .env in the working directory is loaded automatically (cp .env.example .env) — an MCP server launched with a different cwd will not see it, so prefer real environment variables there. The MCP server validates them at startup; the CLI also accepts --url / --token, which win over everything, and falls back to the OS keyring when neither the flags nor the variables are set.
Variable | Default | Effect |
| — | Instance base URL. Required for the MCP server. |
| — | Personal Access Token. Required for the MCP server. |
|
| Which verbs the MCP server exposes — see Permissions. |
| unset (all) | Repository allowlist — see Permissions. |
| unset | Enables HTTP transport on this port instead of stdio. |
|
|
|
|
| REST module and version. |
| resolved | User slug the review tools act as, when a proxy strips |
| unset | CLI only: default for |
Limits
The caps in packages/core/src/operations/caps.ts are env-overridable: BITBUCKET_DIFF_MAX_CHARS (60000), BITBUCKET_DIFF_HEAD_RATIO (0.6), BITBUCKET_DIFF_CONTEXT_LINES (3), BITBUCKET_DIFF_FETCH_MAX_CHARS (12000000), BITBUCKET_DIFF_CACHE_ENTRIES (4), BITBUCKET_CHANGED_FILES_MAX_ITEMS (1000), BITBUCKET_CHANGED_FILES_STATS_MAX_FILES (500), BITBUCKET_REQUEST_TIMEOUT_MS (30000). Two limits are fixed in code and not overridable: the 500 KB single-file ceiling (operations/repository.ts) and the code-search bounds (operations/search.ts). Truncation is never silent — the note names the parameter and the variable that lift the cap, and lists every elided hunk header.
Permissions
Two independent guards.
MCP_PERMISSION_MODE — MCP server only. Every tool is classified read, write or destructive in packages/mcp/src/permissions.ts; a forbidden tool is both hidden from ListTools and refused when called by name.
Mode | Tools |
unset / | 29 |
| 26 — no |
| 17 |
anything else | 0 — a typo fails closed, with a warning on stderr |
The CLI does not read it. A readonly deployment does not stop bb review merge.
Repository allowlist — both entry points. BITBUCKET_ALLOWED_PROJECTS / BITBUCKET_ALLOWED_REPOS take comma-, semicolon- or space-separated patterns: PROJ, PROJ/*, PROJ/repo-a. The check runs inside the shared client before any socket opens, so every tool and every bb command inherits it. Unset means every repository. Case-insensitive; personal repos are project ~username. A malformed pattern is dropped, never widened — a value made only of malformed patterns allows nothing.
Tools
29 MCP tools: 17 read, 9 write, 3 destructive. Full parameters in docs/tools.md.
Group | Tools |
Diagnostic |
|
Repository |
|
Pull request |
|
Comment |
|
Context |
|
Diff |
|
Commit |
|
Browse |
|
Search |
|
Review |
|
Notable defaults
Resolved discussion is hidden.
get_pull_request_comments/bb comment lsneedincludeResolved(--include-resolved) to show resolved threads and tasks; the reply says how many it hid. An explicitstatefilter overrides the default.Reviews are drafted, not posted.
add_pr_draft_comment/bb review draftstore an invisible comment;submit_pr_reviewpublishes every pending comment with a verdict as one notification.pending: false(--no-pending) posts immediately;discard_pr_draft_reviewthrows the draft away.bb ping≠ authentication./application-propertiesanswers 200 anonymously on many instances.bb whoamiis the authentication check.
Development
pnpm build | typecheck | test | lint | format | clean
pnpm dev:mcp # MCP server from source (tsx)
pnpm cli pr ls # bb from source
pnpm --filter @cuonghuunguyen/core testThe layering rule that keeps the adapters from drifting:
core knows nothing about MCP or the CLI — no MCP SDK, no yargs, no stdout. Operations take a client plus params and return structured data or throw.
Adapters own input validation and output shape — zod plus the MCP result shape in
mcp, yargs plus text/--jsonincli. Neither leaks into core.Error messages are written once, in core, with
{projects}/{login}style placeholders each adapter renders in its own vocabulary — the same failure says "uselist_projects" to a model and "usebb project ls" to you.A new capability is an operation plus a formatter in core, then a thin adapter in each of
mcpandcli.
Docker
The image carries the MCP server only.
docker build -t mcp-bitbucket .
docker run -i --rm -e BITBUCKET_URL=… -e BITBUCKET_TOKEN=… mcp-bitbucket
docker run --rm -p 3000:3000 -e BITBUCKET_URL=… -e BITBUCKET_TOKEN=… -e MCP_HTTP_PORT=3000 mcp-bitbucketTroubleshooting
docs/troubleshooting.md. The three most common: a tool missing from the client list means MCP_PERMISSION_MODE hid it (an unrecognised value hides all 29); Refused: … outside the configured repository allowlist means the allowlist does not cover that repo; fewer comments than the web UI means resolved threads are hidden.
Limitations
Bitbucket Server only; no Bitbucket Cloud, no OAuth/SSO/app passwords.
bb loginstores credentials in the OS keyring only — no plaintext store, no--password.No webhooks or event-driven mode; the server answers tool calls.
Diffs are server-rendered unified diff text; inline comments anchored into the diff are not exposed.
search_codeneeds the instance code index: default branch, whole words, no regex.MCP_PERMISSION_MODEgates the MCP server only; the allowlist gates both.
This server cannot be deployed
Maintenance
Related MCP Connectors
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
A MCP server built for developers enabling Git based project management with project and personal…
Related MCP Servers
- AlicenseAqualityBmaintenanceFacilitates interaction with Bitbucket Server for pull request management using the MCP protocol, supporting operations such as creating, merging, commenting, and reviewing pull requests.1568Apache 2.0
- AlicenseBqualityBmaintenanceEnables AI assistants to interact with Bitbucket Cloud and self-hosted instances for pull request reviews, code search, repository operations, and managing PR comments and approvals.19GPL 3.0
- AlicenseBqualityDmaintenanceEnables LLMs to interact with Bitbucket repositories to manage pull requests, branches, and commits through the Model Context Protocol. It supports repository operations such as searching code, accessing file contents, and comparing branches using natural language.162,884 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI systems to interact with Atlassian Bitbucket Server/Data Center for accessing projects, repositories, branches, files, and managing pull requests.MIT