Bitbucket MCP server

Integrates with Bitbucket's API to streamline pull request workflows, enabling efficient code reviews and automated PR management.
Back to servers
Provider
garc33
Release date
Jan 20, 2025
Language
TypeScript
Stats
7 stars

The Bitbucket Server MCP server enables interaction with Bitbucket Server's Pull Request management features through the Model Context Protocol. This server provides tools to create, retrieve, merge, and comment on pull requests via a standardized interface.

Requirements

  • Node.js 16 or higher

Installation Options

Via Smithery (Recommended)

Install the Bitbucket Server MCP server automatically with Smithery:

npx -y @smithery/cli install @garc33/bitbucket-server-mcp-server --client claude

Manual Installation

For manual installation:

npm install
npm run build

Configuration

The server requires configuration in the VSCode MCP settings file:

{
  "mcpServers": {
    "bitbucket": {
      "command": "node",
      "args": ["/path/to/bitbucket-server/build/index.js"],
      "env": {
        "BITBUCKET_URL": "https://your-bitbucket-server.com",
        
        // Authentication (choose one option):
        // Option 1: Personal Access Token
        "BITBUCKET_TOKEN": "your-access-token",
        
        // Option 2: Username/Password
        "BITBUCKET_USERNAME": "your-username",
        "BITBUCKET_PASSWORD": "your-password",
        
        // Optional: Default project
        "BITBUCKET_DEFAULT_PROJECT": "your-default-project"
      }
    }
  }
}

Required Environment Variables

  • BITBUCKET_URL: Base URL of your Bitbucket Server instance
  • Authentication (one required):
    • BITBUCKET_TOKEN: Personal access token
    • BITBUCKET_USERNAME and BITBUCKET_PASSWORD: Basic authentication credentials
  • Optional:
    • BITBUCKET_DEFAULT_PROJECT: Default project key to use when not specified in requests

Available Tools

Creating Pull Requests

Create a new pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug", // Required
  "title": "My new feature",  // Required
  "description": "This PR implements...",
  "sourceBranch": "feature/my-feature",  // Required
  "targetBranch": "main",  // Required
  "reviewers": ["user1", "user2"]  // Optional
}

Getting Pull Request Details

Retrieve information about a specific pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug",  // Required
  "prId": 123  // Required
}

Merging Pull Requests

Merge an existing pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug",  // Required
  "prId": 123,  // Required
  "message": "Merging feature X",  // Optional
  "strategy": "merge-commit"  // Optional, defaults to "merge-commit"
}

Available merge strategies:

  • merge-commit (default)
  • squash
  • fast-forward

Declining Pull Requests

Decline a pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug",  // Required
  "prId": 123,  // Required
  "message": "Not needed anymore"  // Optional
}

Adding Comments

Add a comment to a pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug",  // Required
  "prId": 123,  // Required
  "text": "Please fix the failing tests",  // Required
  "parentId": 456  // Optional, for replies
}

Getting Diffs

Retrieve the diff for a pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug",  // Required
  "prId": 123,  // Required
  "contextLines": 5  // Optional, defaults to 10
}

Fetching Reviews

Get review history of a pull request:

{
  "project": "PROJECT_KEY",  // Optional if BITBUCKET_DEFAULT_PROJECT is set
  "repository": "repo-slug",  // Required
  "prId": 123  // Required
}

Logging

The server logs all operations to bitbucket.log for debugging purposes.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later