使用说明
比特桶MCP
A. 模型上下文协议(MCP) Bitbucket云服务器。使AI助手能够管理存储库、拉取请求、管道等。
安装
选项1:使用npx(推荐)
无需安装。直接运行:
npx @icy-r/bitbucket-mcp
选项2:全局安装
npm install -g @icy-r/bitbucket-mcp
bitbucket-mcp
方案3:地方发展
git clone https://github.com/icy-r/bitbucket-mcp.git
cd bitbucket-mcp
pnpm install
pnpm build
node dist/index.js
MCP客户端配置
光标IDE
添加到光标MCP设置(~/.cursor/mcp.json 在Windows上: %USERPROFILE%\.cursor\mcp.json):
使用npx(推荐):
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["-y", "@icy-r/bitbucket-mcp"],
"env": {
"BITBUCKET_AUTH_METHOD": "api_token",
"BITBUCKET_USER_EMAIL": "your.email@example.com",
"BITBUCKET_API_TOKEN": "your_api_token"
}
}
}
}
使用本地构建:
{
"mcpServers": {
"bitbucket": {
"command": "node",
"args": ["D:\\path\\to\\bitbucket-mcp\\dist\\index.js"],
"env": {
"BITBUCKET_AUTH_METHOD": "api_token",
"BITBUCKET_USER_EMAIL": "your.email@example.com",
"BITBUCKET_API_TOKEN": "your_api_token"
}
}
}
}
克劳德桌面版
添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上, %APPDATA%\Claude\claude_desktop_config.json 在Windows上):
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["-y", "@icy-r/bitbucket-mcp"],
"env": {
"BITBUCKET_AUTH_METHOD": "api_token",
"BITBUCKET_USER_EMAIL": "your.email@example.com",
"BITBUCKET_API_TOKEN": "your_api_token"
}
}
}
}
其他MCP客户端
服务器遵循MCP标准,可与任何兼容的客户端配合使用。使用上面的配置模式,根据平台的需要调整路径。
认证
API代币(推荐)
- 首选 比特桶API代币
- 创建具有所需权限的新令牌
- 设置环境变量:
BITBUCKET_AUTH_METHOD=api_token
BITBUCKET_USER_EMAIL=your.email@example.com
BITBUCKET_API_TOKEN=your_api_token
应用程序密码
- 首选 Bitbucket应用程序密码
- 创建具有所需权限的新应用密码
- 使用
basic使用用户名和应用程序密码的auth方法
环境变量
| 变量 | 描述 | 必填 |
|---|---|---|
BITBUCKET_AUTH_METHOD |
api_token, oauth, basic |
是的 |
BITBUCKET_USER_EMAIL |
您的Atlassian电子邮件 | 关于api_token |
BITBUCKET_API_TOKEN |
API令牌 | 用于API_token |
BITBUCKET_USERNAME |
Bitbucket用户名 | 用于基本身份验证 |
BITBUCKET_APP_PASSWORD |
应用程序密码 | 用于基本身份验证 |
BITBUCKET_WORKSPACE |
默认工作区(当工具调用省略时使用 workspace) |
没有 |
BITBUCKET_OUTPUT_FORMAT |
json, toon, compact |
没有 |
可用工具
| 工具 | 操作 |
|---|---|
bitbucket_workspaces |
list、get、list_projects、list_members |
bitbucket_repositories |
list、get、create、delete、fork、get_file、list_source |
bitbucket_pull_requests |
列表、获取、创建、更新、合并、批准、取消批准、拒绝、list_comments、add_comment、get_diff |
bitbucket_branches |
list_brances、get_branch、create_branch、delete_brance、list_tags、get_tag、create_tag |
bitbucket_commits |
列表、获取、get_diff、get_diffstat |
bitbucket_pipelines |
list、get、trigger_custom、stop、list_steps、get_step、get_log、get_config、set_enabled、list_variables、get_variable、create_variable、update_variable和delete_variable |
bitbucket_issues |
list、get、create、update、delete、list_comments、add_comment、vote、unvote、watch、unwatch |
bitbucket_webhooks |
列表、获取、创建、更新、删除、list_workspace、get_workspace、创建workspace、更新workspace、删除workspace |
输出格式
控制响应的冗长程度 format 参数:
| 格式 | 描述 | 代币节省 |
|---|---|---|
json |
完整JSON输出 | 0% |
toon |
紧凑型TOON格式 | ~50% |
compact |
仅基本字段 | ~76% |
示例用法:
{ "action": "list", "workspace": "my-workspace", "format": "compact" }
示例
列出工作区中的存储库
{
"action": "list",
"workspace": "my-workspace"
}
创建pull请求
{
"action": "create",
"workspace": "my-workspace",
"repo_slug": "my-repo",
"title": "Feature: Add new functionality",
"source_branch": "feature/new-feature",
"destination_branch": "main"
}
触发管道
{
"action": "trigger",
"workspace": "my-workspace",
"repo_slug": "my-repo",
"branch_name": "main"
}
工作空间
集 BITBUCKET_WORKSPACE 在您的环境中跳过 workspace 每次工具调用时的参数:
{ "action": "list", "repo_slug": "my-repo" }
发展
# Clone the repository
git clone https://github.com/icy-r/bitbucket-mcp.git
cd bitbucket-mcp
# Install dependencies
pnpm install
# Build
pnpm build
# Run tests
pnpm test
# Run in development mode (watch)
pnpm dev
# Lint and format
pnpm lint
pnpm format
需求
- Node.js>=20.0.0
- pnpm(用于开发)
许可证
麻省理工学院
