Skip to content

Configuration

bbkt reads credentials from ~/.config/bbkt/credentials.json (multi-profile, mode 0600) or directly from environment variables.

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.

Terminal window
bbkt auth # save to "default" profile
bbkt auth --profile work # save to a named profile
bbkt 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 it
printf '%s\n' "$TOKEN" | bbkt auth --profile ci --email you@example.com --with-token

Profiles 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:bitbucket
read:workspace:bitbucket read:repository:bitbucket
read:pullrequest:bitbucket read:pipeline:bitbucket

Add 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:bitbucket

Leave 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.

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" }
}
}
}

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"
}
}
}
}

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.

Setting these bypasses the stored profile (useful for CI/CD and headless setups).

VariablePurpose
BITBUCKET_USERNAMEAtlassian email (despite the legacy name) — used with BITBUCKET_API_TOKEN
BITBUCKET_API_TOKENScoped Atlassian API token
BITBUCKET_ACCESS_TOKENBearer token: OAuth 2.0 access token or a repository/workspace access token (overrides stored profile)
BITBUCKET_OAUTH_CLIENT_IDOAuth consumer Key (only used by bbkt auth --oauth)
BITBUCKET_OAUTH_CLIENT_SECRETOAuth consumer Secret (only used by bbkt auth --oauth)
BBKT_PROFILEProfile name override (one-shot)
BBKT_OAUTH_CALLBACK_PORTLocal callback port for OAuth flow (default 8976)
BITBUCKET_DISABLED_TOOLSComma-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_WRITESet to 1 to allow write methods (POST/PUT/PATCH/DELETE) through the bitbucket_api MCP passthrough (default: reads only)
BBKT_SKIP_SCOPE_CHECKSet to 1 to start the MCP server even if scope introspection fails (otherwise startup is refused)
BBKT_MCP_HTTP_TOKENBearer token required by bbkt mcp --port (min. 16 characters; generated on loopback if unset)

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.