Bitbucket MCP server

Enables robust Bitbucket repository management by providing comprehensive API integration for repository creation, file manipulation, issue tracking, and branch management with advanced error handling and permission controls.
Back to servers
Setup instructions
Provider
Kallows
Release date
Jan 19, 2025
Language
Python
Stats
5 stars

This Python MCP server provides integration with Bitbucket, allowing your AI applications to interact with Bitbucket repositories, branches, issues, and more. It runs locally on your machine to ensure secure access to your Bitbucket resources.

Installation

# Install the server locally
git clone https://github.com/kallows/mcp-bitbucket.git
cd mcp-bitbucket

# Install dependencies using uv (recommended) or pip
uv install
# or
pip install -e .

Environment Setup

The server requires Bitbucket credentials to be set up as environment variables:

export BITBUCKET_USERNAME="your-username"
export BITBUCKET_APP_PASSWORD="your-app-password"

Creating Bitbucket App Password

  1. Go to Bitbucket Settings → App passwords
  2. Create a new app password with these permissions:
    • Repositories: Read, Write, Admin (for delete operations)
    • Pull requests: Read, Write
    • Issues: Read, Write
    • Account: Read (for workspace operations)

Claude Desktop Configuration

Add this configuration to your claude_desktop_config.json:

Windows

{
  "mcpServers": {
    "bitbucket-api": {
      "command": "C:\\\\Users\\\\YOURUSERNAME\\\\.local\\\\bin\\\\uv.exe",
      "args": [
        "--directory",
        "D:\\\\mcp\\\\mcp-bitbucket",
        "run",
        "-m",
        "mcp_bitbucket.server"
      ],
      "env": {
        "BITBUCKET_USERNAME": "your-username",
        "BITBUCKET_APP_PASSWORD": "your-app-password"
      }
    }
  }
}

Mac and Linux

{
  "mcpServers": {
    "bitbucket-api": {
      "command": "uv",
      "args": [
        "run",
        "--directory", "/path/to/mcp-bitbucket",
        "-m", "mcp_bitbucket.server"
      ],
      "env": {
        "BITBUCKET_USERNAME": "your-username",
        "BITBUCKET_APP_PASSWORD": "your-app-password"
      }
    }
  }
}

⚠️ Important: You must restart Claude Desktop after modifying the configuration file.

Available Tools

This MCP server provides the following Bitbucket integration tools:

Repository Management

  • bb_create_repository: Create a new Bitbucket repository

    • Required: name (repository name)
    • Optional: description, workspace (defaults to kallows), project_key, is_private (default: true), has_issues (default: true)
  • bb_delete_repository: Delete a Bitbucket repository

    • Required: repo_slug
    • Optional: workspace (defaults to kallows)
  • bb_search_repositories: Search Bitbucket repositories using query syntax

    • Required: query (e.g., 'name ~ "test"' or 'project.key = "PROJ"')
    • Optional: workspace (defaults to kallows), page (default: 1), pagelen (default: 10, max: 100)

Branch Management

  • bb_create_branch: Create a new branch in a repository
    • Required: repo_slug, branch (name for the new branch)
    • Optional: workspace (defaults to kallows), start_point (defaults to main)

File Operations

  • bb_read_file: Read a file from a repository

    • Required: repo_slug, path (file path in repository)
    • Optional: workspace (defaults to kallows), branch (defaults to main/master)
  • bb_write_file: Create or update a file in a repository

    • Required: repo_slug, path, content
    • Optional: workspace (defaults to kallows), branch (defaults to main), message (commit message)
  • bb_delete_file: Delete a file from a repository

    • Required: repo_slug, path
    • Optional: workspace (defaults to kallows), branch (defaults to main), message (commit message)

Issue Management

  • bb_create_issue: Create an issue in a repository

    • Required: repo_slug, title, content
    • Optional: workspace (defaults to kallows), kind (bug/enhancement/proposal/task), priority (trivial/minor/major/critical/blocker)
  • bb_delete_issue: Delete an issue from a repository

    • Required: repo_slug, issue_id
    • Optional: workspace (defaults to kallows)

Pull Requests

  • bb_create_pull_request: Create a pull request
    • Required: repo_slug, title, source_branch
    • Optional: workspace (defaults to kallows), destination_branch (defaults to main), description, close_source_branch (default: true)

Usage Examples

Once configured, the Bitbucket tools will be available in Claude Desktop. Here are some examples of how to use them:

Creating a Repository

Create a new repository called 'my-project' in my personal workspace

Managing Branches

Create a new branch called 'feature-xyz' in the my-project repository

Working with Files

Create a README.md file in my-project with some basic content

Repository Search

Search for repositories that contain 'python' in the name

Workspace Configuration

The tools default to the "kallows" workspace, but you can:

  • Specify a different workspace using the workspace parameter
  • Use workspace='~' to work with your personal workspace
  • Create repositories in team workspaces if you have permissions

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-api" '{"command":"uv","args":["run","--directory","/path/to/mcp-bitbucket","-m","mcp_bitbucket.server"],"env":{"BITBUCKET_USERNAME":"your-username","BITBUCKET_APP_PASSWORD":"your-app-password"}}'

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-api": {
            "command": "uv",
            "args": [
                "run",
                "--directory",
                "/path/to/mcp-bitbucket",
                "-m",
                "mcp_bitbucket.server"
            ],
            "env": {
                "BITBUCKET_USERNAME": "your-username",
                "BITBUCKET_APP_PASSWORD": "your-app-password"
            }
        }
    }
}

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-api": {
            "command": "uv",
            "args": [
                "run",
                "--directory",
                "/path/to/mcp-bitbucket",
                "-m",
                "mcp_bitbucket.server"
            ],
            "env": {
                "BITBUCKET_USERNAME": "your-username",
                "BITBUCKET_APP_PASSWORD": "your-app-password"
            }
        }
    }
}

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