mcp-bitbucket
Provides tools for interacting with Bitbucket Cloud REST API v2.0, enabling AI agents to manage repositories, pull requests (including drafts, comments, and pending reviews), branching models, and pipelines.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-bitbucketShow open pull requests"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-bitbucket
Python MCP (Model Context Protocol) server for Bitbucket Cloud (REST API v2.0), built with FastMCP. It exposes 35 tools covering repositories, pull requests (including comments, drafts, and pending reviews), branching models, and pipelines — enabling AI clients (Cursor, Claude Code, etc.) to safely automate Bitbucket workflows.
Table of Contents
Related MCP server: Bitbucket MCP Server
Features
Full Bitbucket Cloud REST API v2.0 coverage for common workflows
Two transport modes: stdio (for local AI clients) and SSE/HTTP (for Docker/remote)
Draft pull requests and pending (unpublished) comments support
Cross-repository pending review detection
Branching model management at both repository and project levels
Pipeline management: trigger, stop, inspect runs, steps, and logs
Built-in health check with connectivity validation
Multi-project support with separate credentials per workspace
Docker-ready with health checks, resource limits, and non-root user
Requirements
Python 3.10+
uv package manager (
pipx install uvor follow uv docs)Bitbucket Cloud account with one of:
App Password (recommended) for
BITBUCKET_USERNAME/BITBUCKET_PASSWORDOAuth token via
BITBUCKET_TOKEN
Recommended App Password Scopes
Scope | Required for |
| Listing repos, branching models |
| Reading PRs, comments, diffs, commits |
| Creating/updating/merging PRs, comments |
| Listing and inspecting pipeline runs |
| Triggering and stopping pipelines |
Installation
# Clone the repository
git clone https://github.com/webboy/mcp-bitbucket.git
cd mcp-bitbucket
# Install in editable mode
uv pip install -e .Dependencies
Package | Purpose |
| MCP SDK with CLI support |
| HTTP client for Bitbucket API |
| Data validation and tool parameter schemas |
| Structured logging |
| ASGI server for SSE transport |
| ASGI framework |
Configuration
All configuration is done via environment variables:
Variable | Default | Description |
|
| Bitbucket Cloud API base URL |
| — | OAuth Bearer token (alternative to username/password) |
| — | Bitbucket username (for App Password auth) |
| — | Bitbucket App Password |
| — | Default workspace slug (optional but convenient) |
|
| Transport type: |
|
| Host to bind SSE server |
|
| Port for SSE server |
|
| Log level: |
Note: Either
BITBUCKET_TOKENorBITBUCKET_USERNAME+BITBUCKET_PASSWORDmust be set. TheBITBUCKET_USERNAMEis also required for thegetPendingReviewPRstool to identify the current reviewer.
Running the Server
stdio mode (default)
BITBUCKET_USERNAME='<user>' \
BITBUCKET_PASSWORD='<app_password>' \
BITBUCKET_WORKSPACE='<workspace>' \
uv run mcp-bitbucketThe server uses stdio and waits for an MCP client to connect.
SSE/HTTP mode
BITBUCKET_USERNAME='<user>' \
BITBUCKET_PASSWORD='<app_password>' \
BITBUCKET_WORKSPACE='<workspace>' \
uv run mcp-bitbucket --transport sse --port 9000The server starts an HTTP endpoint at http://0.0.0.0:9000/sse.
CLI Arguments
Argument | Default | Description |
|
|
|
|
| Bind host for SSE |
|
| Bind port for SSE |
Docker Usage (HTTP/SSE Transport)
The MCP server runs in a Docker container using HTTP/SSE transport, allowing a single long-running container that handles multiple client connections.
Quick Start
Create environment file:
cp .env.example .env
# Edit .env with your Bitbucket credentialsBuild and start the container:
docker-compose up -d --buildConfigure your AI client (e.g., Cursor
~/.cursor/mcp.json):
{
"mcpServers": {
"bitbucket": {
"url": "http://localhost:9000/sse"
}
}
}Restart your AI client — The Bitbucket MCP server should now be available!
Manual Docker Commands
# Build the image
docker build -t mcp-bitbucket:latest .
# Run with docker-compose
docker-compose up -d # Start in background
docker-compose logs -f # View logs
docker-compose down # Stop
# Run directly
docker run -d \
--name mcp-bitbucket \
-p 9000:9000 \
-e BITBUCKET_USERNAME=your_username \
-e BITBUCKET_PASSWORD=your_app_password \
-e BITBUCKET_WORKSPACE=your_workspace \
-e MCP_TRANSPORT=sse \
mcp-bitbucket:latestHealth Check
curl http://localhost:9000/sseContainer Management
docker ps | grep mcp-bitbucket # Check if running
docker logs mcp-bitbucket # View logs
docker restart mcp-bitbucket # Restart
docker stop mcp-bitbucket && docker rm mcp-bitbucket # Stop and removeBenefits of HTTP/SSE Transport
Single container — one long-running container handles all requests
Multiple connections — clients can connect/reconnect without spawning new containers
Better performance — no container startup overhead per request
Easier debugging — view logs with
docker logsHealth monitoring — built-in health checks (30s interval)
Resource limits — default 512MB memory limit, 128MB reserved
Multi-Project Setup
Run multiple containers with different Bitbucket credentials for separate projects:
Create project-specific env files:
cp .env.project1.example .env.project1
cp .env.project2.example .env.project2
# Edit each with the appropriate credentialsStart both containers:
docker compose -f docker-compose.project1.yml up -d
docker compose -f docker-compose.project2.yml up -dConfigure your AI client with both servers:
{
"mcpServers": {
"bitbucket-project1": {
"url": "http://localhost:9000/sse"
},
"bitbucket-project2": {
"url": "http://localhost:9001/sse"
}
}
}Manage individually:
docker compose -f docker-compose.project1.yml down # Stop project1
docker compose -f docker-compose.project2.yml logs -f # Logs for project2Tools Reference
All tools return MCP-compatible responses (text content with pretty-printed JSON, or raw text for diffs/logs). Errors are returned as structured ERROR: <ExceptionType>: <message> text.
Health (1 tool)
Tool | Description |
| Validates configuration and Bitbucket connectivity. Checks credentials and workspace access. |
Repositories (2 tools)
Tool | Description |
| List repositories in a workspace. Filter by name (contains match) and limit results (1–100). |
| Get full repository details by workspace and repo slug. |
Pull Requests (17 tools)
Tool | Description |
| List PRs for a repository. Filter by state ( |
| Create a PR with title, description, source/target branches, optional reviewers. Supports |
| Get a single PR by ID. |
| Update PR title and/or description. |
| List activity feed (comments, approvals, status changes) for a PR. |
| Approve a PR as the current user. |
| Remove your approval from a PR. |
| Decline (close) a PR with an optional message. |
| Merge a PR with optional commit message and merge strategy ( |
| List all comments on a PR. |
| List commits included in a PR. |
| Get the unified diff for a PR (raw text). |
| Add a comment to a PR. Supports inline file/line comments and pending (draft) comments. |
| Add a pending (unpublished) comment to a PR. Shorthand for |
| Publish all pending comments on a PR. |
| Create a draft PR (shorthand for |
| Publish a draft PR (convert to ready for review). |
| Convert an open PR back to draft. |
| List PRs awaiting your review across all (or specified) repositories in a workspace. Requires |
Branching Models (7 tools)
Tool | Description |
| Get the repository-level branching model (effective settings). |
| Get raw repository branching model settings (may inherit from project). |
| Update repository branching model: development/production branches and branch types. |
| Resolve the effective branching model taking project-level inheritance into account. |
| Get project-level branching model (defaults for repositories). |
| Get raw project branching model settings. |
| Update project branching model: development/production branches and branch types. |
Pipelines (8 tools)
Tool | Description |
| List pipeline runs. Filter by status ( |
| Get details for a specific pipeline run by UUID. |
| Trigger a pipeline run for a target branch/commit with optional pipeline variables. |
| Stop a running pipeline by UUID. |
| List all steps for a pipeline run. |
| Get details for a specific pipeline step. |
| Get raw logs for a pipeline step (plain text). |
Use with AI Clients
Cursor (Docker — Recommended)
See Docker Usage above. Configure ~/.cursor/mcp.json:
{
"mcpServers": {
"bitbucket": {
"url": "http://localhost:9000/sse"
}
}
}Cursor / Claude Code (Direct UV — Development)
If the client runs inside the same environment (e.g., Ubuntu/WSL2), use an absolute path to uv:
{
"mcpServers": {
"bitbucket": {
"command": "/home/<user>/.local/bin/uv",
"args": ["run", "--with-editable", "/path/to/mcp-bitbucket", "mcp-bitbucket"],
"env": {
"BITBUCKET_URL": "https://api.bitbucket.org/2.0",
"BITBUCKET_USERNAME": "your_username",
"BITBUCKET_PASSWORD": "your_app_password",
"BITBUCKET_WORKSPACE": "your_workspace",
"FASTMCP_LOG_LEVEL": "DEBUG"
}
}
}
}Cursor on Windows (WSL Bridge)
If Cursor runs on Windows (outside WSL), bridge to WSL:
{
"mcpServers": {
"bitbucket": {
"command": "wsl",
"args": [
"bash", "-lc",
"cd /home/<user>/projects/mcp/mcp-bitbucket && BITBUCKET_USERNAME='your_username' BITBUCKET_PASSWORD='your_app_password' BITBUCKET_WORKSPACE='your_workspace' /home/<user>/.local/bin/uv run mcp-bitbucket"
]
}
}
}Debug with MCP Inspector
Launch the MCP Inspector to interactively test tools:
BITBUCKET_USERNAME='<user>' \
BITBUCKET_PASSWORD='<app_password>' \
BITBUCKET_WORKSPACE='<workspace>' \
uv run --with mcp mcp dev src/app.py --with-editable .Open the printed URL and call tools like health and listRepositories.
Architecture
mcp-bitbucket/
├── src/
│ ├── cli.py # CLI entry point (argparse, transport selection)
│ ├── app.py # FastMCP instance for MCP Inspector / dev
│ ├── server.py # BitbucketMcpServer: tool registry + MCP handlers
│ ├── bitbucket_client.py # BitbucketClient: thin httpx wrapper over REST v2.0
│ └── config.py # BitbucketConfig dataclass + env loader
├── Dockerfile # Python 3.10-slim, non-root user, SSE default
├── docker-compose.yml # Default single-instance compose
├── docker-compose.project1.yml # Multi-project compose (port 9000)
├── docker-compose.project2.yml # Multi-project compose (port 9001)
├── .env.example # Template for environment variables
├── pyproject.toml # Project metadata and dependencies (hatchling)
└── LICENSE # MITKey Components
BitbucketConfig— Immutable dataclass holding API URL, credentials, and default workspace. Loaded from environment variables.BitbucketClient— Synchronous HTTP client (httpx) that maps 1:1 to Bitbucket REST API v2.0 endpoints. Supports both token and App Password authentication.BitbucketMcpServer— Registers all 35 tools with FastMCP, wraps each call in error handling (_safe), and manages both stdio and SSE transports.cli.py— Entry point that parses CLI arguments, initializes config and server, and runs the selected transport.
Troubleshooting
Problem | Solution |
No tools visible in client | Ensure the command starts in your environment (use absolute path to |
401/403 errors | Verify App Password scopes and workspace/repo access. |
Workspace missing errors | Set |
Inspector won't connect | Ensure proxy health at |
Container not starting | Check |
| Requires |
Security
Treat App Passwords and OAuth tokens as secrets. Never commit
.envfiles — they are in.gitignore.The Docker image runs as a non-root user (
mcp, UID 1000).Rotate credentials immediately if exposed.
The server does not store or log credentials.
License
MIT — Copyright (c) 2025 Nemanja Milenković
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/webboy/mcp-bitbucket'
If you have feedback or need assistance with the MCP directory API, please join our Discord server