Bitbucket 仓库管理与 Pull Request 操作 MCP 服务

一个通过 Model Context Protocol 与 Bitbucket REST API 集成的服务,支持代码仓库浏览、文件读取、Pull Request 全流程管理以及提交记录查询,适用于在 AI 开发环境中操作 Bitbucket 工作流。

  • by atayahmet
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 atayahmet/bitbucket-mcp

使用说明

Bitbucket MCP Server

A Model Context Protocol (MCP) server that works with the Bitbucket REST API. Designed to communicate over stdio inside a Docker container.

Setup

1. Build the Docker Image

docker build -t bitbucket-mcp .

2. Create a Bitbucket API Token

The MCP server uses a Bitbucket App Password for authentication. To create a token:

  1. Log in to your Bitbucket account
  2. Go to Settings: https://bitbucket.org/account/settings/
  3. Click App passwords in the left menu (https://bitbucket.org/account/settings/app-passwords/)
  4. Click the Create app password button
  5. Enter a label (e.g. bitbucket-mcp)
  6. Select the required permissions:
    • Repositories: Read
    • Pull requests: Read, Write
  7. Click Create and copy the generated token

Note: The token is only shown once. If you lose it, you will need to create a new one.

3. Configuration via MCP Settings

Credentials are passed through the env field in MCP settings. No separate .env file is needed.

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "bitbucket": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "bitbucket-mcp"],
      "env": {
        "BITBUCKET_EMAIL": "your-email@example.com",
        "BITBUCKET_TOKEN": "your-bitbucket-token"
      }
    }
  }
}

Claude Code

Adding via CLI (claude mcp add)

To add globally (all projects):

claude mcp add bitbucket \
  -s user \
  -e BITBUCKET_EMAIL=your-email@example.com \
  -e BITBUCKET_TOKEN=your-bitbucket-token \
  -- docker run -i --rm -e BITBUCKET_EMAIL -e BITBUCKET_TOKEN bitbucket-mcp

To add for the current project only:

claude mcp add bitbucket \
  -s project \
  -e BITBUCKET_EMAIL=your-email@example.com \
  -e BITBUCKET_TOKEN=your-bitbucket-token \
  -- docker run -i --rm -e BITBUCKET_EMAIL -e BITBUCKET_TOKEN bitbucket-mcp
JSON configuration

~/.claude/settings.json (global) or project .claude/settings.json:

{
  "mcpServers": {
    "bitbucket": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "BITBUCKET_EMAIL",
        "-e",
        "BITBUCKET_TOKEN",
        "bitbucket-mcp"
      ],
      "env": {
        "BITBUCKET_EMAIL": "your-email@example.com",
        "BITBUCKET_TOKEN": "your-bitbucket-token"
      }
    }
  }
}

Without Docker (Direct Node.js)

{
  "mcpServers": {
    "bitbucket": {
      "command": "node",
      "args": ["/path/to/bitbucket-mcp/dist/index.js"],
      "env": {
        "BITBUCKET_EMAIL": "your-email@example.com",
        "BITBUCKET_TOKEN": "your-bitbucket-token"
      }
    }
  }
}

Development

  • npm install: Install dependencies.
  • npm run build: Create a bundle with Vite.
  • npm run dev: Build in watch mode.

Tools

Repository

Tool Description
list_repositories List repositories in a workspace
get_repository Get details of a specific repository

File & Directory

Tool Description
list_directory List contents of a directory in a repository
get_file_content Read the content of a file

Pull Request

Tool Description
create_pull_request Create a new pull request
update_pull_request Update pull request details (title, description, reviewers, destination branch)
list_pull_requests List a summary of pull requests in a repository (OPEN, MERGED, DECLINED, SUPERSEDED), up to limit (default 20)
get_pull_request Get details of a specific pull request
get_pull_request_diff Get the raw diff of the changes a pull request makes
get_pull_request_diffstat Get a summary of changed files in a pull request (lines added/removed)
list_pull_request_commits List the commits of a pull request
get_pull_request_activity Get a pull request's timeline: updates, approvals, change requests and comments
list_pull_request_comments List all comments on a pull request (every page)
add_pull_request_comment Add a general or inline comment (one line or a range, on the new or old side), or a threaded reply (parent_id) (Markdown)
update_pull_request_comment Edit the text of a pull request comment
delete_pull_request_comment Delete a pull request comment
resolve_pull_request_comment Resolve a comment thread, or reopen it with resolved: false
react_to_pull_request_comment Add a reaction (e.g. thumbsup) to a pull request comment
remove_reaction_from_pull_request_comment Remove a reaction from a pull request comment
list_pull_request_tasks List the tasks on a pull request
create_pull_request_task Create a task, attached to a comment (comment_id) or to the pull request
update_pull_request_task Edit a task's text, or resolve or reopen it (state)
delete_pull_request_task Delete a pull request task
approve_pull_request Approve a pull request
unapprove_pull_request Remove approval from a pull request
request_changes_on_pull_request Request changes on a pull request
remove_request_changes_on_pull_request Withdraw your change request on a pull request
merge_pull_request Merge a pull request (merge_commit, squash, fast_forward)
decline_pull_request Decline a pull request

Commit

Tool Description
list_commits List commits in a branch