使用说明
比特桶服务器MCP
Atlassian Bitbucket服务器/数据中心(企业)的MCP(模型上下文协议)服务器。提供66种用于读写项目、存储库、分支、文件、提交、拉取请求和代码搜索的工具,包括 选择加入门控删除操作 (默认情况下禁用,请参见 安全.md.
安装
来自PyPI(推荐)
pip install bitbucket-server-mcp
或与 紫外线:
uv pip install bitbucket-server-mcp
来源
git clone https://github.com/ManpreetShuann/bitbucket-server-mcp.git
cd bitbucket-server-mcp
uv sync
通过Docker(不需要本地Python)
cd bitbucket-server-mcp
docker build -t bitbucket-server-mcp .
先决条件
- Python 3.10+
- 启用HTTP访问令牌的Bitbucket服务器7.x+
配置
设置两个必需的环境变量(加上可选变量):
| 变量 | 必填 | 描述 |
|---|---|---|
BITBUCKET_URL |
是 | 您的Bitbucket服务器的基本URL(例如。, https://bitbucket.yourcompany.com).必须使用HTTPS。 |
BITBUCKET_TOKEN |
是 | HTTP访问令牌(在Bitbucket>用户设置>HTTP访问令牌中创建) |
BITBUCKET_LOG_LEVEL |
否 | stderr输出的日志级别: DEBUG, INFO, WARNING, ERROR (默认值: INFO) |
BITBUCKET_ALLOW_DANGEROUS_DELETE |
否 | 设置为 1 启用一级删除工具(分支、标记、PR、注释、任务、附件) |
BITBUCKET_ALLOW_DESTRUCTIVE_DELETE |
否 | 设置为 1 启用二级删除工具(项目、存储库)。需要 BITBUCKET_ALLOW_DANGEROUS_DELETE=1 |
整合
此服务器通过stdio在本地运行,而不是作为托管HTTP服务运行。本地运行可将Bitbucket访问令牌保留在您自己的计算机上,避免在网络上暴露经过身份验证的API端点,并消除管理服务器基础设施或TLS证书的需要。
克劳德代码
添加 ~/.claude.json 或项目 .claude/settings.json:
With pip (recommended)
pip install bitbucket-server-mcp
{
"mcpServers": {
"bitbucket": {
"command": "bitbucket-server-mcp",
"env": {
"BITBUCKET_URL": "https://bitbucket.yourcompany.com",
"BITBUCKET_TOKEN": "your-token-here"
}
}
}
}
With Docker
{
"mcpServers": {
"bitbucket": {
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "BITBUCKET_URL", "-e", "BITBUCKET_TOKEN", "bitbucket-server-mcp"],
"env": {
"BITBUCKET_URL": "https://bitbucket.yourcompany.com",
"BITBUCKET_TOKEN": "your-token-here"
}
}
}
}
With uv (from source, for development)
git clone https://github.com/ManpreetShuann/bitbucket-server-mcp.git
cd bitbucket-server-mcp
uv sync
{
"mcpServers": {
"bitbucket": {
"command": "uv",
"args": ["run", "--directory", "/path/to/bitbucket-server-mcp", "bitbucket-server-mcp"],
"env": {
"BITBUCKET_URL": "https://bitbucket.yourcompany.com",
"BITBUCKET_TOKEN": "your-token-here"
}
}
}
}
GitHub副本(VS代码)
添加 .vscode/mcp.json 在您的工作空间中:
With pip (recommended)
pip install bitbucket-server-mcp
{
"servers": {
"bitbucket": {
"type": "stdio",
"command": "bitbucket-server-mcp",
"env": {
"BITBUCKET_URL": "https://bitbucket.yourcompany.com",
"BITBUCKET_TOKEN": "${input:bitbucket-token}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "bitbucket-token",
"description": "Bitbucket Server HTTP access token",
"password": true
}
]
}
With Docker
{
"servers": {
"bitbucket": {
"type": "stdio",
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "BITBUCKET_URL", "-e", "BITBUCKET_TOKEN", "bitbucket-server-mcp"],
"env": {
"BITBUCKET_URL": "https://bitbucket.yourcompany.com",
"BITBUCKET_TOKEN": "${input:bitbucket-token}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "bitbucket-token",
"description": "Bitbucket Server HTTP access token",
"password": true
}
]
}
With uv (from source, for development)
git clone https://github.com/ManpreetShuann/bitbucket-server-mcp.git
cd bitbucket-server-mcp
uv sync
{
"servers": {
"bitbucket": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/path/to/bitbucket-server-mcp", "bitbucket-server-mcp"],
"env": {
"BITBUCKET_URL": "https://bitbucket.yourcompany.com",
"BITBUCKET_TOKEN": "${input:bitbucket-token}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "bitbucket-token",
"description": "Bitbucket Server HTTP access token",
"password": true
}
]
}
OpenAI 代码专家
添加 ~/.codex/config.toml:
With pip (recommended)
pip install bitbucket-server-mcp
[mcp_servers.bitbucket]
command = "bitbucket-server-mcp"
args = []
[mcp_servers.bitbucket.env]
BITBUCKET_URL = "https://bitbucket.yourcompany.com"
BITBUCKET_TOKEN = "your-token-here"
或者通过CLI:
codex mcp add bitbucket \
--env BITBUCKET_URL=https://bitbucket.yourcompany.com \
--env BITBUCKET_TOKEN=your-token-here \
-- bitbucket-server-mcp
With Docker
[mcp_servers.bitbucket]
command = "docker"
args = ["run", "--rm", "-i", "-e", "BITBUCKET_URL", "-e", "BITBUCKET_TOKEN", "bitbucket-server-mcp"]
[mcp_servers.bitbucket.env]
BITBUCKET_URL = "https://bitbucket.yourcompany.com"
BITBUCKET_TOKEN = "your-token-here"
或者通过CLI:
codex mcp add bitbucket \
--env BITBUCKET_URL=https://bitbucket.yourcompany.com \
--env BITBUCKET_TOKEN=your-token-here \
-- docker run --rm -i -e BITBUCKET_URL -e BITBUCKET_TOKEN bitbucket-server-mcp
With uv (from source, for development)
git clone https://github.com/ManpreetShuann/bitbucket-server-mcp.git
cd bitbucket-server-mcp
uv sync
[mcp_servers.bitbucket]
command = "uv"
args = ["run", "--directory", "/path/to/bitbucket-server-mcp", "bitbucket-server-mcp"]
[mcp_servers.bitbucket.env]
BITBUCKET_URL = "https://bitbucket.yourcompany.com"
BITBUCKET_TOKEN = "your-token-here"
或者通过CLI:
codex mcp add bitbucket \
--env BITBUCKET_URL=https://bitbucket.yourcompany.com \
--env BITBUCKET_TOKEN=your-token-here \
-- uv run --directory /path/to/bitbucket-server-mcp bitbucket-server-mcp
工具(共66个)
项目
| 工具 | 说明 |
|---|---|
list_projects |
列出所有项目(分页) |
get_project |
按键获取项目详细信息 |
仓库
| 工具 | 说明 |
|---|---|
list_repositories |
列出项目中的存储库(分页) |
get_repository |
获取回购详细信息 |
create_repository |
创建新仓库 |
分支和标签
| 工具 | 说明 |
|---|---|
list_branches |
列出分支(分页、可过滤) |
get_default_branch |
获取默认分支 |
create_branch |
从起点创建分支 |
list_tags |
列表标签(分页、可过滤) |
文件和内容
| 工具 | 说明 |
|---|---|
browse_files |
在路径和修订处浏览目录/文件树 |
get_file_content |
获取原始文件内容 |
list_files |
列出目录中的文件路径 |
提交
| 工具 | 说明 |
|---|---|
list_commits |
列表提交(分页,可按分支/路径过滤) |
get_commit |
获取提交详细信息 |
get_commit_diff |
获取提交的差异 |
get_commit_changes |
获取已更改的文件以进行提交 |
拉取请求
| 工具 | 说明 |
|---|---|
list_pull_requests |
列出带有状态/方向/草稿/标题/参与者过滤器的PR(分页) |
get_pull_request |
获取PR详细信息 |
create_pull_request |
与审阅者一起创建PR(支持草稿模式) |
update_pull_request |
更新PR标题/描述/审阅者/草稿状态 |
create_draft_pull_request |
在草稿模式下创建PR |
publish_draft_pull_request |
发布PR草案(标记为准备审查) |
convert_to_draft |
将打开的PR转换回草稿 |
can_merge_pull_request |
检查合并准备情况(可以合并、冲突、否决) |
merge_pull_request |
将PR与可选策略合并 |
decline_pull_request |
拒绝PR |
reopen_pull_request |
重新打开被拒绝的PR |
approve_pull_request |
批准PR |
unapprove_pull_request |
删除您的批准 |
request_changes_pull_request |
请求更改PR |
remove_change_request_pull_request |
删除您的更改请求 |
list_pull_request_participants |
列出具有角色和状态的审阅者 |
watch_pull_request |
以观察员身份订阅 |
unwatch_pull_request |
取消订阅观看 |
get_commit_message_suggestion |
获取合并的建议提交消息 |
get_pull_request_diff |
获取公关差异 |
get_pull_request_diff_stat |
获取每个文件的更改列表(添加/修改/删除) |
list_pull_request_commits |
PR中的列表提交 |
get_pull_request_activities |
获取公关活动订阅源 |
list_pull_request_comments |
列出对PR的评论 |
get_pull_request_comment |
获取具体评论 |
add_pull_request_comment |
添加评论(常规、内联、回复或阻止任务) |
update_pull_request_comment |
编辑评论 |
resolve_pull_request_comment |
解析评论线程 |
reopen_pull_request_comment |
重新打开已解决的线程 |
list_pull_request_tasks |
列出公关任务 |
create_pull_request_task |
创建任务(可选链接到评论) |
get_pull_request_task |
获取特定任务 |
update_pull_request_task |
更新任务内容或状态 |
仪表盘
| 工具 | 说明 |
|---|---|
list_dashboard_pull_requests |
列出所有存储库中经过身份验证的用户可见的PR(分页) |
list_inbox_pull_requests |
列出用户收件箱中需要审核操作的PR(分页) |
搜索
| 工具 | 说明 |
|---|---|
search_code |
跨仓库搜索代码(需要Elasticsearch) |
find_file |
按带通配符的名称或路径模式查找文件 |
用户
| 工具 | 说明 |
|---|---|
find_user |
按姓名、用户名或电子邮件搜索用户 |
附件
| 工具 | 说明 |
|---|---|
get_attachment |
按ID下载附件 |
get_attachment_metadata |
获取附件元数据 |
save_attachment_metadata |
创建或更新附件元数据 |
危险删除(一级,需要 BITBUCKET_ALLOW_DANGEROUS_DELETE=1)
| 工具 | 说明 |
|---|---|
delete_branch |
删除分支(不可逆) |
delete_tag |
删除标签(不可逆) |
delete_pull_request |
删除PR及其所有内容 |
delete_pull_request_comment |
删除PR评论 |
delete_pull_request_task |
删除PR任务 |
delete_attachment |
删除附件 |
delete_attachment_metadata |
删除附件元数据 |
破坏性删除(第2级,需要两者 BITBUCKET_ALLOW_DANGEROUS_DELETE=1 和 BITBUCKET_ALLOW_DESTRUCTIVE_DELETE=1)
| 工具 | 说明 |
|---|---|
delete_project |
删除项目及其所有存储库(不可逆) |
delete_repository |
删除存储库及其所有内容(不可逆) |
发展
git clone https://github.com/ManpreetShuann/bitbucket-server-mcp.git
cd bitbucket-server-mcp
uv sync # Install all dependencies (including dev)
uv run pytest -v # Run tests
uv run ruff check src/ tests/ # Lint
uv run ruff format src/ tests/ # Format
看 贡献.md 获取完整的开发指南。
分页
所有列表工具均接受 start (默认值0)和 limit (默认值为25)参数。回应包括 isLastPage 和 nextPageStart 用于获取后续页面。
安全
看 安全.md 了解我们的安全策略和漏洞报告说明。