Sponsored by Deepsite.site

MCP Server for Bitbucket API

Created By
JaviMalignoa month ago
MCP server with 58 tools for Bitbucket API operations. Manage repositories, pull requests, pipelines, branches, commits, deployments, webhooks, tags, branch restrictions, and source browsing. Works with Claude Desktop, Claude Code, and any MCP-compatible client.
Content

Bitbucket MCP Server

CI/CD PyPI version Python 3.11+ License: MIT

MCP server for Bitbucket API operations. Works with Claude Code, Claude Desktop, and any MCP-compatible client.

Features

  • Repositories: get, create, delete, list, update (move to project, rename)
  • Pull Requests: create, get, list, merge, approve, decline, request changes, comments, diff
  • Pipelines: trigger, get status, list, view logs, stop
  • Branches: list, get
  • Projects: list, get
  • Commits: list, get details, compare/diff between branches
  • Commit Statuses: get build statuses, create status (CI/CD integration)
  • Deployments: list environments, get environment details, deployment history
  • Webhooks: list, create, get, delete
  • Tags: list, create, delete
  • Branch Restrictions: list, create, delete branch protection rules
  • Source Browsing: read files, list directories without cloning
  • Repository Permissions: manage user and group permissions
  • Pipeline Variables: manage CI/CD environment variables
  • MCP Prompts: reusable workflow templates (code review, release notes, etc.)
  • MCP Resources: browsable workspace data

Quick Start

# Install
pipx install mcp-server-bitbucket

# Configure Claude Code
claude mcp add bitbucket -s user \
  -e BITBUCKET_WORKSPACE=your-workspace \
  -e BITBUCKET_EMAIL=your-email@example.com \
  -e BITBUCKET_API_TOKEN=your-api-token \
  -- mcp-server-bitbucket

Full Installation Guide - Includes API token creation, permissions setup, and troubleshooting.

Available Tools (58 total)

Repositories

ToolDescription
list_repositoriesList and search repositories (supports fuzzy name matching)
get_repositoryGet repository details
create_repositoryCreate a new repository
delete_repositoryDelete a repository
update_repositoryUpdate repo settings (project, visibility, description, name)

Branches & Commits

ToolDescription
list_branchesList branches in a repo
get_branchGet branch details
list_commitsList commits (filter by branch or file path)
get_commitGet commit details
compare_commitsCompare two commits/branches (diff stats)

Tags

ToolDescription
list_tagsList tags in a repo
create_tagCreate a new tag
delete_tagDelete a tag

Branch Restrictions

ToolDescription
list_branch_restrictionsList branch protection rules
create_branch_restrictionCreate branch protection rule
delete_branch_restrictionDelete branch protection rule

Source (File Browsing)

ToolDescription
get_file_contentRead file contents without cloning
list_directoryList directory contents

Commit Statuses (CI/CD)

ToolDescription
get_commit_statusesGet build/CI statuses for a commit
create_commit_statusReport build status from external CI

Pull Requests

ToolDescription
list_pull_requestsList PRs (open, merged, etc.)
get_pull_requestGet PR details
create_pull_requestCreate a new PR
merge_pull_requestMerge a PR
approve_prApprove a PR
unapprove_prRemove approval from a PR
request_changes_prRequest changes on a PR
decline_prDecline (close) a PR
list_pr_commentsList comments on a PR
add_pr_commentAdd comment to a PR (general or inline)
get_pr_diffGet the diff of a PR

Pipelines

ToolDescription
list_pipelinesList recent pipeline runs
get_pipelineGet pipeline status
get_pipeline_logsView pipeline logs
trigger_pipelineTrigger a pipeline run
stop_pipelineStop a running pipeline

Pipeline Variables

ToolDescription
list_pipeline_variablesList pipeline variables for a repo
get_pipeline_variableGet variable details
create_pipeline_variableCreate a new pipeline variable
update_pipeline_variableUpdate variable value
delete_pipeline_variableDelete a pipeline variable

Deployments

ToolDescription
list_environmentsList deployment environments (test, staging, prod)
get_environmentGet environment details
list_deployment_historyGet deployment history for an environment

Webhooks

ToolDescription
list_webhooksList configured webhooks
create_webhookCreate a new webhook
get_webhookGet webhook details
delete_webhookDelete a webhook

Repository Permissions

ToolDescription
list_user_permissionsList user permissions for a repo
get_user_permissionGet specific user's permission
update_user_permissionAdd/update user permission
delete_user_permissionRemove user permission
list_group_permissionsList group permissions for a repo
get_group_permissionGet specific group's permission
update_group_permissionAdd/update group permission
delete_group_permissionRemove group permission

Projects

ToolDescription
list_projectsList projects in workspace
get_projectGet project details

MCP Prompts

Reusable workflow templates that guide Claude through common tasks:

PromptDescription
code_reviewComprehensive PR code review
release_notesGenerate changelog between versions
pipeline_debugDebug failed CI/CD pipelines
repo_summaryComplete repository status overview

MCP Resources

Browsable workspace data as markdown:

Resource URIDescription
bitbucket://repositoriesList all repos in workspace
bitbucket://repositories/{repo}Repository details
bitbucket://repositories/{repo}/branchesBranch list
bitbucket://repositories/{repo}/pull-requestsOpen PRs
bitbucket://projectsList all projects

Example Usage

Once configured, ask Claude to:

Repositories & Branches:

  • "List all repositories in my workspace"
  • "Search for repositories with 'api' in the name"
  • "Show me the last 10 commits on the main branch"
  • "Compare develop branch with main"

Pull Requests & Code Review:

  • "Show me open pull requests in my-repo"
  • "Create a PR from feature-branch to main"
  • "Approve PR #42"
  • "Add a comment to PR #15 saying 'Looks good!'"
  • "Show me the diff for PR #42"
  • "Merge PR #42 using squash strategy"

Pipelines & CI/CD:

  • "Trigger a pipeline on the develop branch"
  • "What's the status of the latest pipeline?"
  • "Get the build status for commit abc123"

Deployments:

  • "List deployment environments for my-repo"
  • "Show deployment history for production"

Webhooks:

  • "List webhooks configured for my-repo"
  • "Create a webhook for push events"

Tags:

  • "List all tags in my-repo"
  • "Create a tag v1.0.0 on the main branch"
  • "Delete the old-release tag"

Branch Protection:

  • "List branch restrictions for my-repo"
  • "Require 2 approvals to merge to main"
  • "Prevent force push to production branches"

Source Browsing:

  • "Show me the contents of src/main.py"
  • "List files in the root directory"
  • "Read the README.md from the develop branch"

Repository Permissions:

  • "List user permissions for my-repo"
  • "Give user@example.com write access to my-repo"
  • "List group permissions for my-repo"
  • "Grant admin access to the DevOps group"

The list_repositories tool supports flexible searching:

# Simple fuzzy search by name
list_repositories(search="api")  # Finds repos with "api" in name

# Advanced Bitbucket query syntax
list_repositories(query='name ~ "test" AND is_private = true')

# Filter by project
list_repositories(project_key="MYPROJECT")

Query syntax supports: name ~ "term", is_private = true/false, AND, OR

Installation Options

pipx install mcp-server-bitbucket
# or
pip install mcp-server-bitbucket

Updating

# Upgrade to latest version
pipx upgrade mcp-server-bitbucket

# If upgrade doesn't pick up the new version, reinstall:
pipx uninstall mcp-server-bitbucket
pipx install mcp-server-bitbucket

From Source

git clone https://github.com/JaviMaligno/mcp-server-bitbucket.git
cd mcp-server-bitbucket
uv sync

Configuration

claude mcp add bitbucket -s user \
  -e BITBUCKET_WORKSPACE=your-workspace \
  -e BITBUCKET_EMAIL=your-email@example.com \
  -e BITBUCKET_API_TOKEN=your-api-token \
  -- mcp-server-bitbucket

Output Format (Optional)

Set OUTPUT_FORMAT to optimize token usage:

# TOON format for ~30-40% token savings
claude mcp add bitbucket -s user \
  -e OUTPUT_FORMAT=toon \
  -e BITBUCKET_WORKSPACE=your-workspace \
  -e BITBUCKET_EMAIL=your-email@example.com \
  -e BITBUCKET_API_TOKEN=your-api-token \
  -- mcp-server-bitbucket
FormatDescriptionUse case
json (default)Standard JSONMaximum compatibility, debugging
toonTOON formatHigh-volume usage, token cost optimization

Cursor IDE

Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):

{
  "mcpServers": {
    "bitbucket": {
      "command": "mcp-server-bitbucket",
      "env": {
        "BITBUCKET_WORKSPACE": "your-workspace",
        "BITBUCKET_EMAIL": "your-email@example.com",
        "BITBUCKET_API_TOKEN": "your-api-token"
      }
    }
  }
}

Claude Desktop / Manual Configuration

Add to ~/.claude.json:

{
  "mcpServers": {
    "bitbucket": {
      "command": "mcp-server-bitbucket",
      "env": {
        "BITBUCKET_WORKSPACE": "your-workspace",
        "BITBUCKET_EMAIL": "your-email@example.com",
        "BITBUCKET_API_TOKEN": "your-api-token",
        "OUTPUT_FORMAT": "json"
      }
    }
  }
}

Creating a Bitbucket API Token

  1. Go to your repository in Bitbucket
  2. Navigate to Repository settings > Access tokens
  3. Click Create Repository Access Token
  4. Select permissions:
    • Repository: Read, Write, Admin, Delete
    • Pull requests: Read, Write
    • Pipelines: Read, Write
  5. Copy the token immediately

See the full installation guide for detailed instructions.

HTTP Server (Remote Deployment)

Deploy the MCP server as an HTTP service for remote access from any MCP client. Uses the standard MCP Streamable HTTP transport protocol.

Running Locally

# Start HTTP server on port 8080
uv run python -m src.http_server

# Or with uvicorn for development (auto-reload)
uv run uvicorn src.http_server:app --reload --port 8080

# Custom port
PORT=3000 uv run python -m src.http_server

Deploy to Cloud Run (Google Cloud)

# Deploy with secrets
gcloud run deploy bitbucket-mcp \
  --source . \
  --region us-central1 \
  --set-env-vars "BITBUCKET_WORKSPACE=your-workspace" \
  --set-secrets "BITBUCKET_EMAIL=bitbucket-email:latest,BITBUCKET_API_TOKEN=bitbucket-token:latest" \
  --allow-unauthenticated  # Or configure IAM for auth

Deploy to Railway/Render/Fly.io

Set these environment variables in your platform:

  • BITBUCKET_WORKSPACE: Your Bitbucket workspace slug
  • BITBUCKET_EMAIL: Your Bitbucket account email
  • BITBUCKET_API_TOKEN: Your repository access token
  • PORT: (usually auto-set by platform)

Docker Deployment

# Build image
docker build -t bitbucket-mcp .

# Run container
docker run -p 8080:8080 \
  -e BITBUCKET_WORKSPACE=your-workspace \
  -e BITBUCKET_EMAIL=your-email \
  -e BITBUCKET_API_TOKEN=your-token \
  bitbucket-mcp

Connecting Claude Code to Remote Server

Once deployed, connect Claude Code to your remote MCP server:

# Add remote MCP server
claude mcp add bitbucket-remote \
  --transport streamable-http \
  --url https://your-deployment-url.com/mcp

# Or with authentication header (if required)
claude mcp add bitbucket-remote \
  --transport streamable-http \
  --url https://your-deployment-url.com/mcp \
  --header "Authorization: Bearer YOUR_TOKEN"

Manual Configuration for Remote Server

Add to ~/.claude.json:

{
  "mcpServers": {
    "bitbucket-remote": {
      "type": "streamable-http",
      "url": "https://your-deployment-url.com/mcp"
    }
  }
}

Development

Requirements

  • Python 3.11+
  • uv for dependency management
  • PyPI account for publishing

Setup

git clone https://github.com/JaviMaligno/mcp-server-bitbucket.git
cd mcp-server-bitbucket
uv sync

Running Locally

# MCP server (stdio mode)
uv run python -m src.server

# HTTP server
uv run uvicorn src.http_server:app --reload --port 8080

CI/CD Pipeline

The project uses GitHub Actions for automated testing and publishing:

  • Every push to main: Runs tests with coverage
  • Pull requests: Runs full test suite
  • Tags (v*): Tests, builds, and publishes to PyPI

To release a new version:

# 1. Bump version in pyproject.toml
# 2. Commit changes
git add -A && git commit -m "release: v0.x.x"
git push origin main

# 3. Create and push tag (triggers PyPI publish)
git tag v0.x.x
git push origin v0.x.x

Manual Publishing

If you need to publish manually:

  1. Get a PyPI API Token:

  2. Build and publish:

    uv build
    uv publish
    

License

MIT

Server Config

{
  "mcpServers": {
    "bitbucket": {
      "command": "mcp-server-bitbucket",
      "env": {
        "BITBUCKET_WORKSPACE": "your-workspace",
        "BITBUCKET_EMAIL": "your-email@example.com",
        "BITBUCKET_API_TOKEN": "your-token"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
ChatWiseThe second fastest AI chatbot™
Serper MCP ServerA Serper MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop