比特桶MCP服务器
用于模型上下文协议(MCP)服务器的Bitbucket API集成。此服务器允许您从Bitbucket存储库读取各种信息,并与Claude Desktop和其他MCP客户端无缝集成。
特性
- 仓库基本信息查询
- 提交列表和详细信息查询
- 提交差异查询
- 分支和标签列表查询
- 拉取请求列表查询
- 文件和目录内容查询
- 支持公共和私有存储库
- 可配置的默认工作区
安装
全局安装(推荐)
npm install -g bitbucket-mcp-service使用npx(无需安装)
npx bitbucket-mcp-service本地安装
npm install bitbucket-mcp-service2.比特桶身份验证设置
您需要创建Bitbucket应用程序密码:
- 转到Bitbucket帐户设置
- 选择应用程序密码菜单
- 创建新的应用程序密码(所需权限:存储库-读取)
- 设置环境变量:
export BITBUCKET_USERNAME="your_username"
export BITBUCKET_APP_PASSWORD="your_app_password"
export BITBUCKET_DEFAULT_WORKSPACE="your_default_workspace_url"3.MCP客户端配置
将以下内容添加到您的Claude Desktop或其他MCP客户端配置中:
使用全局安装
{
"mcpServers": {
"bitbucket": {
"command": "bitbucket-mcp-service",
"env": {
"BITBUCKET_USERNAME": "your_username",
"BITBUCKET_APP_PASSWORD": "your_app_password",
"BITBUCKET_DEFAULT_WORKSPACE": "your_default_workspace_url"
}
}
}
}使用npx
{
"mcpServers": {
"bitbucket": {
"command": "npx",
"args": ["bitbucket-mcp-service"],
"env": {
"BITBUCKET_USERNAME": "your_username",
"BITBUCKET_APP_PASSWORD": "your_app_password",
"BITBUCKET_DEFAULT_WORKSPACE": "your_default_workspace_url"
}
}
}
}使用本地安装
{
"mcpServers": {
"bitbucket": {
"command": "node",
"args": ["./node_modules/bitbucket-mcp-service/build/src/index.js"],
"env": {
"BITBUCKET_USERNAME": "your_username",
"BITBUCKET_APP_PASSWORD": "your_app_password",
"BITBUCKET_DEFAULT_WORKSPACE": "your_default_workspace_url"
}
}
}
}可用工具
get_pository_info
查询存储库的基本信息。
参数:
repo_slug:存储库名称/slugworkspace(可选):Bitbucket工作区名称
get_commits
查询提交列表。
参数:
repo_slug:存储库名称/slugworkspace(可选):Bitbucket工作区名称branch(可选):分支机构名称limit(可选):要检索的提交数(默认值:10,最大值:100)
get_commit_detail
查询特定提交的详细信息。
参数:
repo_slug:存储库名称/slugcommit_id:提交哈希/IDworkspace(可选):Bitbucket工作区名称
get_commit_diff
特定提交的查询更改(diff)。
参数:
repo_slug:存储库名称/slugcommit_id:提交哈希/IDworkspace(可选):Bitbucket工作区名称
get_branches
查询存储库中的分支列表。
参数:
repo_slug:存储库名称/slugworkspace(可选):Bitbucket工作区名称
获取标签
查询存储库中的标记列表。
参数:
repo_slug:存储库名称/slugworkspace(可选):Bitbucket工作区名称
get_pull_requests
查询拉取请求列表。
参数:
repo_slug:存储库名称/slugworkspace(可选):Bitbucket工作区名称state(可选):PR状态(打开、合并、取消、已覆盖)
获取_文件_内容
查询特定文件的内容。
参数:
repo_slug:存储库名称/slugfile_path:文件路径workspace(可选):Bitbucket工作区名称branch(可选):分支名称(默认:main)
get_directory_content
查询目录内容。
参数:
repo_slug:存储库名称/slugworkspace(可选):Bitbucket工作区名称directory_path(可选):目录路径(默认:root)branch(可选):分支名称(默认:main)
使用示例
配置默认工作区后,您可以在MCP客户端中使用:
Show recent 20 commits from myrepo: get_commits repo_slug="myrepo" limit=20
Show specific commit details: get_commit_detail repo_slug="myrepo" commit_id="abc123"
Show file content: get_file_content repo_slug="myrepo" file_path="README.md"备注
- 需要Bitbucket应用程序密码(不能使用常规密码)
- 可以在不进行身份验证的情况下查询公共存储库中的某些信息,但需要身份验证才能实现完整功能
- 使用时考虑API速率限制
- 包含敏感信息的存储库需要适当的权限管理
发展
这个项目是用TypeScript编写的,使用MCP SDK。
克隆和设置
git clone https://github.com/hyodol53/bitbucket-mcp-service.git
cd bitbucket-mcp-service
npm install开发命令
# Build the project
npm run build
# Run in development mode
npm run dev
# Run the built server
npm start测试
您可以使用提供的test.http文件在VS Code中测试服务器,该文件具有REST客户端扩展名。
贡献
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
许可证
MIT许可证
