使用说明
MCP比特桶审核服务器
这是一个MCP服务器,用于LLM将bitbucket的功能用于其代码审查工作流。
安装
[!重要]
你需要python 3.10或更高版本才能工作。
从pip安装:
pip install mcp-bitbucket-review
光标中的配置
-
首选
File->Preferences->Cursor Settings->MCP & Integrations. -
添加新的MCP服务器。
-
将以下位桶服务器MCP添加到MCP.json的mcpServers对象中:
{ "mcpServers": { // ... your rest of the MCP servers "bitbucket": { "command": "mcp-bitbucket-review-server", "env": { "BITBUCKET_EMAIL": "YOUR_BITBUCKET_EMAIL", "BITBUCKET_API_TOKEN": "YOUR_BITBUCKET_API_TOKEN" } } } } -
保存设置。
使用示例
打开新聊天并给出以下提示:
查看拉取请求<YOUR_pull_request_URL>
代码审查清单
您可以提供一个自定义代码审查清单,以便在审查过程中使用。检查表是从文件中读取的,可以有一般指南和特定于每个存储库的指南。
检查表文件结构
检查表文件是一个纯文本文件,每个存储库都有部分。一个部分以方括号中的存储库名称开头(例如。, [my-repo]).一个名为 [general] 可用于适用于所有存储库的指南。
以下是一个清单文件的示例:
[general]
Ensure code is well-documented.
Check for any commented-out code that should be removed.
[my-awesome-repo]
Follow the "Awesome Repo" coding style.
Make sure to update the `awesome-spec.json` file.
[another-repo]
All new features must be covered by integration tests.
配置
要使用检查表,您需要设置 BITBUCKET_CODE_REVIEW_CHECKLIST 环境变量到检查表文件的绝对路径。
您可以将此添加到您的 mcp.json 配置文件:
{
"mcpServers": {
// ... your rest of the MCP servers
"bitbucket": {
"command": "mcp-bitbucket-review-server",
"env": {
// ... other environment variables
"BITBUCKET_CODE_REVIEW_CHECKLIST": "C:\\path\\to\\your\\checklist.txt"
}
}
}
}
从比特桶获取API令牌
-
首选https://id.atlassian.com/manage-profile/security/api-tokens
-
点击标有标签的按钮
Create API token with scopes -
给出作用域并存储API令牌。请确保将以下作用域赋予API令牌:
read:pullrequest:bitbucket write:pullrequest:bitbucket read:repository:bitbucket
编码愉快!
