GitLab MCP 用于代码审查
该项目从cayirtepeomer/gerrit-code-review-mcp分叉而来,并适用于 GitLab 集成。
一个 MCP(模型上下文协议)服务器,用于将 Claude 等 AI 助手与 GitLab 的合并请求集成。这使得 AI 助手可以直接通过 GitLab API 审查代码更改。
特征
完整的合并请求分析:获取有关合并请求的完整详细信息,包括差异、提交和评论
文件特定差异:分析合并请求中特定文件的更改
版本比较:比较不同的分支、标签或提交
审核管理:添加评论、批准或不批准合并请求
项目概览:获取项目中所有合并请求的列表
安装
先决条件
Python 3.10+
具有 API 范围的 GitLab 个人访问令牌(read_api、api)
用于 MCP 集成的Cursor IDE或Claude 桌面应用程序
快速入门
克隆此存储库:
创建并激活虚拟环境:
安装依赖项:
使用您的 GitLab 配置创建一个
.env
文件(有关所有选项,请参阅.env.example
):
配置选项
您可以在.env
文件中配置以下环境变量:
多变的 | 必需的 | 默认 | 描述 |
GITLAB_TOKEN | 是的 | - | 您的 GitLab 个人访问令牌 |
GITLAB_HOST | 不 | gitlab.com | GitLab 实例主机名 |
GITLAB_API_版本 | 不 | v4 | 要使用的 GitLab API 版本 |
日志级别 | 不 | 信息 | 日志级别(DEBUG、INFO、WARNING、ERROR、CRITICAL) |
调试 | 不 | 错误的 | 启用调试模式 |
请求超时 | 不 | 三十 | API 请求超时(秒) |
最大重试次数 | 不 | 3 | 失败请求的最大重试次数 |
Cursor IDE 集成
要将此 MCP 与 Cursor IDE 一起使用,请将此配置添加到您的~/.cursor/mcp.json
文件中:
将/path/to/your/gitlab-mcp-code-review
替换为克隆存储库的实际路径。
Claude 桌面应用程序集成
要将此 MCP 与 Claude 桌面应用程序一起使用:
打开 Claude 桌面应用程序
前往“设置”→“高级”→“MCP 配置”
添加以下配置:
将/path/to/your/gitlab-mcp-code-review
替换为克隆存储库的实际路径。
可用工具
MCP 服务器提供了以下与 GitLab 交互的工具:
工具 | 描述 |
| 获取有关合并请求的完整信息 |
| 获取特定合并请求的差异 |
| 获取特定提交的差异信息 |
| 比较不同的分支、标签或提交 |
| 向合并请求添加评论 |
| 批准合并请求 |
| 取消批准合并请求 |
| 获取项目的合并请求列表 |
使用示例
获取合并请求
查看特定文件更改
比较分支机构
向合并请求添加评论
批准合并请求
故障排除
如果您遇到问题:
验证您的 GitLab 令牌是否具有适当的权限(api、read_api)
检查你的
.env
文件设置确保您的 MCP 配置路径正确
使用以下方法测试连接:
curl -H "Private-Token: your-token" https://gitlab.com/api/v4/projects
在 .env 文件中设置 LOG_LEVEL=DEBUG 以获得更详细的日志记录
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
分叉存储库
创建你的功能分支(
git checkout -b feature/amazing-feature
)提交您的更改(
git commit -m 'Add some amazing feature'
)推送到分支(
git push origin feature/amazing-feature
)打开拉取请求
有关开发过程的更多详细信息,请参阅CONTRIBUTING.md文件。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
MCP 服务器将 Claude 等 AI 助手与 GitLab 的合并请求相集成,允许他们直接通过 GitLab API 审查代码更改、添加注释以及批准/取消批准合并请求。
Related MCP Servers
- AsecurityFlicenseAqualityAn MCP server that enables Claude and other compatible LLMs to interact with the GitHub API, supporting features like creating issues, retrieving repository information, listing issues, and searching repositories.Last updated -4
- -securityAlicense-qualityAn MCP server that enables communication with GitLab repositories, allowing interaction with GitLab's API to manage projects, issues, and repositories through natural language.Last updated -7,5121MIT License
- AsecurityFlicenseAqualityAn MCP server that allows Claude and other MCP-compatible LLMs to interact with the GitHub API, supporting features like creating issues, getting repository information, listing issues, and searching repositories.Last updated -4
- -securityAlicense-qualityAn MCP server that enables AI assistants like Claude to help users manage their GitHub notifications through natural language commands.Last updated -016MIT License