Skip to main content

MCP server for Bitbucket API operations

Project description

Bitbucket MCP Server

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
  • Pipelines: trigger, get status, list, view logs, stop
  • Branches: list, get
  • Projects: list, get

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

Tool Description
list_repositories List and search repositories (supports fuzzy name matching)
get_repository Get repository details
create_repository Create a new repository
delete_repository Delete a repository
list_branches List branches in a repo
get_branch Get branch details
list_projects List projects in workspace
get_project Get project details
update_repository Update repo settings (project, visibility, description, name)
list_pull_requests List PRs (open, merged, etc.)
get_pull_request Get PR details
create_pull_request Create a new PR
merge_pull_request Merge a PR
list_pipelines List recent pipeline runs
get_pipeline Get pipeline status
get_pipeline_logs View pipeline logs
trigger_pipeline Trigger a pipeline run
stop_pipeline Stop a running pipeline

Example Usage

Once configured, ask Claude to:

  • "List all repositories in my workspace"
  • "Search for repositories with 'api' in the name"
  • "Find all private repos containing 'test'"
  • "List all projects in the workspace"
  • "Move repository my-repo to project DS"
  • "Show me open pull requests in my-repo"
  • "Create a PR from feature-branch to main"
  • "Trigger a pipeline on the develop branch"
  • "What's the status of the latest pipeline?"
  • "Merge PR #42 using squash strategy"

Repository Search

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

From PyPI (Recommended)

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

From Source

git clone git@bitbucket.org:simplekyc/bitbucket-mcp.git
cd bitbucket-mcp
poetry install

Configuration

Claude Code CLI (Recommended)

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

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"
      }
    }
  }
}

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 (Cloud Run)

For deploying as an HTTP API:

# Run locally
poetry run uvicorn src.http_server:app --reload --port 8080

# Deploy to Cloud Run
gcloud run deploy bitbucket-mcp-service \
  --source . \
  --region australia-southeast1 \
  --set-secrets "BITBUCKET_EMAIL=bitbucket-email:latest,BITBUCKET_API_TOKEN=bitbucket-token:latest"

Development

Requirements

Setup

git clone git@bitbucket.org:simplekyc/bitbucket-mcp.git
cd bitbucket-mcp
poetry install

Running Locally

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

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

Publishing to PyPI

  1. Get a PyPI API Token:

  2. Bump version in pyproject.toml

  3. Build and publish:

    poetry build
    poetry publish
    
  4. Tag the release:

    git tag v0.x.x
    git push origin v0.x.x
    

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_bitbucket-0.1.8.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_bitbucket-0.1.8-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_bitbucket-0.1.8.tar.gz.

File metadata

  • Download URL: mcp_server_bitbucket-0.1.8.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Darwin/24.6.0

File hashes

Hashes for mcp_server_bitbucket-0.1.8.tar.gz
Algorithm Hash digest
SHA256 1ad47f3212ca1b8429bd63a354f65ec24d242257b06de02cf84d4c0b3aff32f5
MD5 42cb4d794fc33f227900b4c0fd8297c9
BLAKE2b-256 85cd69f63d35b5ca2bfbd99f97990bf55b24abd673f26f742379b3c1d25fbf33

See more details on using hashes here.

File details

Details for the file mcp_server_bitbucket-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_bitbucket-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 83a711b2f4761740ca9f23e1ce413e909bcfc2b926f5c3cb196de46bc73fdb90
MD5 65dd37e19f3ae1d8a8ad42845d93ca78
BLAKE2b-256 7acd574d2c0a95ece6db90d8bdd8303939e263f94a285292fa5d410b986bd154

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page