GitLab MCP (Model Context Protocol) server for AI agents
Gitlab Mcp server
支持服务:
GitLab 集成使用 @gitbeaker/rest 库支持获取 Merge Request 信息。
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 文档
支持通过 Lark(飞书)机器人发送通知,可以在写入 GitLab MR 评论时自动发送 Lark 通知。
export LARK_WEBHOOK_URL="https://open.feishu.cn/open-apis/bot/v2/hook/xxx" # Lark 机器人 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(仅Lark)、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"
});
// 只发送 Lark 通知,不写入 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: 获取支持的项目类型信息支持为特定项目配置专属的代码审查规则:
详细使用说明请参考:
Source-derived launch command. Check the maintainer’s required arguments and credentials before running:
npx -y @dubuqingfeng/gitlab-mcp-serverMerge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.
{
"mcpServers": {
"io-github-dubuqingfeng-gitlab-mcp-server": {
"command": "npx",
"args": [
"-y",
"@dubuqingfeng/gitlab-mcp-server"
]
}
}
}Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.
Claude Desktop setup referenceio.github.dubuqingfeng/gitlab-mcp-server works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.~/.cursor/mcp.jsonRestart Cursor for changes to take effect..vscode/mcp.jsonReload VS Code window for changes to take effect.~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect..mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.