GitLab MCP for Code Review
GitLab MCP 用于代码审查
该项目从cayirtepeomer/gerrit-code-review-mcp分叉而来,并适用于 GitLab 集成。
一个 MCP(模型上下文协议)服务器,用于将 Claude 等 AI 助手与 GitLab 的合并请求集成。这使得 AI 助手可以直接通过 GitLab API 审查代码更改。
特征
完整的合并请求分析:获取有关合并请求的完整详细信息,包括差异、提交和评论
文件特定差异:分析合并请求中特定文件的更改
版本比较:比较不同的分支、标签或提交
审核管理:添加评论、批准或不批准合并请求
项目概览:获取项目中所有合并请求的列表
Related MCP server: AI-PR-Review-MCP
安装
先决条件
Python 3.10+
具有 API 范围的 GitLab 个人访问令牌(read_api、api)
用于 MCP 集成的Cursor IDE或Claude 桌面应用程序
快速入门
克隆此存储库:
git clone https://github.com/mehmetakinn/gitlab-mcp-code-review.git
cd gitlab-mcp-code-review创建并激活虚拟环境:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate安装依赖项:
pip install -r requirements.txt使用您的 GitLab 配置创建一个
.env文件(有关所有选项,请参阅.env.example):
# Required
GITLAB_TOKEN=your_personal_access_token_here
# Optional settings
GITLAB_HOST=gitlab.com
GITLAB_API_VERSION=v4
LOG_LEVEL=INFO配置选项
您可以在.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文件中:
{
"mcpServers": {
"gitlab-mcp-code-review": {
"command": "/path/to/your/gitlab-mcp-code-review/.venv/bin/python",
"args": [
"/path/to/your/gitlab-mcp-code-review/server.py",
"--transport",
"stdio"
],
"cwd": "/path/to/your/gitlab-mcp-code-review",
"env": {
"PYTHONPATH": "/path/to/your/gitlab-mcp-code-review",
"VIRTUAL_ENV": "/path/to/your/gitlab-mcp-code-review/.venv",
"PATH": "/path/to/your/gitlab-mcp-code-review/.venv/bin:/usr/local/bin:/usr/bin:/bin"
},
"stdio": true
}
}
}将/path/to/your/gitlab-mcp-code-review替换为克隆存储库的实际路径。
Claude 桌面应用程序集成
要将此 MCP 与 Claude 桌面应用程序一起使用:
打开 Claude 桌面应用程序
前往“设置”→“高级”→“MCP 配置”
添加以下配置:
{
"mcpServers": {
"gitlab-mcp-code-review": {
"command": "/path/to/your/gitlab-mcp-code-review/.venv/bin/python",
"args": [
"/path/to/your/gitlab-mcp-code-review/server.py",
"--transport",
"stdio"
],
"cwd": "/path/to/your/gitlab-mcp-code-review",
"env": {
"PYTHONPATH": "/path/to/your/gitlab-mcp-code-review",
"VIRTUAL_ENV": "/path/to/your/gitlab-mcp-code-review/.venv",
"PATH": "/path/to/your/gitlab-mcp-code-review/.venv/bin:/usr/local/bin:/usr/bin:/bin"
},
"stdio": true
}
}
}将/path/to/your/gitlab-mcp-code-review替换为克隆存储库的实际路径。
可用工具
MCP 服务器提供了以下与 GitLab 交互的工具:
工具 | 描述 |
| 获取有关合并请求的完整信息 |
| 获取特定合并请求的差异 |
| 获取特定提交的差异信息 |
| 比较不同的分支、标签或提交 |
| 向合并请求添加评论 |
| 批准合并请求 |
| 取消批准合并请求 |
| 获取项目的合并请求列表 |
使用示例
获取合并请求
# Get details of merge request #5 in project with ID 123
mr = fetch_merge_request("123", "5")查看特定文件更改
# Get diff for a specific file in a merge request
file_diff = fetch_merge_request_diff("123", "5", "path/to/file.js")比较分支机构
# Compare develop branch with master branch
diff = compare_versions("123", "develop", "master")向合并请求添加评论
# Add a comment to a merge request
comment = add_merge_request_comment("123", "5", "This code looks good!")批准合并请求
# Approve a merge request and set required approvals to 2
approval = approve_merge_request("123", "5", approvals_required=2)故障排除
如果您遇到问题:
验证您的 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
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseCqualityAmaintenanceA production-ready MCP server for GitLab enabling AI assistants to read and manage GitLab projects, merge requests, issues, pipelines, wikis, releases, and more through a unified interface.1005149MIT
- Flicense-qualityDmaintenanceAn MCP server that automates pull request reviews using multiple LLM providers (OpenAI, Claude, Gemini, Groq, Perplexity) and supports GitHub and Bitbucket with real-time webhook integration and interactive AI assistant commands.1
- Alicense-qualityBmaintenanceAn MCP server that enables AI agents to perform automated code reviews on GitLab merge requests, including fetching details, reading diffs, posting inline comments, managing labels, and approving or unapproving MRs.514MIT
- AlicenseAqualityAmaintenanceMCP server for GitLab REST API enabling AI agents to manage pipelines, merge requests, diffs, and local reviews.1512MIT
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
An MCP server that integrates with Discord to provide AI-powered features.
A MCP server built for developers enabling Git based project management with project and personal…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mehmetakinn/gitlab-mcp-code-review'
If you have feedback or need assistance with the MCP directory API, please join our Discord server