Back to Browse

Bitbucket MCP Server

Developer ToolsLow Risk10.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

Bitbucket MCP for Data Center: PR review with multi-line comments, plus Code Mode over the REST API.

About

Bitbucket MCP for Data Center: PR review with multi-line comments, plus Code Mode over the REST API.

Security Report

10.0
Low Risk10.0Low Risk

Valid MCP server (2 strong, 2 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry. Trust signals: 7 highly-trusted packages.

7 files analyzed · 1 issue found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

env_vars

Check that this permission is expected for this type of plugin.

file_system

Check that this permission is expected for this type of plugin.

HTTP Network Access

Connects to external APIs or services over the internet.

What You'll Need

Set these up before or after installing:

Bitbucket Data Center base URL, e.g. https://bitbucket.example.comOptional

Environment variable: BITBUCKET_BASE_URL

HTTP access token (sent as Bearer)Required

Environment variable: BITBUCKET_TOKEN

true hides and refuses every writeOptional

Environment variable: BITBUCKET_READ_ONLY

all, curated or codeOptional

Environment variable: BITBUCKET_TOOLS

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "bitbucket-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@adarsh.ba/bitbucket-mcp@0.2.0"
      ],
      "env": {
        "BITBUCKET_TOKEN": "your-bitbucket-token-here",
        "BITBUCKET_TOOLS": "your-bitbucket-tools-here",
        "BITBUCKET_BASE_URL": "your-bitbucket-base-url-here",
        "BITBUCKET_READ_ONLY": "your-bitbucket-read-only-here"
      }
    }
  }
}

Some servers take additional arguments. See the repository for details.

Documentation

View on GitHub

From the project's GitHub README.

Bitbucket MCP

Talk is cheap. Show me the code.

A Model Context Protocol (MCP) server for reviewing and shipping pull requests on self-hosted Bitbucket Data Center. Curated pull request tools, multi-line comments, draft reviews, and Code Mode over the whole REST API in a QuickJS sandbox, over a stdio transport.

Source: https://github.com/adarshba/bitbucket-mcp npm: https://www.npmjs.com/package/@adarsh.ba/bitbucket-mcp

What is this?

Exposes Bitbucket Data Center pull requests as MCP tools. An AI agent (Claude, Cursor, OpenCode, etc.) connects over stdio to read a pull request with its merge checks, tasks and threads in one call, then comment, resolve, review and merge. Anything the curated tools don't cover goes through Code Mode: the agent searches the Data Center REST API spec and runs JavaScript that calls any endpoint, in about 1k tokens of tool definitions.

Quick Start

npx @adarsh.ba/bitbucket-mcp bunx --bun @adarsh.ba/bitbucket-mcp # or with Bun

From source:

bun install bun run build BITBUCKET_BASE_URL=https://bitbucket.example.com
BITBUCKET_TOKEN=your-token
bun dist/index.js

Configuration

Configure with environment variables:

BITBUCKET_BASE_URL (required) instance URL, including a context path if you have one BITBUCKET_TOKEN (required) HTTP access token, sent as "Authorization: Bearer" BITBUCKET_USERNAME your username, used to report your review status (default: the X-AUSERNAME response header) BITBUCKET_TOOLS all, curated (PR tools only) or code (search and execute only) (default: all) BITBUCKET_READ_ONLY true hides write tools and refuses non-GET requests from execute (default: false) BITBUCKET_TIMEOUT_MS timeout per Bitbucket request (default: 30000) BITBUCKET_CODE_TIMEOUT_MS time limit per search or execute call (default: 30000)

Create the token under Profile > Manage account > HTTP access tokens. Read permission is enough for read-only mode; reviewing and merging needs repository write.

MCP Client Setup

Claude Code:

claude mcp add bitbucket-mcp
-e BITBUCKET_BASE_URL=https://bitbucket.example.com
-e BITBUCKET_TOKEN=your-token
-- npx -y @adarsh.ba/bitbucket-mcp

or with Bun:

claude mcp add bitbucket-mcp
-e BITBUCKET_BASE_URL=https://bitbucket.example.com
-e BITBUCKET_TOKEN=your-token
-- bunx --bun @adarsh.ba/bitbucket-mcp

Claude Desktop, Cursor, OpenCode, etc.:

{ "mcpServers": { "bitbucket-mcp": { "command": "npx", "args": ["-y", "@adarsh.ba/bitbucket-mcp"], "env": { "BITBUCKET_BASE_URL": "https://bitbucket.example.com", "BITBUCKET_TOKEN": "your-token" } } } }

To run on Bun, use "command": "bunx", "args": ["--bun", "@adarsh.ba/bitbucket-mcp"]. Without --bun, bunx follows the package's node shebang.

Tools

Every pull request tool takes project, repository and pull_request_id.

get_pull_request Pull request details with a reviewer summary, merge checks and vetoes, auto-merge state, open tasks, comment threads and your pending review comments, in one call.

list_pull_requests Pull requests in a repository, or your dashboard across all repositories when project and repository are omitted.

state OPEN, MERGED, DECLINED or ALL (default: OPEN) draft only drafts (true) or only ready PRs (false) filter_text match title or description role AUTHOR, REVIEWER or PARTICIPANT (dashboard only) start, limit pagination

get_pull_request_diff Unified diff as raw text. A diff over ~6,000 tokens returns a per-file summary (path, lines added and removed) instead.

path one file only full return the whole diff even when large context_lines lines of context ignore_whitespace ignore whitespace changes

create_pull_request Create a pull request, optionally as a draft (8.18+) or from a fork.

title, source_branch, target_branch (required) description, reviewers, draft, source_project, source_repository

update_pull_request Change title, description, target branch, reviewers or draft state. Omitted fields are kept.

merge_pull_request Merge now, or with auto_merge once merge checks pass (8.15+).

auto_merge, strategy, message

add_comment General, reply, file, inline or multi-line comment.

text (required) markdown comment text parent_id reply to this comment path file comment line, line_type inline comment; line_type is ADDED, REMOVED or CONTEXT start_line first line of a range (9.2+); line is the last line start_line_type diff segment of start_line (default: line_type) suggestion replacement code, sent as a suggestion block severity BLOCKER creates a task pending add to your draft review

REMOVED lines anchor to the old file; ADDED and CONTEXT lines anchor to the new one. For a range the tool reads the file's diff once and computes the multilineSpan Data Center requires, so you only pass line numbers. Both ends must be lines shown in the diff.

manage_comment One action on a comment: edit, delete, resolve_thread, reopen_thread, resolve_task, reopen_task, apply_suggestion, react, unreact.

comment_id (required) text edit only suggestion_index, commit_message apply_suggestion only emoticon react and unreact only

submit_review Publish your pending comments with an optional status (approved, needs_work, unapproved) and summary comment, or discard them.

search Run an async arrow function against a global "spec": the Bitbucket Data Center 10.5 OpenAPI spec with $refs resolved and examples removed.

execute Run an async arrow function that calls any Data Center REST endpoint through bitbucket.request({ method, path, query, body, accept }).

Writes that need the current version fetch it first. If Bitbucket answers 409 because someone else changed the pull request or comment in between, the tool re-reads and retries once.

Code Mode

search and execute take an "async () => { ... }" arrow function. It runs in a fresh QuickJS sandbox with no network, filesystem, process or timers. console.log output comes back in "logs". Results over about 6,000 tokens are cut to valid JSON with a "--- TRUNCATED ---" marker; pass truncate: false to opt out (still capped at 1 MB).

Find build endpoints:

async () => { const results = []; for (const [path, methods] of Object.entries(spec.paths)) { for (const [method, op] of Object.entries(methods)) { if (op.tags?.includes("Builds and Deployments")) { results.push(${method.toUpperCase()} ${path}); } } } return results; }

Open pull requests across a project, in one call:

async () => { const repos = await bitbucket.request({ method: "GET", path: "/rest/api/latest/projects/PROJ/repos", query: { limit: 100 }, }); const open = await Promise.all( repos.values.map(async (repo) => { const prs = await bitbucket.request({ method: "GET", path: /rest/api/latest/projects/PROJ/repos/${repo.slug}/pull-requests, query: { state: "OPEN", limit: 25 }, }); return { repo: repo.slug, titles: prs.values.map((pr) => pr.title) }; }), ); return open.filter((entry) => entry.titles.length > 0); }

Limits per call: BITBUCKET_CODE_TIMEOUT_MS, 64 MB of memory and 50 requests.

Security

  • The token stays in the server process. Sandbox code calls bitbucket.request and the host adds Authorization; requests cannot carry their own headers.
  • execute paths must start with /rest/ and resolve under BITBUCKET_BASE_URL. Absolute URLs, ".." traversal (plain or percent-encoded), ";" path parameters and redirects are refused.
  • A timed-out execute aborts its in-flight requests, so no write lands after the agent is told the call failed.
  • BITBUCKET_READ_ONLY=true hides write tools and refuses every non-GET request from execute.
  • Errors never include the token. A plain-HTTP base URL to a non-local host prints a warning at startup.
  • GET requests retry on 429, 502, 503 and 504 with jittered backoff; other methods retry only on 429.

Project Layout

src/index.ts entry point, env loading, stdio transport src/server.ts MCP server, tool registration, response serialization src/constants.ts every default, limit and fixed string src/config/loader.ts environment variable loading and validation src/config/schema.ts Zod schemas for env, Bitbucket responses and tool inputs src/client/dc.ts Data Center HTTP client: auth, egress guard, retries, 409 refetch src/code/sandbox.ts QuickJS sandbox with memory, time and request limits src/code/search.ts search handler over the bundled spec src/code/execute.ts execute handler and the bitbucket.request bridge src/code/truncate.ts structural truncation that keeps JSON valid src/tools/get-pull-request.ts get_pull_request handler src/tools/list-pull-requests.ts list_pull_requests handler src/tools/get-pull-request-diff.ts get_pull_request_diff handler and diff summary parser src/tools/create-pull-request.ts create_pull_request handler src/tools/update-pull-request.ts update_pull_request handler src/tools/merge-pull-request.ts merge_pull_request handler src/tools/add-comment.ts add_comment handler and multi-line anchor builder src/tools/manage-comment.ts manage_comment handler src/tools/submit-review.ts submit_review handler src/types/*.ts all type declarations; index.ts is the barrel scripts/build-spec.ts regenerates spec/bitbucket-dc.json from Atlassian's spec spec/bitbucket-dc.json pruned Data Center 10.5 OpenAPI spec, bundled into dist

Development

bun install bun run check every gate CI runs: format, lint, typecheck, knip, tests with coverage, audit bun run format oxfmt bun run spec regenerate spec/bitbucket-dc.json

Requirements

  • Node.js >= 22 or Bun >= 1.4
  • Bitbucket Data Center 8.0 or later; resolving threads needs 8.9+, auto-merge 8.15+, draft PRs 8.18+ and multi-line comments 9.2+

License

MIT

Reviews

No reviews yet

Be the first to review this server!