【技术文档摘要】: Gitlab Mcp server
支持服务:
GitLab集成和使用 @gitbeaker/rest 库支持获取合并请求信息。
export GITLAB_TOKEN="your_personal_access_token"
export GITLAB_URL="https://gitlab.com" # 可选,默认为 gitlab.com(注意:不需要 /api/v4 后缀)
get_merge_request: 获取特定MR的详细信息list_merge_requests 列出项目的MR列表gitlab_code_review 对MR进行全面代码审查gitlab_branch_code_review 对指定分支进行全面代码审查gitlab_commit_review 对指定提交进行代码审查get_file_content 获取仓库中特定文件的内容list_branches 列出项目的所有分支write_gitlab_mr_note 在MR中写入审查评论(支持灵活的通知模式)@gitbeaker/rest GitLab API客户端库请参阅详细的使用说明 GitLab 文档
支持通过飞书机器人发送通知,当在GitLab MR评论时可以自动发送飞书通知。
export LARK_WEBHOOK_URL="https://open.feishu.cn/open-apis/bot/v2/hook/xxx" # 飞书机器人Webhook URL
export LARK_SECRET_KEY="your_secret_key" # 可选:签名密钥(如果机器人启用了签名验证)
export LARK_ENABLE_NOTIFICATION="true" # 可选:是否启用通知,默认为 true
export GITLAB_NOTE_MODE="gitlab_only" # 可选:通知模式 - gitlab_only(仅GitLab)、lark_only(仅飞书)、both(两者都发),默认为 gitlab_only
// 使用环境变量配置的默认模式
await write_gitlab_mr_note({
projectId: "group/project",
mergeRequestIid: 123,
note: "代码审查完成,LGTM!"
});
// 明确指定只写入 GitLab
await write_gitlab_mr_note({
projectId: "group/project",
mergeRequestIid: 123,
note: "内部备注",
notificationMode: "gitlab_only"
});
// 只发送飞书通知,不写入 GitLab
await write_gitlab_mr_note({
projectId: "group/project",
mergeRequestIid: 123,
note: "团队通知:代码已审查",
notificationMode: "lark_only"
});
// 强制两者都执行(覆盖环境变量)
await write_gitlab_mr_note({
projectId: "group/project",
mergeRequestIid: 123,
note: "重要通知",
notificationMode: "both"
});
智能代码审查规则系统根据不同的项目类型和文件扩展名提供相应的代码审查建议。
get_code_review_rules: 获取适用于特定项目和文件的代码审查规则list_all_code_review_rules 列出所有可用的代码审查规则get_project_types: 获取支持的项目类型信息支持为特定项目配置专属代码审查规则:
详细使用说明,请参阅: