Bitbucket MCP server

Integrates with Bitbucket's API to streamline pull request workflows, enabling efficient code reviews and automated PR management.
Back to servers
Setup instructions
Provider
garc33
Release date
Jan 20, 2025
Language
TypeScript
Stats
22 stars

This MCP server provides tools to interact with Bitbucket Server pull requests through the Model Context Protocol, enabling you to manage repositories, create and merge pull requests, and participate in code reviews.

Requirements and Installation

Prerequisites

  • Node.js >= 16

Installing via Smithery

The easiest way to install the Bitbucket Server MCP for Claude Desktop is through Smithery:

npx -y @smithery/cli install @garc33/bitbucket-server-mcp-server --client claude

Manual Installation

If you prefer to install manually:

npm install
npm run build

Configuration

Configure the server in your VSCode MCP settings file:

{
  "mcpServers": {
    "bitbucket": {
      "command": "node",
      "args": ["/path/to/bitbucket-server/build/index.js"],
      "env": {
        "BITBUCKET_URL": "https://your-bitbucket-server.com",
        "BITBUCKET_TOKEN": "your-access-token",
        // Or alternatively:
        // "BITBUCKET_USERNAME": "your-username",
        // "BITBUCKET_PASSWORD": "your-password",
        "BITBUCKET_DEFAULT_PROJECT": "your-default-project"
      }
    }
  }
}

Required Environment Variables

  • BITBUCKET_URL: Your Bitbucket Server instance URL
  • Authentication (choose one):
    • BITBUCKET_TOKEN: Personal access token
    • BITBUCKET_USERNAME and BITBUCKET_PASSWORD: Basic auth credentials
  • BITBUCKET_DEFAULT_PROJECT (optional): Default project key when not specified in commands

Using the Server

Project and Repository Discovery

List all accessible projects:

list_projects

List repositories in default project:

list_repositories

List repositories in specific project:

list_repositories --project "MYPROJECT"

Pagination support:

list_projects --limit 10 --start 0

Working with Pull Requests

Create a pull request:

create_pull_request --repository "my-repo" --title "Feature: New functionality" --sourceBranch "feature/new-feature" --targetBranch "main"

Create PR with description and specific project:

create_pull_request --project "MYPROJECT" --repository "my-repo" --title "Bugfix: Critical issue" --sourceBranch "bugfix/critical" --targetBranch "develop" --description "Fixes critical issue #123"

Get pull request details:

get_pull_request --repository "my-repo" --prId 123

Merge a pull request:

merge_pull_request --repository "my-repo" --prId 123 --strategy "squash" --message "Feature: New functionality (#123)"

Add a comment to a PR:

add_comment --repository "my-repo" --prId 123 --text "Could you explain this implementation further?"

View code differences:

get_diff --repository "my-repo" --prId 123

Check review status:

get_reviews --repository "my-repo" --prId 123

Decline a pull request:

decline_pull_request --repository "my-repo" --prId 123 --message "Needs significant rework"

Available Tools

Project and Repository Management

  • list_projects: Discovers all accessible Bitbucket projects
  • list_repositories: Explores repositories within specific projects or across all projects

Pull Request Lifecycle

  • create_pull_request: Creates new pull requests with customizable title, description, and reviewers
  • get_pull_request: Retrieves detailed PR information
  • merge_pull_request: Integrates approved changes with support for different merge strategies
  • decline_pull_request: Rejects PRs with feedback
  • add_comment: Adds review comments or feedback to pull requests
  • get_diff: Retrieves code differences in the PR
  • get_reviews: Fetches review history and approval status

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "bitbucket" '{"command":"node","args":["/path/to/bitbucket-server/build/index.js"],"env":{"BITBUCKET_URL":"https://your-bitbucket-server.com","BITBUCKET_TOKEN":"your-access-token","BITBUCKET_DEFAULT_PROJECT":"your-default-project"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "bitbucket": {
            "command": "node",
            "args": [
                "/path/to/bitbucket-server/build/index.js"
            ],
            "env": {
                "BITBUCKET_URL": "https://your-bitbucket-server.com",
                "BITBUCKET_TOKEN": "your-access-token",
                "BITBUCKET_DEFAULT_PROJECT": "your-default-project"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your 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

2. Add this to your configuration file:

{
    "mcpServers": {
        "bitbucket": {
            "command": "node",
            "args": [
                "/path/to/bitbucket-server/build/index.js"
            ],
            "env": {
                "BITBUCKET_URL": "https://your-bitbucket-server.com",
                "BITBUCKET_TOKEN": "your-access-token",
                "BITBUCKET_DEFAULT_PROJECT": "your-default-project"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later