A Model Context Protocol (MCP) server for integrating with Bitbucket Cloud and Server APIs. This MCP server enables AI assistants like Cursor to interact with your Bitbucket repositories, pull requests, and other resources.
This is a safe and responsible package — no DELETE operations are used, so there’s no risk of data loss. Every pull request is analyzed with CodeQL to ensure the code remains secure.
Checkout out the official npm package This server implements the Model Context Protocol standard to provide AI assistants with access to Bitbucket data and operations. It includes tools for:
- Listing and retrieving repositories
- Getting repository details
- Fetching pull requests
- And more...
The easiest way to use this MCP server is via NPX, which allows you to run it without installing it globally:
# Run with environment variables
BITBUCKET_URL="https://bitbucket.org/your-workspace" \
BITBUCKET_USERNAME="your-username" \
BITBUCKET_PASSWORD="your-app-password" \
npx -y bitbucket-mcp@latestAlternatively, you can install it globally or as part of your project:
# Install globally
npm install -g bitbucket-mcp
# Or install in your project
npm install bitbucket-mcpThen run it with:
# If installed globally
BITBUCKET_URL="https://bitbucket.org/your-workspace" \
BITBUCKET_USERNAME="your-username" \
BITBUCKET_PASSWORD="your-app-password" \
bitbucket-mcp
# If installed in your project
BITBUCKET_URL="https://bitbucket.org/your-workspace" \
BITBUCKET_USERNAME="your-username" \
BITBUCKET_PASSWORD="your-app-password" \
npx bitbucket-mcpConfigure the server using the following environment variables:
| Variable | Description | Required |
|---|---|---|
BITBUCKET_URL |
Bitbucket base URL (e.g., "https://bitbucket.org/your-workspace") | Yes |
BITBUCKET_USERNAME |
Your Bitbucket username | Yes* |
BITBUCKET_PASSWORD |
Your Bitbucket app password | Yes* |
BITBUCKET_TOKEN |
Your Bitbucket access token (alternative to username/password) | No |
BITBUCKET_WORKSPACE |
Default workspace to use when not specified | No |
* Either BITBUCKET_TOKEN or both BITBUCKET_USERNAME and BITBUCKET_PASSWORD must be provided.
- Log in to your Bitbucket account
- Go to Personal Settings > App Passwords
- Create a new app password with the following permissions:
- Repositories: Read
- Pull requests: Read, Write
- Pipelines: Read (required for pipeline operations)
- Copy the generated password and use it as the
BITBUCKET_PASSWORDenvironment variable
To integrate this MCP server with Cursor:
- Open Cursor
- Go to Settings > Extensions
- Click on "Model Context Protocol"
- Add a new MCP configuration:
"bitbucket": {
"command": "npx",
"env": {
"BITBUCKET_URL": "https://bitbucket.org/your-workspace",
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_PASSWORD": "your-app-password"
},
"args": ["-y", "bitbucket-mcp@latest"]
}- Save the configuration
- Use the "/bitbucket" command in Cursor to access Bitbucket repositories and pull requests
If you're developing locally and want to test your changes:
"bitbucket-local": {
"command": "node",
"env": {
"BITBUCKET_URL": "https://bitbucket.org/your-workspace",
"BITBUCKET_USERNAME": "your-username",
"BITBUCKET_PASSWORD": "your-app-password"
},
"args": ["/path/to/your/local/bitbucket-mcp/dist/index.js"]
}This MCP server provides tools for interacting with Bitbucket repositories and pull requests. Below is a comprehensive list of the available operations:
Lists repositories in a workspace.
Parameters:
workspace(optional): Bitbucket workspace namelimit(optional): Maximum number of repositories to return
Gets details for a specific repository.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slug
Gets pull requests for a repository.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugstate(optional): Pull request state (OPEN,MERGED,DECLINED,SUPERSEDED)limit(optional): Maximum number of pull requests to return
Creates a new pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugtitle: Pull request titledescription: Pull request descriptionsourceBranch: Source branch nametargetBranch: Target branch namereviewers(optional): List of reviewer usernamesdraft(optional): Whether to create the pull request as a draft
Gets details for a specific pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Updates a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID- Various optional update parameters (title, description, etc.)
Gets the activity log for a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Approves a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Removes an approval from a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Declines a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDmessage(optional): Reason for declining
Merges a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDmessage(optional): Merge commit messagestrategy(optional): Merge strategy (merge-commit,squash,fast-forward)
Requests changes on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Removes a change request from a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Creates a new draft pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugtitle: Pull request titledescription: Pull request descriptionsourceBranch: Source branch nametargetBranch: Target branch namereviewers(optional): List of reviewer usernames
Note: This is equivalent to calling createPullRequest with draft: true.
Publishes a draft pull request to make it ready for review.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Converts a regular pull request to draft status.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Lists comments on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Creates a comment on a pull request (general or inline).
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcontent: Comment content in markdown formatinline(optional): Inline comment information for commenting on specific lines
Inline Comment Format:
The inline parameter allows you to create comments on specific lines of code in the pull request diff:
{
"path": "src/file.ts",
"to": 15, // Line number in NEW version (for added/modified lines)
"from": 10 // Line number in OLD version (for deleted/modified lines)
}Examples:
- General comment: Omit the
inlineparameter for a general pull request comment - Comment on new line: Use only
toparameter - Comment on deleted line: Use only
fromparameter - Comment on modified line: Use both
fromandtoparameters
Usage:
// General comment
addPullRequestComment(workspace, repo, pr_id, "Great work!")
// Inline comment on new line 25
addPullRequestComment(workspace, repo, pr_id, "Consider error handling here", {
path: "src/service.ts",
to: 25
})Gets a specific comment on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcomment_id: Comment ID
Updates a comment on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcomment_id: Comment IDcontent: Updated comment content
Deletes a comment on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcomment_id: Comment ID
Resolves a comment thread on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcomment_id: Comment ID
Reopens a resolved comment thread on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcomment_id: Comment ID
Gets the diff for a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Gets the diff statistics for a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Gets the patch for a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Lists tasks on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Creates a task on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDcontent: Task contentcomment(optional): Comment ID to associate with the taskpending(optional): Whether the task is pending
Gets a specific task on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDtask_id: Task ID
Updates a task on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDtask_id: Task IDcontent(optional): Updated task contentstate(optional): Updated task state
Deletes a task on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request IDtask_id: Task ID
Lists commits on a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Lists commit statuses for a pull request.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpull_request_id: Pull request ID
Lists pipeline runs for a repository.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository sluglimit(optional): Maximum number of pipelines to returnstatus(optional): Filter pipelines by status (PENDING,IN_PROGRESS,SUCCESSFUL,FAILED,ERROR,STOPPED)target_branch(optional): Filter pipelines by target branchtrigger_type(optional): Filter pipelines by trigger type (manual,push,pullrequest,schedule)
Gets details for a specific pipeline run.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpipeline_uuid: Pipeline UUID
Triggers a new pipeline run.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugtarget: Pipeline target configuration (object withref_type,ref_name, and optionalcommit_hash,selector_type,selector_pattern)variables(optional): Array of pipeline variables (objects withkey,value, and optionalsecuredfields)
Stops a running pipeline.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpipeline_uuid: Pipeline UUID
Lists steps for a pipeline run.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpipeline_uuid: Pipeline UUID
Gets details for a specific pipeline step.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpipeline_uuid: Pipeline UUIDstep_uuid: Step UUID
Gets logs for a specific pipeline step.
Parameters:
workspace: Bitbucket workspace namerepo_slug: Repository slugpipeline_uuid: Pipeline UUIDstep_uuid: Step UUID
- Node.js 18 or higher
- npm or yarn
# Clone the repository
git clone https://github.com/MatanYemini/bitbucket-mcp.git
cd bitbucket-mcp
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run devThis project is licensed under the MIT License - see the LICENSE file for details.