Configuration
bbkt reads credentials from ~/.config/bbkt/credentials.json (multi-profile, mode 0600) or directly from environment variables.
Authentication
Section titled “Authentication”The recommended path is to run bbkt auth once, which prompts for an Atlassian email and API token and saves them under a named profile.
bbkt auth # save to "default" profilebbkt auth --profile work # save to a named profilebbkt auth --oauth # OAuth 2.0 browser flow (requires consumer)bbkt status # confirm what's wired up
# no terminal (scripts, CI): pipe the token in instead of typing itprintf '%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 env block.
Read scopes (browse repos, PRs and pipelines; nothing can change):
read:account read:user:bitbucketread:workspace:bitbucket read:repository:bitbucketread: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.
Client Registration (MCP)
Section titled “Client Registration (MCP)”Modify your MCP client config to point at the absolute path of the executable. The MCP server reads credentials from the stored profile by default; no env block is required if you’ve run bbkt auth:
{ "mcpServers": { "bitbucket": { "command": "/absolute/path/to/bbkt", "args": ["mcp"] } }}To select a non-default profile per client (e.g. a “work” config in one MCP host, “personal” in another):
{ "mcpServers": { "bitbucket": { "command": "/absolute/path/to/bbkt", "args": ["mcp"], "env": { "BBKT_PROFILE": "work" } } }}Least-privilege credentials for agents
Section titled “Least-privilege credentials for agents”The MCP server only hides a tool when the credential lacks that tool’s read scope. A read-only credential still exposes the write actions inside the multiplexed manage_* tools (they fail at the API instead), so the credential is the real boundary on what an agent can change. For agent setups, prefer a Bitbucket repository or workspace access token scoped to just the repos and permissions the agent needs, 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.
Example:
{ "mcpServers": { "bitbucket": { "command": "/absolute/path/to/bbkt", "args": ["mcp"], "env": { "BITBUCKET_ACCESS_TOKEN": "<repository-access-token>", "BITBUCKET_DISABLED_TOOLS": "manage_repositories,manage_pipelines" } } }}HTTP transport
Section titled “HTTP transport”bbkt mcp --port <n> binds 127.0.0.1 and requires Authorization: Bearer <token> on every request. Set the token with BBKT_MCP_HTTP_TOKEN; if it is unset on loopback, a random token is printed to stderr at startup. Binding another address needs --host <addr> --allow-remote plus BBKT_MCP_HTTP_TOKEN, and the transport is cleartext HTTP, so put it behind TLS. See the MCP reference.
Environment Variables
Section titled “Environment Variables”Setting these bypasses the stored profile (useful for CI/CD and headless setups).
| Variable | Purpose |
|---|---|
BITBUCKET_USERNAME | Atlassian email (despite the legacy name) — used with BITBUCKET_API_TOKEN |
BITBUCKET_API_TOKEN | Scoped Atlassian API token |
BITBUCKET_ACCESS_TOKEN | Bearer token: OAuth 2.0 access token or a repository/workspace access token (overrides stored profile) |
BITBUCKET_OAUTH_CLIENT_ID | OAuth consumer Key (only used by bbkt auth --oauth) |
BITBUCKET_OAUTH_CLIENT_SECRET | OAuth consumer Secret (only used by bbkt auth --oauth) |
BBKT_PROFILE | Profile name override (one-shot) |
BBKT_OAUTH_CALLBACK_PORT | Local callback port for OAuth flow (default 8976) |
BITBUCKET_DISABLED_TOOLS | Comma-separated MCP tools to remove: 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 |
BBKT_API_ALLOW_WRITE | Set to 1 to allow write methods (POST/PUT/PATCH/DELETE) through the bitbucket_api MCP passthrough (default: reads only) |
BBKT_SKIP_SCOPE_CHECK | Set to 1 to start the MCP server even if scope introspection fails (otherwise startup is refused) |
BBKT_MCP_HTTP_TOKEN | Bearer token required by bbkt mcp --port (min. 16 characters; generated on loopback if unset) |
Multi-Profile Selection
Section titled “Multi-Profile Selection”When BBKT_PROFILE is unset and --profile isn’t passed, bbkt tries to auto-select a profile whose accessible_workspaces matches your git config email; otherwise it falls back to the active_profile field of credentials.json. Run bbkt profile refresh periodically so the workspace cache stays current.