bitbucket-mcp
Provides tools for reviewing and shipping Bitbucket Data Center pull requests: reading PR details, diffs, merge checks, tasks, threads, and draft reviews; creating and updating PRs; adding comments, suggestions, and tasks; managing comments, threads, and tasks; submitting reviews; and merging or enabling auto-merge. Code Mode can call any Bitbucket Data Center REST endpoint.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Bitbucket MCP
Talk is cheap. Show me the code.
Model Context Protocol server for reviewing and shipping pull requests on self-hosted Bitbucket Data Center from AI agents (Claude, Cursor, OpenCode, etc.).
Features
Pull request review loop: read a PR with merge checks, tasks, threads and your draft review in one call, then comment, resolve and approve
Multi-line comments: anchor a comment to a line range (Data Center 9.2+)
Draft reviews: queue pending comments and publish them with your status in one call
Suggestions, tasks and reactions: suggestion blocks, BLOCKER tasks, apply-suggestion, emoji reactions
Draft PRs and auto-merge: create drafts (8.18+) and merge once checks pass (8.15+)
Code Mode:
searchandexecutereach the whole Data Center REST API in about 1k tokens of tool definitionsSandboxed: agent code runs in QuickJS with memory, time and request limits; the token never enters the sandbox
Read-only mode: hide write tools and refuse non-GET requests
Typed results: pull request and comment tools declare an output schema and return
structuredContentCurrent protocol: serves MCP 2026-07-28 clients and 2025-era clients over stdio
Related MCP server: Bitbucket Server MCP
Installation
npx @adarsh.ba/bitbucket-mcp
# or with Bun:
bunx --bun @adarsh.ba/bitbucket-mcpConfiguration
Configure with environment variables:
Variable | Required | Default | Description |
| yes | Instance URL, e.g. | |
| yes | HTTP access token, sent as | |
| no | from the | Your username; used to report your review status |
| no |
|
|
| no |
|
|
| no |
| Timeout per Bitbucket request |
| no |
| Time limit per |
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-mcpClaude Desktop / Cursor: add to your MCP config:
{
"mcpServers": {
"bitbucket-mcp": {
"command": "npx",
"args": ["-y", "@adarsh.ba/bitbucket-mcp"],
"env": {
"BITBUCKET_BASE_URL": "https://bitbucket.example.com",
"BITBUCKET_TOKEN": "your-token"
}
}
}
}OpenCode: add to .opencode/config.json:
{
"mcp": {
"bitbucket-mcp": {
"type": "local",
"command": ["npx", "-y", "@adarsh.ba/bitbucket-mcp"],
"environment": {
"BITBUCKET_BASE_URL": "https://bitbucket.example.com",
"BITBUCKET_TOKEN": "your-token"
},
"enabled": true
}
}
}To run on Bun, use "command": "bunx", "args": ["--bun", "@adarsh.ba/bitbucket-mcp"] in Claude Desktop and Cursor, or "command": ["bunx", "--bun", "@adarsh.ba/bitbucket-mcp"] in OpenCode. Without --bun, bunx follows the package's node shebang.
Tools
Tool | Description |
| PR details with reviewers, merge checks, auto-merge state, open tasks, comment threads and your pending review comments. |
| PRs in a repository ( |
| Unified diff as raw text, optionally for one file. A diff over ~6,000 tokens returns a per-file summary (path, lines added and removed) unless |
| Create a PR, optionally as a draft or from a fork. |
| Change title, description, target branch, reviewers or draft state; omitted fields are kept. |
| Merge now, or set |
| General, reply, file, inline or multi-line comment; optional suggestion, BLOCKER task or pending draft comment. |
|
|
| Publish pending comments with |
| Run JavaScript against the Data Center REST API spec to find endpoints. |
| Run JavaScript that calls any Data Center REST endpoint. |
Writes that need the current version fetch it first. If Bitbucket answers 409 because someone else changed the PR or comment in between, the tool re-reads and retries once.
Comment anchors
Comment | Arguments |
General |
|
Reply |
|
File |
|
Inline |
|
Range (DC 9.2+) | inline arguments plus |
Suggestion | inline or range arguments plus |
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. Range comments need Data Center 9.2+; older servers get a clear error instead of a silent single-line comment.
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).
search gets a global spec: the Bitbucket Data Center 10.5 OpenAPI spec with $refs resolved and examples removed. Paths start with /rest/.
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;
};execute gets bitbucket.request({ method, path, query, body, accept }), which returns parsed JSON, or text for accept: "text/plain". A failed request throws with the method, path, status, Bitbucket's message and request id.
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 addsAuthorization; requests cannot carry their own headers.executepaths must start with/rest/and resolve underBITBUCKET_BASE_URL; absolute URLs and..traversal are refused.Path segments in curated tools are percent-encoded;
..,/and control characters are refused.BITBUCKET_READ_ONLY=truehides write tools and refuses every non-GET request fromexecute.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.
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 from Atlassian's published specRequirements
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 © Adarsh B A
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Software factory for AI agents: issue and PR reviews, auto-fixes, stacked PRs and a merge queue.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
AI code governance and code review for Claude Code, Copilot and Cursor. Checks rules and security.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables 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
- AlicenseNot gradedqualityDmaintenanceConnects AI assistants to Bitbucket Server/Data Center for reviewing pull requests, managing repositories, searching users, and more.149 npm4MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to manage Bitbucket Cloud repositories, pull requests, pipelines, and code review tasks through natural language.74139 PyPI4MIT
- AlicenseNot gradedqualityAmaintenanceEnables users to securely access and manage Bitbucket Data Center projects, repositories, pull requests, branches, commits, and build statuses through natural language, using per-user OAuth 2.0 authentication and granular read/write permissions.MIT