Bitbucket MCP Server

$git clone https://github.com/jlromano/bitbucket-mcp.git && cd bitbucket-mcp && npm install && npm run build
README.md

Interact with Bitbucket repositories, manage pull requests, and analyze code.

Bitbucket MCP Server

A Model Context Protocol (MCP) server that enables Large Language Models (LLMs) to interact with Bitbucket repositories, manage pull requests, analyze code, and perform various repository operations.

🌟 Features

Repository Management

  • List workspaces and repositories
  • Get detailed repository information
  • Search code across repositories
  • Access file contents

Branch Operations

  • List and get branch details
  • Compare branches
  • View branch history

Pull Request Management

  • List, create, and manage pull requests
  • Approve and merge pull requests
  • Add comments and reviews
  • Filter by status (OPEN, MERGED, DECLINED)

Commit Operations

  • List and analyze commits
  • Get commit details and diffs
  • Filter commits by branch

šŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/jlromano/bitbucket-mcp.git
cd bitbucket-mcp
  1. Install dependencies:
npm install
  1. Configure environment:
cp .env.example .env
# Edit .env with your Bitbucket credentials
  1. Build the project:
npm run build

šŸ” Authentication Setup

Creating a Bitbucket App Password

  1. Log into your Bitbucket account
  2. Navigate to Personal Settings → App passwords
  3. Click Create app password
  4. Select the following permissions:
    • Account: Read
    • Workspace membership: Read
    • Repositories: Read, Write
    • Pull requests: Read, Write
  5. Copy the generated password

Environment Configuration

Create a .env file with your credentials:

BITBUCKET_USERNAME=your-username-or-email
BITBUCKET_APP_PASSWORD=your-app-password
BITBUCKET_WORKSPACE=default-workspace (optional)

šŸ“‹ Configuration

Claude Desktop

Add to your Claude configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json

{
  "mcpServers": {
    "bitbucket": {
      "command": "node",
      "args": ["/absolute/path/to/bitbucket-mcp/dist/index.js"],
      "env": {
        "BITBUCKET_USERNAME": "your-username",
        "BITBUCKET_APP_PASSWORD": "your-app-password",
        "BITBUCKET_WORKSPACE": "your-workspace"
      }
    }
  }
}

Other MCP-Compatible Applications

Install globally and run:

npm install -g bitbucket-mcp
bitbucket-mcp

šŸ› ļø Available Tools

The server provides the following tools for LLM interaction:

Tool Description
list_workspaces List all available workspaces
list_repositories List repositories in a workspace
get_repository Get repository details
list_branches List repository branches
get_branch Get branch details
compare_branches Compare two branches
list_pull_requests List pull requests with optional filters
get_pull_request Get pull request details
create_pull_request Create a new pull request
approve_pull_request Approve a pull request
merge_pull_request Merge a pull request
add_pull_request_comment Add a comment to a pull request
list_commits List repository commits
get_commit Get commit details
get_file_content Get file contents from repository
search_code Search code in workspace

šŸ’» Development

Project Structure

bitbucket-mcp/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts           # MCP server implementation
│   └── BitbucketClient.ts # Bitbucket API client
ā”œā”€ā”€ dist/                  # Compiled JavaScript
ā”œā”€ā”€ .env.example          # Environment variables template
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
└── README.md

Development Commands

# Run in development mode with hot reload
npm run dev

# Build for production
npm run build

# Run linting
npm run lint

# Format code
npm run format

# Start production server
npm start

šŸ¤ Usage Examples

Once configured, you can interact with your Bitbucket repositories through your LLM:

  • "List all repositories in my workspace"
  • "Show open pull requests in the main repository"
  • "Create a pull request from feature/new-feature to main"
  • "Get the content of README.md from the develop branch"
  • "Search for 'authentication' in the codebase"
  • "Compare develop and main branches"
  • "Show recent commits with 'fix' in the message"

šŸ” Troubleshooting

Common Issues

Authentication Failed

  • Verify your username (use email if that'

Tools (16)

list_workspacesList all available workspaces
list_repositoriesList repositories in a workspace
get_repositoryGet repository details
list_branchesList repository branches
get_branchGet branch details
compare_branchesCompare two branches
list_pull_requestsList pull requests with optional filters
get_pull_requestGet pull request details
create_pull_requestCreate a new pull request
approve_pull_requestApprove a pull request
merge_pull_requestMerge a pull request
add_pull_request_commentAdd a comment to a pull request
list_commitsList repository commits
get_commitGet commit details
get_file_contentGet file contents from repository
search_codeSearch code in workspace

Environment Variables

BITBUCKET_USERNAMErequiredYour Bitbucket username or email
BITBUCKET_APP_PASSWORDrequiredYour Bitbucket App Password with appropriate permissions
BITBUCKET_WORKSPACEDefault Bitbucket workspace

Configuration

claude_desktop_config.json
{"mcpServers": {"bitbucket": {"command": "node", "args": ["/absolute/path/to/bitbucket-mcp/dist/index.js"], "env": {"BITBUCKET_USERNAME": "your-username", "BITBUCKET_APP_PASSWORD": "your-app-password", "BITBUCKET_WORKSPACE": "your-workspace"}}}}

Try it

→Show open pull requests in the main repository
→Create a pull request from feature/new-feature to main
→Search for 'authentication' in the codebase
→Compare develop and main branches
→Show recent commits with 'fix' in the message

Frequently Asked Questions

What are the key features of Bitbucket MCP Server?

Full Pull Request lifecycle management including creation, approval, and merging.. Advanced repository operations like code searching and file content access.. Branch operations including detailed comparisons and history viewing.. Commit analysis with support for viewing diffs and filtering by branch..

What can I use Bitbucket MCP Server for?

Automated code review assistance by fetching PR details and adding comments.. Streamlining DevOps workflows by creating and merging pull requests via chat.. Quickly searching across multiple repositories for specific code patterns or strings.. Analyzing branch differences and commit history to troubleshoot regressions..

How do I install Bitbucket MCP Server?

Install Bitbucket MCP Server by running: git clone https://github.com/jlromano/bitbucket-mcp.git && cd bitbucket-mcp && npm install && npm run build

What MCP clients work with Bitbucket MCP Server?

Bitbucket MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Use Bitbucket MCP Server with Conare

Manage MCP servers visually, upload persistent context, and never start from zero with Claude Code & Codex.

Try Free