A Model Context Protocol (MCP) server for integrating with Bitbucket Cloud and Server APIs. This MCP server enables AI assistants like Claude and Cursor to interact with your Bitbucket repositories, pull requests, pipelines, and other resources.
β¨ Comprehensive Bitbucket Integration - 59 tools covering repositories, PRs, branches, commits, pipelines, and more
π Secure Authentication - App password tokens or basic auth with granular permission control via Bitbucket
π Well-Documented - Complete API reference, architecture guides, and deployment instructions in /docs
π§ͺ Fully Tested - Comprehensive unit test suite with full tool coverage (Vitest)
β‘ Modular Design - Clean, maintainable architecture organized by feature domain (11 handler modules)
π‘οΈ Safety First - 3 operation modes (readonly, safe, full) with fine-grained tool control
π Production Ready - Built with pnpm, ESLint, Prettier, and modern TypeScript
# Option 1: Global install
pnpm add -g @atercates/bitbucket-mcp
# Option 2: Use with NPX (no installation required)
npx -y @atercates/bitbucket-mcp@latest
# Option 3: Local development
git clone https://github.com/ATERCATES/bitbucket-mcp.git
cd bitbucket-mcp
pnpm install
pnpm build
pnpm startREQUIRED Environment Variables:
# Authentication (Personal API Token ONLY)
export BITBUCKET_USERNAME="user@example.com" # Your Atlassian email address
export BITBUCKET_API_TOKEN="ATBBxxxxxxxxxxxxx" # Personal API Token (starts with ATBB or ATATT)
# Default Workspace (optional but recommended)
export BITBUCKET_WORKSPACE="my-workspace" # Your default workspace nameOptional Configuration:
# Server Operation Mode
export BITBUCKET_MODE="safe" # readonly | safe (default) | full
# Fine-grained tool control
export BITBUCKET_ENABLED_TOOLS="getPullRequest,listPullRequests,createPullRequest"
export BITBUCKET_DISABLED_TOOLS="deleteBranch,deleteRepository"
# Custom API URL (for self-hosted Bitbucket Server)
export BITBUCKET_URL="https://bitbucket.company.com/rest/api/2.0"π Operation Modes:
readonly- Only GET operations (no modifications)safe- GET + POST/PUT operations, but no deletes (default)full- All operations including dangerous deletes
- This MCP server strictly enforces Personal API Tokens (starting with
ATBBorATATT) - App Passwords and Access Tokens (BBAT-xxx) are NOT supported
BITBUCKET_USERNAMEmust be your Atlassian email address
# If installed globally
bitbucket-mcp
# If using NPX
npx -y @atercates/bitbucket-mcp@latest
# If installed locally
pnpm startThe server will start and listen for MCP protocol connections via stdio.
Add to your MCP configuration (.mcp.json or similar):
{
"mcpServers": {
"bitbucket": {
"command": "bitbucket-mcp",
"env": {
"BITBUCKET_USERNAME": "user@example.com",
"BITBUCKET_API_TOKEN": "ATBBxxxxxxxxxxxxx",
"BITBUCKET_WORKSPACE": "my-workspace",
"BITBUCKET_MODE": "safe"
}
}
}
}Examples:
// Read-only mode (safe for production analysis)
{
"BITBUCKET_MODE": "readonly"
}
// Safe mode (default - no deletes)
{
"BITBUCKET_MODE": "safe"
}
// Full mode (all operations including deletes)
{
"BITBUCKET_MODE": "full"
}
// Fine-grained control (only specific tools)
{
"BITBUCKET_ENABLED_TOOLS": "getPullRequest,listPullRequests,getPullRequestDiff"
}
// Blacklist specific tools
{
"BITBUCKET_DISABLED_TOOLS": "deleteBranch,deleteRepository,deleteTag"
}Or with npx:
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["-y", "@atercates/bitbucket-mcp@latest"],
"env": {
"BITBUCKET_USERNAME": "user@example.com",
"BITBUCKET_API_TOKEN": "ATBBxxxxxxxxxxxxx",
"BITBUCKET_WORKSPACE": "my-workspace",
"BITBUCKET_MODE": "safe"
}
}
}
}The server provides 59 tools organized into 11 categories:
| Category | Tools |
|---|---|
| Repositories | List, get, create repositories |
| Pull Requests | Create, approve, merge, decline PRs |
| PR Comments | Create, delete PR comments |
| PR Tasks | Create, update, delete PR tasks (TODOs) |
| PR Content | Get diffs and commits |
| Branches & Tags | List, create, delete branches and tags |
| Commits | List commits and commit details |
| Pipelines | List, run, stop pipeline runs |
| Source Code | Read file content from repositories |
| Users | Get current user and workspace info |
| Branching Model | Get branching strategy configuration |
Complete reference: See docs/TOOLS.md
BITBUCKET_USERNAME- Your Atlassian email address (e.g.,user@example.com)BITBUCKET_API_TOKEN- Personal API Token starting withATBB-orATATT-
How to create:
- Go to https://bitbucket.org/account/settings/app-passwords/
- Click "Create API token"
- Select permissions: Repositories (Read, Write), Pull requests (Read, Write), Pipelines (Read)
- Copy the generated token
- Set expiration date (max 1 year)
BITBUCKET_WORKSPACE- Default workspace name (can be provided per-tool call)BITBUCKET_URL- API base URL (default:https://api.bitbucket.org/2.0)BITBUCKET_MODE- Operation mode:readonly,safe(default), orfullBITBUCKET_ENABLED_TOOLS- Comma-separated list of tools to enable (whitelist mode)BITBUCKET_DISABLED_TOOLS- Comma-separated list of tools to disable (blacklist mode)
BITBUCKET_LOG_DISABLE- Disable file logging (default:false)BITBUCKET_LOG_FILE- Custom log file pathBITBUCKET_LOG_DIR- Custom log directoryBITBUCKET_LOG_PER_CWD- Create per-directory logs (default:false)
- Tools Reference - Complete API documentation for all 59 tools with examples
- Architecture Guide - Technical design, modular structure, and extension guide
- Node.js 24
- pnpm (or npm)
git clone https://github.com/ATERCATES/bitbucket-mcp.git
cd bitbucket-mcp
pnpm installpnpm build # Compile TypeScript
pnpm lint # Run ESLint
pnpm format # Format with Prettier
pnpm format:check # Check formattingpnpm test # Run Vitest suite
pnpm test:watch # Watch modepnpm dev # Run with tsx (watch mode, no build required)
# OR
pnpm build && pnpm startpnpm inspector # Launch interactive MCP inspector to test toolssrc/
ββ index.ts # Entry point
ββ server.ts # MCP server orchestration
ββ client.ts # Bitbucket API client
ββ config.ts # Configuration management
ββ logger.ts # File-based logging
ββ types.ts # TypeScript definitions
ββ schemas.ts # JSON schemas
ββ utils.ts # Utilities
ββ pagination.ts # Pagination helper
ββ handlers/ # Feature modules
ββ repositories.ts
ββ pull-requests.ts
ββ pr-comments.ts
ββ pr-tasks.ts
ββ pr-content.ts
ββ refs.ts
ββ commits.ts
ββ pipelines.ts
ββ source.ts
ββ users.ts
ββ branching-model.ts
ββ index.ts
docs/
ββ TOOLS.md # Tools reference
ββ architecture/
ββ ARCHITECTURE.md # Technical design
__tests__/
ββ test-utils.ts # Test helpers
ββ handlers/ # Handler tests
The server uses a modular handler-based architecture:
MCP Client β Server β Handler Modules β BitbucketClient β Bitbucket API
Each handler module:
- Defines tools (names, schemas, descriptions)
- Implements handlers (async functions)
- Can mark tools as dangerous
- Is automatically registered by the server
See docs/architecture/ARCHITECTURE.md for details.
Some tools that perform destructive operations are marked as dangerous:
deletePullRequestCommentdeletePullRequestTaskdeleteBranchdeleteTag
These require BITBUCKET_MODE=full to use, preventing accidental data loss.
Test your credentials:
# Test Personal API Token
curl -u "user@example.com:ATBBxxxxxx" \
https://api.bitbucket.org/2.0/user
# Should return your user info if credentials are validCommon errors:
-
"BITBUCKET_USERNAME is required"
- Set
BITBUCKET_USERNAMEto your Atlassian email address.
- Set
-
"BITBUCKET_API_TOKEN is required"
- Set
BITBUCKET_API_TOKENto your Personal API Token (starts with ATBB).
- Set
-
"Invalid token format"
- The token must start with
ATBB. App passwords and Access Tokens are not supported.
- The token must start with
-
"401 Unauthorized"
- Check username/token are correct
- Verify token hasn't expired (max 1 year)
- Ensure you are using your email address as username
macOS:
tail -f ~/Library/Logs/bitbucket-mcp/bitbucket.logLinux:
tail -f ~/.local/state/bitbucket-mcp/bitbucket.logWindows:
Get-Content -Path "$env:LOCALAPPDATA\bitbucket-mcp\bitbucket.log" -Tail 50 -WaitFor self-hosted Bitbucket Server, set the API URL:
BITBUCKET_URL=https://bitbucket.mycompany.com/rest/api/2.0 bitbucket-mcpMIT License - See LICENSE file for details.
- π§ Check docs/TOOLS.md for tool documentation with examples
- ποΈ Review docs/architecture/ARCHITECTURE.md for technical details
- π Enable logging with
BITBUCKET_LOG_DISABLE=falsefor debugging - π Report issues at https://github.com/ATERCATES/bitbucket-mcp/issues
Architecture: Modular handler-based design with 11 feature modules
Test Framework: Vitest
Package Manager: pnpm