trackmcp
Back to directory
pdogra1299

bitbucket-mcp-server

View on GitHub

MCP Server for interacting with BitBucket API

11 stars TypeScriptServers & Infrastructure Updated Oct 15, 2025

Documentation

Bitbucket MCP Server

npm version
License: MIT

MCP server for Bitbucket — built for AI coding agents that need to work with remote repositories as if they were local clones: grep-fast code search, windowed file reads, compact token-efficient responses, and a transport layer that never trips Bitbucket's rate limits.

Supports Bitbucket Server / Data Center (primary target) and Bitbucket Cloud.

Why v3

v2v3
Content search in a repo1 listing + up to 3,000 file GETs1 archive call cold, 0–1 calls warm
Search completenesssilently partial under server throttlingcomplete, with every cap reported
PR diff tokensper-line JSON (~4× larger)raw unified diff
Read a 100-line window2 calls, full file transferred1 call, window only
Blame a window of a huge fileup to 100 calls1 call
Rate-limit safetynone (burst → 429/403)client-side pacing sized to DC's limiter
Tools3325 (~30% less definition context)

Measured on a live Data Center instance: a repeated content search went from 519 API calls / ~7s (finding 1 of 8 real matches under burst throttling) to 0 API calls / 24ms finding all 8. Full design and verified API research: `REVAMP_PLAN.md`.

Tools (25)

Search (`search`) — Server/DC only

  • `grep` — search file contents with full regex, any branch, like ripgrep on a local clone. One `archive` download per repo+commit, streamed in constant memory, cached in-process, freshness-checked every call (responses carry `as_of `). Omit `query` for filename-only glob listing. Modes: `content`, `files`, `count`; `glob`, `path`, `context`, `case_insensitive`, `max_results`.
  • `search_code` — index-backed exact-term search across a whole project in one call (default branch only, case-insensitive, no regex, files ` so the agent knows exactly which state it saw.
  • Truncation is never silent — every cap produces an explicit warning with continuation guidance (`next_start`, "narrow the glob", etc.).
  • Mutable entities include `version`, so mutations don't need a re-read.

Installation

json
{
  "mcpServers": {
    "bitbucket": {
      "command": "npx",
      "args": ["-y", "@nexus2520/bitbucket-mcp-server"],
      "env": {
        "BITBUCKET_USERNAME": "your.username",
        "BITBUCKET_TOKEN": "your-http-access-token",
        "BITBUCKET_BASE_URL": "https://bitbucket.yourcompany.com"
      }
    }
  }
}

For Bitbucket Cloud use `BITBUCKET_APP_PASSWORD` instead of `BITBUCKET_TOKEN` (and omit `BITBUCKET_BASE_URL`).

Credential walkthroughs: Cloud app password · Server/DC HTTP token.

From source

bash
git clone https://github.com/pdogra1299/bitbucket-mcp-server.git
cd bitbucket-mcp-server
npm install && npm run build
# point your MCP config at: node /build/index.js

Configuration

Every numeric policy is environment-tunable — nothing is hard-coded. The full table lives in `src/config/index.ts` (`CONFIG_REFERENCE`). The ones that matter most:

VariableDefaultPurpose
`BITBUCKET_RATE_LIMIT_RPS``5`Client-side sustained request rate (DC's per-user refill is 5/s). `0` disables pacing — set this if your account has an admin rate-limit exemption
`BITBUCKET_RATE_LIMIT_BURST``50`Burst capacity (DC's server bucket is 60)
`BITBUCKET_GLOBAL_MAX_CONCURRENCY``8`Max in-flight requests across all tools
`BITBUCKET_SNAPSHOT_MAX_MB``256`In-memory grep cache budget. `0` = pure streaming (no retention, still 2 calls per search)
`BITBUCKET_SNAPSHOT_MAX_FILE_KB``2048`Files larger than this are scanned but not cached
`BITBUCKET_REF_RESOLVE_TTL_MS``15000`Branch→SHA freshness memo; `0` = validate on every single call
`BITBUCKET_STREAM_ABORT_MB``2048`Abort archive scans past this many extracted MB (falls back to bounded per-file scan)
`BITBUCKET_HTTP_TIMEOUT_MS``30000`Per-request timeout
`BITBUCKET_TOOL_GROUPS`allComma-separated groups to expose (validated, enforced at dispatch, fails closed)

The grep engine's guarantees

  • Memory-bounded: the archive is streamed, never buffered whole; the cache is a hard byte budget with LRU eviction and content-hash dedup across branches. Worst case = budget + a few MB transient.
  • Fresh: every query re-resolves the branch head; a moved branch can never serve stale results. Merges/deletes made through this server invalidate immediately.
  • Complete: cache limits never reduce scan coverage — oversized files are still scanned; only true binaries are skipped, and they're counted in the output.

Rate limiting

All requests flow through a token bucket sized to Bitbucket DC's per-user limiter, so 429s are avoided rather than retried-after. If your instance throttles hard anyway, the error message says exactly what to do — the durable fix is asking a Bitbucket admin for a rate-limit exemption for the service account (Admin → Rate limiting → Exemptions), then setting `BITBUCKET_RATE_LIMIT_RPS=0`.

Migrating from v2

Removed tools and their v3 equivalents (same capabilities, fewer tools):

v2v3
`find_in_files``grep` with `query`
`search_files``grep` without `query` (use `glob`)
`list_pr_tasks``get_pull_request` + `include_tasks: true`
`create_pr_task``add_comment` + `severity: "BLOCKER"`
`update_pr_task``manage_comment` `action: "edit"`
`delete_pr_task`, `delete_comment``manage_comment` `action: "delete"`
`set_pr_task_status``manage_comment` `action: "resolve"` / `"reopen"`
`convert_pr_item``manage_comment` `action: "to_task"` / `"to_comment"`
`set_pr_approval``set_review_status` `status: "APPROVED"` / `"UNAPPROVED"`

Update Claude Code permission allowlists (`mcp__bitbucket__*`) accordingly. Diff tools now return unified diff text instead of per-line JSON — line numbers come from `@@` headers. Full details in `CHANGELOG.md`.

Development

bash
npm run build   # tsc → build/
npm test        # build + node --test (unit + snapshot-engine tests)

Architecture: `src/config` (all policy) · `src/core` (transport, snapshot engine, caches) · `src/handlers` (tool logic) · `src/tools` (definitions, guards, registry) · `src/formatting` (compact output) · `src/types` (single barrel).

License

MIT

Frequently asked questions

What is bitbucket-mcp-server?

bitbucket-mcp-server is MCP Server for interacting with BitBucket API

How do I install bitbucket-mcp-server?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is bitbucket-mcp-server open source?

Yes — it is hosted on GitHub at https://github.com/pdogra1299/bitbucket-mcp-server and has 11 stars.

Related MCP tools

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP