The Bitbucket Cloud MCP Server provides comprehensive integration with Bitbucket Cloud through 32 specialized tools, enabling AI assistants to manage repositories, perform code reviews, execute CI/CD operations, and search code.
Core Capabilities:
Repository Management: List, view, create, and delete repositories; view forks; filter and sort by role or query; configure settings including privacy, wiki, issues, and project associations.
Pull Request Operations: Create, update, merge (with merge commit, squash, or fast-forward strategies), decline, approve, and request changes on pull requests; manage comments including inline comments on specific files and lines; view diffs; filter by state (OPEN, MERGED, DECLINED, SUPERSEDED); manage reviewers and close source branches after merge.
Branch Management: List, view, create, and delete branches; create branches from specific commits or existing branches; filter and sort with query strings.
Commit Operations: List commits with filtering by branch and include/exclude criteria; view commit details including message, author, and parent commits; retrieve commit diffs.
Issue Tracking: Create, read, update, and delete issues; set properties including type (bug, enhancement, proposal, task), priority, assignee, and state; filter and search with query strings and sorting.
CI/CD Pipeline Management: List and view pipeline runs with pagination; trigger new runs on branches, tags, or bookmarks; pass custom variables including secured variables; stop running pipelines.
Code Search & File Access: Search code across all repositories in a workspace; retrieve file contents from any repository, branch, tag, or commit; access files via MCP resources using URIs.
Authentication: Supports secure OAuth 2.0 with automatic token refresh and browser-based sign-in, as well as App Password authentication for simpler personal use; includes secure token persistence with automatic re-authentication.
Provides 25+ tools for comprehensive Bitbucket Cloud API access, including repository management, pull request operations, branch and commit handling, issue tracking, pipeline management, and code search across workspaces.
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., "@Bitbucket Cloud MCP Serverlist my recent pull requests in the backend-api repository"
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.
@lexmata/bitbucket-mcp
A Model Context Protocol (MCP) server for Bitbucket Cloud - 25+ tools for repositories, pull requests, branches, commits, issues, pipelines, and code search.
Features
Full Bitbucket Cloud API Coverage: Access repositories, pull requests, branches, commits, issues, pipelines, and code search
OAuth 2.0 Authentication: Secure authentication with automatic browser-based sign-in and token refresh
App Password Support: Alternative authentication using Bitbucket App Passwords
MCP Tools: 25+ tools for interacting with Bitbucket
MCP Resources: Access repositories, pull requests, and files as resources
TypeScript: Fully typed for reliability and developer experience
Installation
Configuration
Option 1: OAuth 2.0 (Recommended)
OAuth provides the best experience with automatic browser-based authentication and token refresh.
Step 1: Create an OAuth Consumer
Go to your Bitbucket workspace:
https://bitbucket.org/{workspace}/workspace/settings/oauth-consumersClick "Add consumer"
Fill in:
Name:
MCP Server(or any name)Callback URL:
http://localhost:9876/callback(required)Permissions: Select the following:
Account: Read
Repositories: Read, Write, Admin
Pull requests: Read, Write
Issues: Read, Write
Pipelines: Read, Write
Click Save and note the Key (Client ID) and Secret (Client Secret)
Step 2: Run the OAuth Flow
Use the included helper script to authenticate:
This will:
Start a local callback server on port 9876
Open your browser to Bitbucket's authorization page
After you authorize, display the configuration to add to your MCP config
Step 3: Configure Your MCP Client
Add the output configuration to your MCP client config file.
Option 2: App Password (Simple setup)
For personal use without OAuth setup:
Go to Bitbucket: Personal Settings → App passwords
Click Create app password
Give it a name and select permissions:
Account: Read
Repositories: Read, Write, Admin
Pull requests: Read, Write
Issues: Read, Write
Pipelines: Read, Write
Copy the generated password
Configure with your Bitbucket username and the app password:
Usage with Cursor IDE
Add the following to your Cursor MCP configuration file:
Linux: ~/.cursor/mcp.json
macOS: ~/.cursor/mcp.json
Windows: %USERPROFILE%\.cursor\mcp.json
With OAuth (Recommended)
When tokens expire, the server will automatically refresh them using the refresh token. If refresh fails, a browser window will open for re-authentication.
With App Password
Usage with Claude Desktop
Add the following to your Claude Desktop 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
Or if installed globally:
Environment Variables
Variable | Description | Required |
| OAuth consumer key | For OAuth |
| OAuth consumer secret | For OAuth |
| OAuth access token or App password | Yes |
| OAuth refresh token | For OAuth |
| Bitbucket username | For App Password |
Token Management
OAuth Tokens
Access tokens expire after 2 hours
Refresh tokens are used to automatically obtain new access tokens
Tokens are persisted to
~/.config/bitbucket-mcp/tokens.jsonIf tokens expire and refresh fails, the browser will automatically open for re-authentication
Re-authenticating
If you need to re-authenticate manually:
Or delete the token file to trigger re-authentication:
Available Tools
Repository Management
Tool | Description |
| List repositories in a workspace |
| Get details of a specific repository |
| Create a new repository |
| Delete a repository |
| List all forks of a repository |
Pull Requests
Tool | Description |
| List pull requests with optional filtering |
| Get details of a specific pull request |
| Create a new pull request |
| Update a pull request |
| Merge a pull request |
| Decline a pull request |
| Approve a pull request |
| Request changes on a pull request |
| List comments on a pull request |
| Add a comment to a pull request |
| Get the diff for a pull request |
Branches
Tool | Description |
| List branches in a repository |
| Get details of a specific branch |
| Create a new branch |
| Delete a branch |
Commits
Tool | Description |
| List commits with optional filtering |
| Get details of a specific commit |
| Get the diff for a commit |
Issues
Tool | Description |
| List issues in a repository |
| Get details of a specific issue |
| Create a new issue |
| Update an issue |
| Delete an issue |
Pipelines
Tool | Description |
| List pipeline runs |
| Get details of a pipeline run |
| Trigger a new pipeline run |
| Stop a running pipeline |
Code Search
Tool | Description |
| Search code across repositories |
Files
Tool | Description |
| Get the content of a file |
Resources
The server provides the following resource types:
Resource URI | Description |
| Repository information |
| Pull request details |
| File contents |
Examples
List repositories in a workspace
Create a pull request
Search for code
Trigger a pipeline
Development
Prerequisites
Node.js 18+
pnpm 9+
Setup
Scripts
Script | Description |
| Build the project with SWC |
| Run in development mode |
| Run the built server |
| Run TypeScript type checking |
| Run ESLint |
| Fix ESLint issues |
| Format code with Prettier |
| Check code formatting |
OAuth Flow Helper
The scripts/oauth-flow.js script provides a convenient way to authenticate:
This script:
Starts a local HTTP server on port 9876
Opens your browser to Bitbucket's authorization page
Handles the OAuth callback
Displays the complete MCP configuration with tokens
Troubleshooting
"Port 9876 is already in use"
Another process is using the OAuth callback port. Either:
Close the other application using port 9876
Wait a moment and try again (previous OAuth attempt may still be running)
"localhost:9876 returned not found"
The OAuth callback URL in your Bitbucket consumer is incorrect. Make sure it's set to:
"Token is invalid or expired"
Your access token has expired. The server will automatically:
Try to refresh using the refresh token
If that fails, open the browser for re-authentication
To manually re-authenticate:
"Authentication failed (401)"
Check that:
Your OAuth consumer has the correct permissions
Your app password (if using) has the required scopes
For app passwords, ensure
BITBUCKET_USERNAMEis set
Server not loading in Cursor
Verify your
~/.cursor/mcp.jsonsyntax is valid JSONRestart Cursor or reload the window
Check the MCP server logs for errors
License
MIT License - Copyright (c) 2025 Lexmata LLC
See LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request