A Model Context Protocol (MCP) server for Bitbucket Cloud API integration
Project description
Bitbucket Cloud MCP Server
A production-ready Model Context Protocol (MCP) server for seamless integration with the Bitbucket Cloud API. Built with enterprise-grade quality standards, this server provides comprehensive access to Bitbucket Cloud's functionalities through a standardized MCP interface.
๐ Highlights
- โ Complete Bitbucket Cloud API Coverage - All essential features implemented
- โ Production Ready - Comprehensive error handling, logging, and type safety
- โ Multiple Installation Methods - PyPI, direct execution, or development mode
- โ Claude Desktop Integration - Ready for AI assistant workflows
- โ Fully Tested - Comprehensive test suite with automated CI/CD
- โ Clean Architecture - Modular design following SOLID principles
๐ ๏ธ Features (15 Tools)
๐ฏ Project & Repository Management
list_projects- List all accessible projects in workspacelist_repositories- List repositories by workspace or projectlist_commits- Browse commit history with filtering options
๐ Pull Request Lifecycle
list_pull_requests- List PRs with state filtering (OPEN, MERGED, DECLINED)get_pull_request- Get detailed PR informationcreate_pull_request- Create new pull requests with reviewersupdate_pull_request- Update pull request title and/or descriptionapprove_pull_request- Approve pull requestsdecline_pull_request- Decline pull requestsmerge_pull_request- Merge approved PRs with strategy selection
๐ฌ Comment System
list_pull_request_comments- List all PR commentscreate_pull_request_comment- Add general commentscreate_pull_request_inline_comment- Add line-specific code comments
๐ Code Analysis
get_pull_request_diff- Get full diff for code reviewget_pull_request_diffstat- Get summary of changes (files, lines added/removed)
๐ Installation & Usage
Method 1: Direct Execution via uvx (Recommended)
# No installation needed - run directly from PyPI
uvx bitbucket-mcp-cloud
# For MCP tools that support it
mcp run bitbucket-mcp-cloud
Method 2: Global Installation
# Install globally
pip install bitbucket-mcp-cloud
# Run the server
bitbucket-mcp-cloud
Method 3: Development Mode
# Clone and setup for development
git clone https://github.com/jhonymiler/Bitbucket-MCP-Cloud.git
cd Bitbucket-MCP-Cloud
# Using uv (recommended)
uv sync
uv run server.py
# Or using pip
pip install -e .
python server.py
Method 4: MCP Tools Integration
# Using the MCP CLI
mcp run server.py
# For development and testing
uv run mcp dev server.py
๐ Prerequisites
- Python 3.10+
- A Bitbucket Cloud account
- Configured Bitbucket App Password
โ๏ธ Setup
1. Create Bitbucket App Password
- Go to: Account Settings > App Passwords
- Click "Create app password"
- Select the required permissions:
- Repositories: Read, Write
- Pull requests: Read, Write
- Projects: Read
2. Configure Environment Variables
# Option 1: Using .env file (for development)
cp .env.example .env
# Edit .env with your credentials
# Option 2: Export environment variables
export BITBUCKET_USERNAME=your_username
export BITBUCKET_TOKEN=your_app_password
export BITBUCKET_DEFAULT_WORKSPACE=your_workspace
3. Claude Desktop Integration
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"bitbucket": {
"command": "uvx",
"args": ["bitbucket-mcp-cloud"],
"env": {
"BITBUCKET_USERNAME": "your_username",
"BITBUCKET_TOKEN": "your_app_password",
"BITBUCKET_DEFAULT_WORKSPACE": "your_workspace"
}
}
}
}
๐ง Tool Usage Examples
Projects and Repositories
# List projects
await list_projects(workspace="my-workspace", limit=25)
# List all repositories
await list_repositories(workspace="my-workspace")
# List repositories for a specific project
await list_repositories(workspace="my-workspace", project="PROJ")
Pull Requests
# List open PRs
await list_pull_requests(repository="my-repo", state="OPEN")
# Get PR details
await get_pull_request(repository="my-repo", pr_id=123)
# Create new PR
await create_pull_request(
repository="my-repo",
title="New feature",
source_branch="feature/new-feature",
target_branch="main",
description="Implements new feature X"
)
# Update PR description
await update_pull_request(
repository="my-repo",
pr_id=123,
description="Updated description with more details"
)
# Approve and merge PR
await approve_pull_request(repository="my-repo", pr_id=123)
await merge_pull_request(repository="my-repo", pr_id=123, merge_strategy="squash")
Comments and Code Review
# Create inline comment on specific line
await create_pull_request_inline_comment(
repository="my-repo",
pr_id=123,
content="This function could be optimized",
filename="src/main.py",
line_number=42
)
# Get diff for analysis
diff_text = await get_pull_request_diff(repository="my-repo", pr_id=123)
# Get summary of changes
diffstat = await get_pull_request_diffstat(repository="my-repo", pr_id=123)
๐๏ธ Architecture
bitbucket-mcp-cloud/
โโโ server.py # Main MCP server (entry point)
โโโ src/
โ โโโ models.py # Pydantic models for type safety
โ โโโ utils.py # Utility functions and logging
โ โโโ __init__.py
โโโ tests/ # Comprehensive test suite
โ โโโ test_bitbucket_mcp.py
โโโ pyproject.toml # Project configuration
โโโ .env.example # Configuration template
โโโ .github/
โ โโโ workflows/
โ โโโ publish.yml # CI/CD pipeline
โโโ README.md # This documentation
Key Components
BitbucketCloudClient: Async HTTP client with comprehensive API coverageFastMCP: MCP server with auto-generated tool definitions- Pydantic Models: Type-safe data structures for all API responses
- Comprehensive Logging: Detailed operation tracking and debugging
- Error Handling: Robust error handling with proper HTTP status codes
๐งช Testing
# Run all tests
uv run pytest
# Run with coverage report
uv run pytest --cov=src --cov-report=html
# Run specific test categories
uv run pytest tests/test_bitbucket_mcp.py::TestMCPTools -v
# Type checking
uv run mypy server.py src/
# Code formatting
uv run black server.py src/ tests/
๐ Security Features
- Secure Authentication: Uses Bitbucket App Passwords (no OAuth complexity)
- Input Validation: Comprehensive validation using Pydantic models
- Error Handling: Sanitized error messages (no credential leakage)
- Rate Limiting Awareness: Respects Bitbucket API rate limits
- HTTPS Only: All communications encrypted
๐ Quality Assurance
- Type Safety: Full type annotations with mypy validation
- Code Quality: Black formatting and comprehensive linting
- Testing: 17 test cases covering all major functionality
- CI/CD: Automated testing and PyPI publishing
- Documentation: Comprehensive docstrings and examples
๐ API Reference
This MCP server implements the complete Bitbucket Cloud REST API v2.0. Key API endpoints covered:
/workspaces/{workspace}/projects- Project management/repositories/{workspace}- Repository operations/repositories/{workspace}/{repo}/pullrequests- PR lifecycle/repositories/{workspace}/{repo}/commits- Commit history/pullrequests/{pr_id}/comments- Comment system/pullrequests/{pr_id}/diff- Code analysis
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run tests (
uv run pytest) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
# Clone and setup
git clone https://github.com/jhonymiler/Bitbucket-MCP-Cloud.git
cd Bitbucket-MCP-Cloud
uv sync --extra dev
# Run quality checks
uv run pytest
uv run mypy server.py src/
uv run black --check server.py src/ tests/
๐ Changelog
v1.3.5 (Latest)
- โ Package restructured for optimal PyPI distribution
- โ Server.py in root with conditional imports
- โ All execution methods tested and working
- โ Enhanced build system and CI/CD
- โ Production-ready package structure
v1.3.4
- โ Server correctly included in PyPI wheel
- โ All execution methods working (uvx, pip, development)
- โ Complete test coverage
- โ Claude Desktop integration ready
v1.3.x Series
- โ Complete Bitbucket Cloud API implementation
- โ Comprehensive error handling and logging
- โ Type safety with mypy validation
- โ Production-ready architecture
๐ License
MIT License - see the LICENSE file for details.
๐ Support
- Issues: GitHub Issues
- Documentation: This README and inline code documentation
- API Reference: Bitbucket Cloud REST API
๐ Related Links
- Model Context Protocol Specification
- FastMCP Framework
- Claude Desktop
- Bitbucket App Passwords Guide
- uv Python Package Manager
Made with โค๏ธ for the MCP community
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitbucket_mcp_cloud-1.3.7.tar.gz.
File metadata
- Download URL: bitbucket_mcp_cloud-1.3.7.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92cf75825d32f7095a270aba93e5a76408427d2c23226480c9754c0279b487f1
|
|
| MD5 |
041f8cb9ec2f0cee9cbdf1c3ef7a887a
|
|
| BLAKE2b-256 |
612264fc6e0a2bf4b9eba7a702a141c804782f5f8fc33684d4caed5f9edcc03b
|
Provenance
The following attestation bundles were made for bitbucket_mcp_cloud-1.3.7.tar.gz:
Publisher:
publish.yml on jhonymiler/Bitbucket-MCP-Cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bitbucket_mcp_cloud-1.3.7.tar.gz -
Subject digest:
92cf75825d32f7095a270aba93e5a76408427d2c23226480c9754c0279b487f1 - Sigstore transparency entry: 264784674
- Sigstore integration time:
-
Permalink:
jhonymiler/Bitbucket-MCP-Cloud@52a0cae5c0cf42ebc41eac68baed423cbda0df91 -
Branch / Tag:
refs/tags/v1.3.8 - Owner: https://github.com/jhonymiler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52a0cae5c0cf42ebc41eac68baed423cbda0df91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bitbucket_mcp_cloud-1.3.7-py3-none-any.whl.
File metadata
- Download URL: bitbucket_mcp_cloud-1.3.7-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
098ea54a058bacdadc921f9f3c83dca40a5e841bf8c5a6b33e5d00267c2d6e7f
|
|
| MD5 |
4a0bb47c3cffa9de5c50c6259d4e6d21
|
|
| BLAKE2b-256 |
4d3940e73a5ed68cf3a47c7ba46369d7745b5cc0488fea322ac6b8a559dc4dcb
|
Provenance
The following attestation bundles were made for bitbucket_mcp_cloud-1.3.7-py3-none-any.whl:
Publisher:
publish.yml on jhonymiler/Bitbucket-MCP-Cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bitbucket_mcp_cloud-1.3.7-py3-none-any.whl -
Subject digest:
098ea54a058bacdadc921f9f3c83dca40a5e841bf8c5a6b33e5d00267c2d6e7f - Sigstore transparency entry: 264784675
- Sigstore integration time:
-
Permalink:
jhonymiler/Bitbucket-MCP-Cloud@52a0cae5c0cf42ebc41eac68baed423cbda0df91 -
Branch / Tag:
refs/tags/v1.3.8 - Owner: https://github.com/jhonymiler
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52a0cae5c0cf42ebc41eac68baed423cbda0df91 -
Trigger Event:
push
-
Statement type: