Bitbucket MCP server

Integrates with Bitbucket's REST APIs to enable repository management, pull request handling, and workspace operations with TypeScript-based error handling and pagination support
Back to servers
Setup instructions
Provider
Andi Ashari
Release date
Mar 25, 2025
Language
TypeScript
Package
Stats
27.1K downloads
70 stars

This MCP server allows you to connect AI assistants like Claude and Cursor AI directly to your Bitbucket repositories. It enables AI tools to access, search, and interact with your code, pull requests, and repositories using natural language commands.

Installation

Set Up Bitbucket Credentials

Before using the MCP server, you'll need to generate Bitbucket credentials:

  1. Generate a Bitbucket App Password:
    • Go to Bitbucket App Passwords
    • Click "Create app password"
    • Name it something like "AI Assistant"
    • Select these permissions:
      • Workspaces: Read
      • Repositories: Read (and Write if you want AI to create PRs/comments)
      • Pull Requests: Read (and Write for PR management)

Quick Test

You can quickly test the server with npx:

# Set your credentials (choose one method)

# Method 1: Standard Atlassian credentials (recommended)
export ATLASSIAN_SITE_NAME="your-company"  # for your-company.atlassian.net
export ATLASSIAN_USER_EMAIL="[email protected]"
export ATLASSIAN_API_TOKEN="your_api_token"

# OR Method 2: Bitbucket-specific credentials
export ATLASSIAN_BITBUCKET_USERNAME="your_username"
export ATLASSIAN_BITBUCKET_APP_PASSWORD="your_app_password"

# List your workspaces
npx -y @aashari/mcp-server-atlassian-bitbucket ls-workspaces

# List repositories in your workspace
npx -y @aashari/mcp-server-atlassian-bitbucket ls-repos --workspace-slug your-workspace

# Get details about a specific repository  
npx -y @aashari/mcp-server-atlassian-bitbucket get-repo --workspace-slug your-workspace --repo-slug your-repo

Connecting to AI Assistants

For Claude Desktop

Add this to your Claude configuration file (~/.claude/claude_desktop_config.json):

Option 1: Standard Atlassian credentials (recommended)

{
  "mcpServers": {
    "bitbucket": {
      "command": "npx",
      "args": ["-y", "@aashari/mcp-server-atlassian-bitbucket"],
      "env": {
        "ATLASSIAN_SITE_NAME": "your-company",
        "ATLASSIAN_USER_EMAIL": "[email protected]",
        "ATLASSIAN_API_TOKEN": "your_api_token"
      }
    }
  }
}

Option 2: Bitbucket-specific credentials

{
  "mcpServers": {
    "bitbucket": {
      "command": "npx",
      "args": ["-y", "@aashari/mcp-server-atlassian-bitbucket"],
      "env": {
        "ATLASSIAN_BITBUCKET_USERNAME": "your_username",
        "ATLASSIAN_BITBUCKET_APP_PASSWORD": "your_app_password"
      }
    }
  }
}

Restart Claude Desktop, and you'll see "🔗 bitbucket" in the status bar.

For Other AI Assistants

Most AI assistants support MCP. Install the server globally:

npm install -g @aashari/mcp-server-atlassian-bitbucket

Then configure your AI assistant to use the MCP server with STDIO transport.

Using a Configuration File

Create ~/.mcp/configs.json for system-wide configuration:

Option 1: Standard Atlassian credentials (recommended)

{
  "bitbucket": {
    "environments": {
      "ATLASSIAN_SITE_NAME": "your-company",
      "ATLASSIAN_USER_EMAIL": "[email protected]",
      "ATLASSIAN_API_TOKEN": "your_api_token",
      "BITBUCKET_DEFAULT_WORKSPACE": "your_main_workspace"
    }
  }
}

Option 2: Bitbucket-specific credentials

{
  "bitbucket": {
    "environments": {
      "ATLASSIAN_BITBUCKET_USERNAME": "your_username",
      "ATLASSIAN_BITBUCKET_APP_PASSWORD": "your_app_password",
      "BITBUCKET_DEFAULT_WORKSPACE": "your_main_workspace"
    }
  }
}

Usage Examples

Repository Exploration

Ask your AI assistant:

  • "List all repositories in my main workspace"
  • "Show me details about the backend-api repository"
  • "What's the commit history for the feature-auth branch?"
  • "Get the content of src/config.js from the main branch"

Pull Request Management

Ask your AI assistant:

  • "Show me all open pull requests that need review"
  • "Get details about pull request #42 including the code changes"
  • "Create a pull request from feature-login to main branch"
  • "Add a comment to PR #15 saying the tests passed"
  • "Approve pull request #33"

Branch and Code Operations

Ask your AI assistant:

  • "Compare my feature branch with the main branch"
  • "Create a new branch called hotfix-login from the main branch"
  • "List all branches in the user-service repository"
  • "Show me the differences between commits abc123 and def456"

Search Features

Ask your AI assistant:

  • "Search for JavaScript files that contain 'authentication'"
  • "Find all pull requests related to the login feature"
  • "Search for repositories in the mobile project"
  • "Show me code files that use the React framework"

Troubleshooting

Authentication Issues

If you get "Authentication failed" or "403 Forbidden":

  1. Choose the right authentication method:

    • Standard Atlassian method: Use your Atlassian account email + API token
    • Bitbucket-specific method: Use your Bitbucket username + App password
  2. For Bitbucket App Passwords:

    • Check that your app password has the right permissions (Workspaces: Read, Repositories: Read, Pull Requests: Read)
  3. For Atlassian API Tokens:

    • Make sure your token is still active
  4. Verify your credentials:

    # Test your credentials work
    npx -y @aashari/mcp-server-atlassian-bitbucket ls-workspaces
    

Resource Not Found Errors

If you get "Workspace not found" or "Repository not found":

  1. Check your workspace slug:

    # List your workspaces to see the correct slugs
    npx -y @aashari/mcp-server-atlassian-bitbucket ls-workspaces
    
  2. Use the exact slug from Bitbucket URL:

    • If your repo URL is https://bitbucket.org/myteam/my-repo
    • Workspace slug is myteam
    • Repository slug is my-repo

Default Workspace Issues

If you get "No default workspace configured", set a default workspace:

export BITBUCKET_DEFAULT_WORKSPACE="your-main-workspace-slug"

Claude Desktop Integration Issues

  1. Restart Claude Desktop after updating the config file
  2. Check the status bar for the "🔗 bitbucket" indicator
  3. Verify config file location:
    • macOS: ~/.claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json

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":"npx","args":["-y","@aashari/mcp-server-atlassian-bitbucket"]}'

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": "npx",
            "args": [
                "-y",
                "@aashari/mcp-server-atlassian-bitbucket"
            ]
        }
    }
}

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": "npx",
            "args": [
                "-y",
                "@aashari/mcp-server-atlassian-bitbucket"
            ]
        }
    }
}

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