使用说明
比特桶MCP服务器
用于Bitbucket云和服务器API的模型上下文协议(MCP)服务器,使用TypeScript和Node.js构建。为存储库管理、拉取请求、分支、提交和文件操作提供全面的工具。
特性
- 双重API支持 -Bitbucket Cloud API v2和服务器API v1.0(由基本URL自动检测)
- 25+MCP工具 -全面覆盖Bitbucket操作
- 灵活的配置 -环境变量或JSON配置文件
- 智能默认值 -自动检测当前分支以创建PR
- 结构化错误 -详细的错误响应和建议
- TypeScript -全型安全和现代ES模块
安装
使用npm(全局)
npm install -g @yogeshrathod/bitbucket-mcp
使用npx(无需安装)
npx @yogeshrathod/bitbucket-mcp
更新
更新全局安装
npm update -g @yogeshrathod/bitbucket-mcp
使用npx更新到最新版本
npx @yogeshrathod/bitbucket-mcp@latest
检查当前版本
npm list -g @yogeshrathod/bitbucket-mcp
配置
使用环境变量或JSON配置文件配置服务器。
环境变量
export ATLASSIAN_SITE_URL="bitbucket" # or your server URL
export ATLASSIAN_USER_EMAIL="your-email@example.com"
export ATLASSIAN_API_TOKEN="your-app-password-or-pat"
| 变量 | 描述 |
|---|---|
ATLASSIAN_SITE_URL |
bitbucket 用于云API或用于服务器的完整URL(例如。, https://bitbucket.company.com/rest/api/1.0) |
ATLASSIAN_USER_EMAIL |
您的Bitbucket帐户电子邮件 |
ATLASSIAN_API_TOKEN |
应用程序密码(云)或个人访问令牌(服务器) |
JSON配置文件
在您的工作目录中创建以下文件之一: mcp.config.json, .mcp.config.json,或 .bitbucket.mcp.json
{
"bitbucket": {
"defaultDestinationBranch": "main",
"environments": {
"ATLASSIAN_SITE_URL": "https://bitbucket.company.com/rest/api/1.0",
"ATLASSIAN_USER_EMAIL": "your-email@example.com",
"ATLASSIAN_API_TOKEN": "your-app-password",
"BITBUCKET_DEFAULT_DEST_BRANCH": "main"
}
}
}
MCP客户端配置
添加到您的MCP客户端配置中(例如,Claude Desktop、Windsurf):
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["@yogeshrathod/bitbucket-mcp"],
"env": {
"ATLASSIAN_SITE_URL": "bitbucket",
"ATLASSIAN_USER_EMAIL": "your-email@example.com",
"ATLASSIAN_API_TOKEN": "your-app-password"
}
}
}
}
工具参考
所有特定于存储库的工具都需要 workspace 和 repoSlug 参数。
连接与发现
| 工具 | 说明 | 参数 |
|---|---|---|
connection_test |
测试与Bitbucket API的连接 | - |
workspaces_list |
列出所有可访问的工作区 | - |
repos_list |
列出工作区中的存储库 | workspace |
repo_info |
获取存储库详细信息 | workspace, repoSlug |
拉取请求
| 工具 | 说明 | 参数 |
|---|---|---|
pr_list |
列出拉取请求 | workspace, repoSlug, state? (打开 |
pr_create |
创建pull请求 | workspace, repoSlug, title, sourceBranch?, destBranch?, description? |
pr_get |
获取PR详细信息 | workspace, repoSlug, prId |
pr_update |
更新PR标题/描述 | workspace, repoSlug, prId, title?, description? |
pr_diff |
获取公关差异 | workspace, repoSlug, prId |
pr_diff_file |
获取每个文件的PR差异(避免2MB限制) | workspace, repoSlug, prId, file_path, context_lines? (默认值3) |
pr_changes |
在PR中获取文件更改 | workspace, repoSlug, prId |
pr_approve |
批准PR | workspace, repoSlug, prId |
pr_decline |
拒绝/拒绝PR | workspace, repoSlug, prId |
pr_merge |
合并PR | workspace, repoSlug, prId, closeSourceBranch?, mergeStrategy?, message? |
pr_comment_add |
向PR添加评论 | workspace, repoSlug, prId, text |
pr_comments_list |
列出公关评论 | workspace, repoSlug, prId |
pr_reviewers_add |
将审阅者添加到PR | workspace, repoSlug, prId, reviewers (数组) |
pr_inline_comment_add |
在特定行添加内联注释 | workspace, repoSlug, prId, filePath, line, text, lineType? |
pr_task_add |
使用任务创建内联注释 | workspace, repoSlug, prId, file_path, line_number, line_type, comment_text, task_text? |
分支
| 工具 | 说明 | 参数 |
|---|---|---|
branches_list |
列出分支 | workspace, repoSlug |
branch_create |
创建分支 | workspace, repoSlug, name, targetHash |
branch_compare |
比较两个分支 | workspace, repoSlug, source, destination |
承诺
| 工具 | 说明 | 参数 |
|---|---|---|
commits_list |
列表提交 | workspace, repoSlug, spec? |
commit_get |
获取提交详细信息 | workspace, repoSlug, commitHash |
commit_diff |
获取提交差异 | workspace, repoSlug, commitHash |
文件
| 工具 | 说明 | 参数 |
|---|---|---|
file_content |
提交时获取文件内容 | workspace, repoSlug, filePath, commitHash |
使用示例
列出打开拉取请求
{
"tool": "pr_list",
"arguments": {
"workspace": "my-workspace",
"repoSlug": "my-repo",
"state": "OPEN"
}
}
创建拉取请求
{
"tool": "pr_create",
"arguments": {
"workspace": "my-workspace",
"repoSlug": "my-repo",
"title": "Add new feature",
"sourceBranch": "feature/my-feature",
"destBranch": "main",
"description": "This PR adds a new feature"
}
}
合并拉取请求
{
"tool": "pr_merge",
"arguments": {
"workspace": "my-workspace",
"repoSlug": "my-repo",
"prId": 123,
"mergeStrategy": "squash",
"closeSourceBranch": true
}
}
比较分支机构
{
"tool": "branch_compare",
"arguments": {
"workspace": "my-workspace",
"repoSlug": "my-repo",
"source": "feature/my-feature",
"destination": "main"
}
}
获取每个文件的PR差异
{
"tool": "pr_diff_file",
"arguments": {
"workspace": "my-workspace",
"repoSlug": "my-repo",
"prId": 123,
"file_path": "src/components/App.tsx",
"context_lines": 5
}
}
使用任务创建内联注释
{
"tool": "pr_task_add",
"arguments": {
"workspace": "my-workspace",
"repoSlug": "my-repo",
"prId": 123,
"file_path": "src/utils/helper.js",
"line_number": 42,
"line_type": "ADDED",
"comment_text": "Please add error handling here",
"task_text": "Add error handling"
}
}
备注: pr_task_add 在Bitbucket服务器/数据中心上创建拦截器评论,在Bitbuckets云上创建任务。
发展
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Start development server
npm start
需求
- Node.js>=18.17.0
- Bitbucket云应用密码或服务器个人访问令牌
许可证
麻省 理工© Yogesh Rathod 的
