Bitbucket云MCP服务器

一个为Bitbucket Cloud REST API v2.0设计的模型上下文协议(MCP)服务器,支持多种MCP客户端,提供32种工具和5个工具集,具有安全控制和优化的LLM输出。

  • by or2ooo
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 or2ooo/bitbucket-mcp

使用说明

比特桶云MCP服务器

Bitbucket Cloud REST API v2.0的模型上下文协议(MCP)服务器。适用于任何MCP客户端——Claude Code、GitHub Copilot、OpenAI Codex等。提供5个工具组中的32个工具,具有安全控制和紧凑的LLM优化输出。

设置

先决条件

  • Node.js v24+
  • Atlassian API令牌(见下文)

创建API令牌

  1. 首选 大西洋API代币
  2. 点击 “创建具有作用域的API令牌”
  3. 命名令牌(例如“Bitbucket MCP”)并设置过期时间
  4. 选择应用程序: 比特桶
  5. 启用下面列出的范围
  6. 点击 创建 并复制令牌

只读范围 (6个范围——使用时足够 BITBUCKET_READONLY=true):

作用域 启用
read:user:bitbucket bb_whoami
read:workspace:bitbucket bb_list_workspaces
read:repository:bitbucket bb_list_repositories, bb_get_repository, bb_list_branches, bb_list_commits, bb_get_file, bb_list_directory, bb_search_code
read:pullrequest:bitbucket bb_list_pull_requests, bb_get_pull_request, bb_get_pull_request_diff, bb_get_pull_request_diffstat, bb_list_pull_request_activity
read:issue:bitbucket bb_list_issues, bb_get_issue
read:pipeline:bitbucket bb_list_pipelines, bb_get_pipeline

写入范围 (添加这4个以获得完全访问权限):

作用域 启用
write:repository:bitbucket bb_create_commit_files, bb_create_branch, bb_delete_branch
write:pullrequest:bitbucket bb_create_pull_request, bb_update_pull_request, bb_add_pull_request_comment, bb_approve_pull_request, bb_request_changes_pull_request, bb_merge_pull_request, bb_decline_pull_request
write:issue:bitbucket bb_create_issue, bb_comment_issue
write:pipeline:bitbucket bb_trigger_pipeline

添加到您的MCP客户端

Claude Code

一个命令——不需要克隆或构建:

claude mcp add bitbucket \
  -e ATLASSIAN_USER_EMAIL=your-email@example.com \
  -e ATLASSIAN_API_TOKEN=your-api-token \
  -e BITBUCKET_READONLY=false \
  -- npx -y @or2ooo/bitbucket-mcp@latest

通过以下方式进行验证:

claude mcp list
GitHub Copilot (VS Code)

增添 .vscode/mcp.json 在项目根目录中:

{
  "servers": {
    "bitbucket": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@or2ooo/bitbucket-mcp@latest"],
      "env": {
        "ATLASSIAN_USER_EMAIL": "your-email@example.com",
        "ATLASSIAN_API_TOKEN": "your-api-token",
        "BITBUCKET_READONLY": "false"
      }
    }
  }
}
OpenAI Codex CLI

增添 ~/.codex/config.toml:

[mcp_servers.bitbucket]
command = "npx"
args = ["-y", "@or2ooo/bitbucket-mcp@latest"]
env = { ATLASSIAN_USER_EMAIL = "your-email@example.com", ATLASSIAN_API_TOKEN = "your-api-token", BITBUCKET_READONLY = "false" }
From source (for development)
git clone https://github.com/or2ooo/bitbucket-mcp.git
cd bitbucket-mcp
npm install && npm run build

claude mcp add bitbucket \
  -e ATLASSIAN_USER_EMAIL=your-email@example.com \
  -e ATLASSIAN_API_TOKEN=your-api-token \
  -e BITBUCKET_READONLY=true \
  -- node $(pwd)/dist/index.js

环境变量

变量 必填 描述
ATLASSIAN_USER_EMAIL 是 Atlassian帐户电子邮件
ATLASSIAN_API_TOKEN 是 Atlassian API令牌(请参阅 创建API令牌)
BITBUCKET_DEFAULT_WORKSPACE 否 默认工作区段塞
BITBUCKET_ALLOWED_WORKSPACES 否 逗号分隔的工作区蛞蝓列表
BITBUCKET_ALLOWED_REPOS 否 逗号分隔的满列表(slug 或 workspace/slug)
BITBUCKET_READONLY 没有 true 阻止所有写入操作
BITBUCKET_BASE_URL 否 覆盖API基础URL

安全控制

  • 只读模式:设置 BITBUCKET_READONLY=true 以防止任何写入操作。
  • 工作区列表:限制对特定工作区的访问。
  • 存储库分配列表:限制对特定存储库的访问。
  • 破坏性行动确认:合并PR、拒绝PR和删除分支工具需要明确 confirm: true.

工具参考

上下文(2个工具)

工具 说明
bb_whoami 获取当前经过身份验证的用户
bb_list_workspaces 列出可访问的工作区

存储库(10个工具)

工具 说明
bb_list_repositories 列出工作区中的存储库
bb_get_repository 获取存储库详细信息
bb_list_branches 列出分支
bb_list_commits 列表提交(可选用于分支/标签)
bb_get_file 获取特定版本的文件内容
bb_create_commit_files 创建带有文件更改的提交(写入)
bb_create_branch 创建新分支(写入)
bb_delete_branch 删除分支(破坏性,需要确认)
bb_list_directory 列出特定版本的目录内容
bb_search_code 在工作区或存储库中搜索代码

拉取请求(12个工具)

工具 说明
bb_list_pull_requests 列出带有可选状态过滤器的PR
bb_get_pull_request 获取PR详细信息
bb_create_pull_request 创建新的PR(编写)
bb_update_pull_request 更新PR标题、描述或审阅者(撰写)
bb_get_pull_request_diff 获取PR差异(原始文本)
bb_get_pull_request_diffstat 获取PR差异统计摘要
bb_list_pull_request_activity 列出公关活动(评论、批准、更新)
bb_add_pull_request_comment 在PR中添加评论(写)
bb_approve_pull_request 批准PR(写)
bb_request_changes_pull_request 请求更改PR(写入)
bb_merge_pull_request 合并PR(破坏性,需要确认)
bb_decline_pull_request 拒绝PR(破坏性,需要确认)

问题(4个工具)

工具 说明
bb_list_issues 使用可选查询列出问题
bb_get_issue 获取问题详细信息
bb_create_issue 创建新问题(写)
bb_comment_issue 为问题添加评论(写)

管道(3个工具)

工具 说明
bb_list_pipelines 列出最近的管道
bb_get_pipeline 获取管道详细信息
bb_trigger_pipeline 触发管道运行(写入)

发展

npm test         # Run tests
npm run lint     # Lint
npm run build    # Compile

贡献

看 贡献.md 用于开发设置和指南。

安全

看 安全.md 用于报告漏洞。

许可证

麻省理工学院