bbkt
bbkt’s MCP server lets AI agents securely read and write Bitbucket Cloud data across workspaces, repositories, code, pull requests, pipelines, and issues.
List/get/create/delete repositories and list/get workspaces.
List/create/delete branches and tags; list/get commits with diffs and diffstats.
Read, list, search, and inspect source history; write/delete files with commit messages.
Manage pull requests: list/get/create/update/merge/approve/unapprove/decline, diffs, diffstats, commits.
Manage PR comments: list/create/update/delete/resolve/unresolve, including inline and threaded comments.
Manage pipelines: list/get/trigger/stop, list steps, fetch step logs.
Manage issues: list/get/create/update with state, kind, priority, assignee.
Use
bitbucket_apifor any Bitbucket v2 endpoint; reads/HEAD by default, writes allowed only withBBKT_API_ALLOW_WRITE=1.Tools are scope-gated at startup and can be disabled with
BITBUCKET_DISABLED_TOOLS; credentials determine actual permissions.
Integrates with Atlassian's Bitbucket platform to manage workspaces, repositories, pipelines, and development workflows through the Bitbucket API.
Provides programmatic integration with Bitbucket workspaces and repositories, allowing for the management of repositories, pull requests, pipelines, issues, and source code operations.
bbkt (Bitbucket CLI & MCP Server)
A complete command-line interface and Model Context Protocol (MCP) server written in Go that provides programmatic integration with Bitbucket Cloud workspaces and repositories.
Features
Dual mode — Use as an interactive CLI for daily work, or launch as an MCP server (
bbkt mcp) for AI agents (Claude Desktop, Cursor, etc.).Git-aware — Most commands auto-detect the current workspace and repo from
.git/config, sobbkt prs listJust Works inside a Bitbucket repo.Multi-profile — Switch between personal and work Atlassian accounts with
--profileorBBKT_PROFILE; auto-selects the right profile based on your git config email.Two auth modes — Atlassian API tokens (Basic auth) or interactive OAuth 2.0 with automatic token refresh.
Scope-aware MCP — At startup the MCP server introspects your token's granted scopes and hides tools whose read scope the token lacks. This is a usability filter, not a write guard: limit what an agent can change with a least-privilege credential (see Scope-gated tools).
Read and write — Repositories, workspaces, pipelines, issues, pull requests, comments, and source code (read/write/delete) — all via the API.
Related MCP server: obx
Installation
Recommended — curl | bash
Installs the latest release binary for your OS/arch from GitHub Releases.
# System-wide (uses sudo if /usr/local/bin isn't writable)
curl -sSL https://raw.githubusercontent.com/zach-snell/bbkt/main/install.sh | bash
# User-local, no sudo (~/.local/bin)
curl -sSL https://raw.githubusercontent.com/zach-snell/bbkt/main/install.sh | bash -s -- --userFish users on --user: run fish_add_path ~/.local/bin once if it isn't already on $PATH.
From GitHub Releases
Download a prebuilt binary for your OS/arch directly from the Releases page (Linux/macOS/Windows, amd64 + arm64).
From source
git clone https://github.com/zach-snell/bbkt.git
cd bbkt
go build -o bbkt ./cmd/bbktRequires Go 1.26+.
Quickstart
# 1. Authenticate (interactive — prompts for email + Atlassian API token)
bbkt auth
# 2. Verify
bbkt status
# 3. Use it. Inside a Bitbucket repo, workspace/repo are inferred from git.
bbkt prs list
bbkt pipelines trigger --ref-name main
bbkt source read README.mdFor OAuth instead of an API token:
export BITBUCKET_OAUTH_CLIENT_ID=<consumer-key>
export BITBUCKET_OAUTH_CLIENT_SECRET=<consumer-secret>
bbkt auth --oauthAuthentication
bbkt stores credentials at ~/.config/bbkt/credentials.json and supports multiple profiles.
Atlassian API tokens (default)
bbkt auth # save to "default" profile
bbkt auth --profile work # save to a named profile
# no terminal (scripts, CI): pipe the token in instead of typing it
printf '%s\n' "$TOKEN" | bbkt auth --profile ci --email you@example.com --with-tokenProfiles live side by side; the first one you create is active. Use another with bbkt --profile work …, bbkt profile use work, or BBKT_PROFILE=work in an MCP server's environment.
Important: Bitbucket Cloud REST API requires scoped API tokens since the September 2025 phase-2 of app-password deprecation. At id.atlassian.com/manage-profile/security/api-tokens, use the "Create API token with scopes" button — not plain "Create API token". Unscoped tokens authenticate to Atlassian but Bitbucket rejects them; bbkt will detect this and point you here.
Read scopes (browse repos, PRs and pipelines; nothing can change):
read:account read:user:bitbucket
read:workspace:bitbucket read:repository:bitbucket
read:pullrequest:bitbucket read:pipeline:bitbucketAdd these to open and merge PRs, comment, commit files, delete branches and run pipelines (what most agent setups use):
write:repository:bitbucket write:pullrequest:bitbucket write:pipeline:bitbucketLeave admin:* and delete:* scopes off unless you need them. A write-scoped token can merge PRs and commit to any unprotected branch, so protect main/develop with Bitbucket branch restrictions: see Securing agent access.
OAuth 2.0 (browser flow)
Register an OAuth consumer in your Bitbucket workspace settings, then:
export BITBUCKET_OAUTH_CLIENT_ID=<consumer-key>
export BITBUCKET_OAUTH_CLIENT_SECRET=<consumer-secret>
bbkt auth --oauthbbkt opens a browser, captures the callback on http://localhost:8976, exchanges the code for tokens, and stores them. Access tokens auto-refresh on expiry. To override the callback port (must match your registered redirect_uri):
export BBKT_OAUTH_CALLBACK_PORT=9876Multi-profile switching
bbkt profile # list profiles, mark active
bbkt profile use work # set active profile
bbkt profile refresh # refresh cached workspace list per profile
BBKT_PROFILE=work bbkt prs list # one-shot profile overrideWhen BBKT_PROFILE is unset, bbkt tries to auto-select a profile whose accessible workspaces match your git config email; otherwise it falls back to active_profile.
One-shot env-var auth (CI, scripts)
Setting any of these env vars bypasses the stored profile entirely:
# API token
export BITBUCKET_USERNAME=you@example.com # despite the name, this is your Atlassian email
export BITBUCKET_API_TOKEN=ATATT3xFf...
# OAuth bearer
export BITBUCKET_ACCESS_TOKEN=<oauth-access-token>CLI Usage
Global flags (all commands): --json raw JSON output, --profile <name> profile override.
# Auth & profiles
bbkt auth [--oauth] [--profile <name>] # set up credentials
bbkt status # show active profile + token health
bbkt logout # remove stored credentials
bbkt profile [use <name> | refresh] # manage profiles
# Workspaces / repos
bbkt workspaces [list | get <workspace>]
bbkt repos [list | get | create | delete]
[--query <q>] [--role <owner|admin|contributor|member>]
# Pull requests (workspace/repo inferred from git)
bbkt prs list # --state OPEN|MERGED|SUPERSEDED|DECLINED
bbkt prs get <pr-id>
bbkt prs create --title <t> --source <branch> [--destination <branch>]
bbkt prs merge <pr-id> [--strategy merge_commit|squash|fast_forward]
bbkt prs approve <pr-id>
bbkt prs decline <pr-id>
bbkt prs comments [list | add | resolve | unresolve] # --content, --parent, --file, --to, --from
# Pipelines
bbkt pipelines list # --status SUCCESSFUL|FAILED|INPROGRESS
bbkt pipelines get <pipeline-uuid>
bbkt pipelines trigger --ref-name <branch> [--ref-type branch|tag|bookmark]
bbkt pipelines stop <pipeline-uuid>
bbkt pipelines steps <pipeline-uuid>
bbkt pipelines log <pipeline-uuid> <step-uuid>
# Issues
bbkt issues [list | get | create | update]
[--state] [--kind bug|enhancement|proposal|task] [--priority ...]
# Source code
bbkt source read <path> [--ref <ref>]
bbkt source tree [<path>] [--max-depth <n>]
bbkt source search <query>
bbkt source history <path>
bbkt source write <path> --content <text> [--message <m>] [--branch <b>]
bbkt source delete <path> [--message <m>]Most commands prompt interactively (via huh) when required arguments are missing. Run bbkt <command> --help for full flag details.
MCP Server
bbkt mcp launches a Model Context Protocol server for AI agents. Two transports:
Stdio (default — for Claude Desktop, Cursor, etc.)
Add to your MCP client config:
{
"mcpServers": {
"bitbucket": {
"command": "/absolute/path/to/bbkt",
"args": ["mcp"]
}
}
}By default the server reads credentials from ~/.config/bbkt/credentials.json (the profile set up via bbkt auth). To override per-client:
{
"mcpServers": {
"bitbucket": {
"command": "/absolute/path/to/bbkt",
"args": ["mcp"],
"env": {
"BBKT_PROFILE": "work"
}
}
}
}HTTP Streamable (for clients that can't spawn a process)
bbkt mcp --port 8080This serves the MCP Streamable Transport (SSE-based) on 127.0.0.1:8080.
Bearer token required. Every request must send
Authorization: Bearer <token>; anything else gets401. Set the token withBBKT_MCP_HTTP_TOKEN(at least 16 characters). If it is unset on loopback, bbkt generates a random token and prints it once to stderr.Loopback only by default.
--host <addr>changes the bind address. A non-loopback address is refused unless you pass--allow-remoteand setBBKT_MCP_HTTP_TOKEN:export BBKT_MCP_HTTP_TOKEN="$(openssl rand -hex 32)" bbkt mcp --port 8080 --host 0.0.0.0 --allow-remoteCleartext. There is no TLS; the token and all Bitbucket data travel unencrypted. Put a remote bind behind a TLS-terminating reverse proxy.
Scope-gated tools
The MCP server calls Bitbucket's /user endpoint at startup to introspect your token's granted scopes, then drops any tool whose read scope is missing (e.g. manage_pipelines without pipeline). If introspection fails, the server refuses to start; set BBKT_SKIP_SCOPE_CHECK=1 to start anyway, in which case no scope filtering happens and every tool is registered.
Scope filtering does not hide write actions. A read-only token still exposescreate, delete, merge, write_file, trigger and the other write actions inside the multiplexed manage_* tools; they fail at the API instead. The credential is what limits an agent, so use least-privilege credentials for agent setups, ideally a Bitbucket repository or workspace access token passed via BITBUCKET_ACCESS_TOKEN. Repository and workspace access tokens are not tied to a user; if introspection fails for one and startup is refused, set BBKT_SKIP_SCOPE_CHECK=1. Every tool is then registered, and Bitbucket still enforces the token's own permissions. For scope choices and Bitbucket branch protection, see Securing agent access.
To remove tools outright, regardless of scopes:
export BITBUCKET_DISABLED_TOOLS="manage_repositories,manage_pipelines,bitbucket_api"Valid names: manage_workspaces, manage_repositories, manage_refs, manage_commits, manage_pull_requests, manage_pr_comments, manage_source, manage_pipelines, manage_issues, bitbucket_api. Unknown names are rejected at startup.
bitbucket_api passthrough
bitbucket_api gives the agent authenticated access to any Bitbucket v2 endpoint without a typed tool. Only GET/HEAD are allowed by default; set BBKT_API_ALLOW_WRITE=1 on the server to allow POST/PUT/PATCH/DELETE, which lets the agent call any write endpoint the credential permits.
To skip credential loading entirely (tools will return auth-required errors when invoked — useful for testing the transport):
bbkt mcp --no-authEnvironment Variables
Variable | Purpose | Required |
| Atlassian email (despite the legacy name) — used with | Only for env-var API-token auth |
| Atlassian scoped API token | Only for env-var API-token auth |
| Bearer token: OAuth 2.0 access token or repository/workspace access token (overrides stored profile) | Only for env-var bearer auth |
| OAuth consumer Key | Only for |
| OAuth consumer Secret | Only for |
| Profile name override (one-shot) | No |
| Local callback port for OAuth flow (default 8976) | No |
| Comma-separated MCP tools to remove (names above; unknown names rejected at startup) | No |
|
| No |
|
| No |
| Bearer token for | Required for |
When BITBUCKET_ACCESS_TOKEN or (BITBUCKET_USERNAME + BITBUCKET_API_TOKEN) is set, the stored profile is bypassed entirely.
Tools Provided (MCP)
Tool | Operations | Required Scope |
| list, get | — |
| list, get, create, delete |
|
| list, create, delete branches and tags |
|
| list, get, diff, diffstat |
|
| read, list_directory, get_history, search, write, delete |
|
| list, get, create, update, merge, approve, unapprove, decline, diff, diffstat, commits |
|
| list, create, update, delete, resolve, unresolve |
|
| list, get, trigger, stop, list-steps, get-step-log |
|
| list, get, create, update |
|
| any v2 endpoint; reads only unless | — |
"Required Scope" is the read scope that keeps a tool registered; write actions inside a tool still need the matching write scope at call time. Scopes shown are the OAuth-style names. For Atlassian API tokens, the equivalent granular scopes are read:<scope>:bitbucket / write:<scope>:bitbucket.
Development
Requires Go 1.26+.
go test ./... # unit tests
go test -tags=live ./... # live integration tests (requires BBKT_LIVE_* secrets)
golangci-lint run ./...The repo also has a docs site (Astro) under docs/ deployed to https://zach-snell.github.io/bbkt/.
License
Apache 2.0 — see LICENSE.
Available Tools
10 toolsbitbucket_apiA
Authenticated passthrough to ANY Bitbucket Cloud REST API v2 endpoint not covered by the manage_* tools above (e.g. pipelines-config/OIDC, webhooks, branch restrictions). Prefer a typed manage_* tool when one fits; use this for the long tail instead of calling the API yourself. Reads (GET/HEAD) work by default; write methods are rejected unless BBKT_API_ALLOW_WRITE is set on the server. Supports pagination and returns the raw HTTP status + JSON body.
Inputs: path (required), body, method, paginate, +1 more.
manage_commitsC
Unified tool for listing and getting commits, diffs, and diffstats
Inputs: action (required), repo_slug (required), workspace (required), page, +7 more.
manage_issuesC
Unified tool for managing repository issues (list, get, create, update)
Inputs: action (required), repo_slug (required), workspace (required), kind, +9 more.
manage_pipelinesC
Unified tool for managing Bitbucket Pipelines (list, get, trigger, stop, list-steps, get-step-log)
Inputs: action (required), repo_slug (required), workspace (required), page, +8 more.
manage_pr_commentsC
Unified tool for managing pull request comments (list, create, update, delete, resolve, unresolve)
Inputs: pr_id (required), action (required), repo_slug (required), workspace (required), +8 more.
manage_pull_requestsB
Unified tool covering all pull request operations (list, get, create, update, merge, approve, unapprove, decline, diff, diffstat, commits)
Inputs: action (required), repo_slug (required), workspace (required), page, +12 more.
manage_refsC
Unified tool for listing, creating, and deleting branches and tags
Inputs: action (required), repo_slug (required), workspace (required), name, +5 more.
manage_repositoriesC
Unified tool for listing, getting, creating, and deleting repositories
Inputs: action (required), workspace (required), page, role, +8 more.
manage_sourceC
Unified tool for source code operations (read, list_directory, get_history, search, write, delete)
Inputs: action (required), repo_slug (required), workspace (required), ref, +9 more.
manage_workspacesC
Unified tool for getting and listing Bitbucket workspaces
Inputs: action (required), page, pagelen, workspace.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each manage_* tool targets a distinct Bitbucket resource (commits, issues, pipelines, etc.) with clear operation lists, and the catch-all bitbucket_api handles everything else, ensuring no overlap.
All manage_* tools follow a consistent verb_noun pattern, but the bitbucket_api tool breaks that pattern, causing a minor inconsistency.
With 10 tools covering workspaces, repos, issues, PRs, comments, commits, pipelines, source, and refs, the count is well-scoped for a Bitbucket integration server.
The tool set provides CRUD or lifecycle operations for all major Bitbucket resources, and the bitbucket_api tool covers any remaining endpoints, leaving no obvious gaps.
Maintenance
Related MCP Connectors
Go MCP server for GitLab: 2 dynamic tools reach 1000+ REST/GraphQL actions. Free/CE, no paid tier.
A MCP server built for developers enabling Git based project management with project and personal…
MCP server for siGit (sigit.si): browse repos, search code, manage PRs/issues, web search.
An MCP server that let you interact with Cycloid.io Internal Development Portal and Platform
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceAccess all major Bitbucket Cloud features—repositories, pull requests, issues, branches, pipelines, deployments, and more—using a modern Rust codebase. Expose Bitbucket as Model Context Protocol (MCP) tools, ideal for bots, CI/CD, and workflow automation.-
- AlicenseAqualityDmaintenanceA fast, lightweight MCP server and CLI for Obsidian vaults built in Go. 16 multiplexed tools covering 72 actions for notes, search, templates, tasks, links, frontmatter, and vault analysis. Single binary, no plugins required.154Apache 2.0
- AlicenseBqualityCmaintenanceJira CLI & MCP Server — dual-mode Go binary for Jira Cloud with 9 tools, 4 prompts, permission introspection, and dev-status API.101Apache 2.0
- AlicenseBqualityDmaintenanceConfluence CLI & MCP Server — dual-mode Go binary for Confluence Cloud with 7 tools, folder CRUD, page diff, and write gating.81Apache 2.0