bbkt is a Bitbucket Cloud command-line interface (CLI) and Model Context Protocol (MCP) server written in Go, designed to provide programmatic integration for Bitbucket Cloud workspaces and repositories.
Purpose
bbkt is aimed at developers who need to operate Bitbucket Cloud via the command line or AI agents. It can be used both as an interactive CLI for daily development and as an MCP server for invocation by AI agents (such as Claude Desktop, Cursor, etc.), thereby enabling AI to read and write Bitbucket resources.
Main capabilities
- Dual mode: can be used as an interactive CLI, or started as an MCP server via
bbkt mcp. - Git-aware: most commands can automatically detect the current workspace and repository from
.git/config, so runningbbkt prs listdirectly inside a Bitbucket repository works. - Multiple profiles: can switch between personal and work Atlassian accounts via
--profileorBBKT_PROFILE; it can also automatically select the correct profile based on the email configured in git. - Two authentication modes: Atlassian API token (Basic authentication) or interactive OAuth 2.0 (automatic token refresh).
- Scope-aware MCP: when the MCP server starts, it checks the scopes granted to the token and silently hides tools the token cannot use, preventing AI from hallucinating successful writes without permission.
- Read and write operations: repositories, workspaces, pipelines, issues, pull requests, comments, and source code (read/write/delete) can all be operated via the API.
Usage
Installation
The recommended approach is curl | bash , installing the latest release binary for the current OS/architecture from GitHub Releases. Fish users using --userneed to run fish_add_path ~/.local/binonce (if not already in $PATH ). Prebuilt binaries for Linux/macOS/Windows (amd64 + arm64) can also be downloaded directly from the Releases page. Building from source requires Go 1.26+.
Authentication
bbkt stores credentials in ~/.config/bbkt/credentials.jsonand supports multiple profiles.
Atlassian API token (default): because the Bitbucket Cloud REST API requires scoped API tokens starting from phase two of the app password deprecation in September 2025, they must be created at id.atlassian.com/manage-profile/security/api-tokens using the "Create API token with scopes" button, rather than the ordinary "Create API token". Although unscoped tokens can authenticate with Atlassian, they will be rejected by Bitbucket, and bbkt will detect this and prompt.
OAuth 2.0 (browser flow): register an OAuth consumer in the Bitbucket workspace settings, then run the corresponding command. bbkt will open the browser, capture the callback at http://localhost:8976 , exchange the token, and store it. Access tokens are automatically refreshed after expiration. The callback port can be overridden via a parameter (it must match the registered redirect_uri).
Multiple profile switching: when BBKT_PROFILE is not set, bbkt will try to automatically select the profile whose accessible workspace matches the email configured in git; otherwise it falls back to active_profile.
One-off environment variable authentication (CI, scripts): setting BITBUCKET_ACCESS_TOKEN or (BITBUCKET_USERNAME + BITBUCKET_API_TOKEN) can completely bypass the stored profiles.
Global flags
All commands support --json(raw JSON output) and --profile <name>(profile override). Most commands will interactively prompt via huh when required parameters are missing. Run bbkt <command> --help to view full flag details.
MCP server
bbkt mcp Start a Model Context Protocol server for AI agents, supporting two transport methods:
- Stdio (default, suitable for Claude Desktop, Cursor, etc.): add to the MCP client configuration. By default, reads credentials from
~/.config/bbkt/credentials.json(via the configuration file set bybbkt auth), and can be overridden per client. - HTTP Streamable (suitable for remote/network clients): provides MCP Streamable Transport (SSE-based) on the specified port.
Scope-gated tools: when the MCP server starts, it calls Bitbucket's /user endpoint to check the scopes granted to the token, then silently discards tools that lack the required scopes. This prevents the AI from calling, on a read-only token, something like manage_pipelines(which requires the pipeline scope) and receiving an unrecoverable 403. Tools can also be explicitly denied (even if the scope allows them), or credential loading can be skipped entirely (tools return an authentication-required error when called, which is useful for testing transport).
Environment Variables
When BITBUCKET_ACCESS_TOKEN or (BITBUCKET_USERNAME + BITBUCKET_API_TOKEN) is set, the stored configuration file is completely bypassed.
Use Cases
- Developers quickly working with Bitbucket repositories, pull requests, issues, and pipelines in the terminal.
- One-off authenticated operations in CI or scripts via environment variables.
- Connecting Bitbucket capabilities to AI agents (such as Claude Desktop, Cursor), letting the AI assist with managing repositories, PRs, issues, etc.
- Developers who need to switch between multiple accounts (personal/work).
Limitations
- Only Bitbucket Cloud is supported; Bitbucket Server/Data Center is not covered.
- Building from source requires Go 1.26+.
- When using API tokens, a scoped token must be created; unscoped tokens will be rejected by Bitbucket.
- The OAuth callback port must match the registered redirect_uri.
- MCP tools are limited by token scopes; tools lacking scopes are hidden.
- The documentation does not provide a specific tool list, complete command list, pricing, or billing information.
Other
The repository contains an Astro documentation site under docs/ , deployed at https://zach-snell.github.io/bbkt/ . The project uses the Apache 2.0 license; see LICENSE for details.