
mehmetakinn/gitlab-mcp-code-review 是从 https://github.com/mehmetakinn/gitlab-mcp-code-review. 导入的 MCP 服务器候选
概览
mehmetakinn/gitlab-mcp-code-review 是从 https://github.com/mehmetakinn/gitlab-mcp-code-review. 导入的 MCP 服务器候选
概述(AI 翻译)
本项目由 cayirtepeomer/gerrit-code-review-mcp 分支而来,并适配为 GitLab 集成。
一个MCP(模型上下文协议)服务器,用于将像Claude这样的AI助手与GitLab的合并请求集成。这使得AI助手能够通过GitLab API直接审查代码变更。
特色
- 完整的合并请求分析:获取合并请求的详细信息,包括差异、提交和注释
- 文件特定差异:分析合并请求中特定文件的变更
- 版本比较:比较不同的分支、标签或提交
- 审核管理:添加评论,批准或取消合并请求
- 项目概述:获取项目中所有合并请求的列表
安装
先决条件
- Python 3.10+
- 带有API范围的GitLab个人访问令牌(read_api,API)
- 用于MCP集成的光标IDE或Claude桌面应用
快速开始
-
克隆此仓库:
-
创建并激活虚拟环境:
-
安装依赖:
-
创建一个包含 GitLab 配置的
.env文件(所有选项见.env.example):
配置选项
以下环境变量可以在你的’中配置。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
GitLab MCP for Code Review
This project is forked from cayirtepeomer/gerrit-code-review-mcp and adapted for GitLab integration.
An MCP (Model Context Protocol) server for integrating AI assistants like Claude with GitLab’s merge requests. This allows AI assistants to review code changes directly through the GitLab API.
Features
- Complete Merge Request Analysis: Fetch full details about merge requests including diffs, commits, and comments
- File-Specific Diffs: Analyze changes to specific files within merge requests
- Version Comparison: Compare different branches, tags, or commits
- Review Management: Add comments, approve, or unapprove merge requests
- Project Overview: Get lists of all merge requests in a project
Installation
Prerequisites
- Python 3.10+
- GitLab personal access token with API scope (read_api, api)
- Cursor IDE or Claude Desktop App for MCP integration
Quick Start
- Clone this repository:
git clone https://github.com/mehmetakinn/gitlab-mcp-code-review.git
cd gitlab-mcp-code-review
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.envfile with your GitLab configuration (see.env.examplefor all options):
# Required
GITLAB_TOKEN=your_personal_access_token_here
# Optional settings
GITLAB_HOST=gitlab.com
GITLAB_API_VERSION=v4
LOG_LEVEL=INFO
Configuration Options
The following environment variables can be configured in your .env file:
| Variable | Required | Default | Description |
|---|---|---|---|
| GITLAB_TOKEN | Yes | - | Your GitLab personal access token |
| GITLAB_HOST | No | gitlab.com | GitLab instance hostname |
| GITLAB_API_VERSION | No | v4 | GitLab API version to use |
| LOG_LEVEL | No | INFO | Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
| DEBUG | No | false | Enable debug mode |
| REQUEST_TIMEOUT | No | 30 | API request timeout in seconds |
| MAX_RETRIES | No | 3 | Maximum retry attempts for failed requests |
Cursor IDE Integration
To use this MCP with Cursor IDE, add this configuration to your ~/.cursor/mcp.json file:
{
"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": {
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"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
}
}
}