GitLab MCP for Code Review
コードレビューのためのGitLab MCP
このプロジェクトは、cayirtepeomer/gerrit-code-review-mcpからフォークされ、GitLab 統合用に適応されています。
ClaudeのようなAIアシスタントをGitLabのマージリクエストに統合するためのMCP(Model Context Protocol)サーバー。これにより、AIアシスタントはGitLab APIを介して直接コード変更をレビューできるようになります。
特徴
完全なマージリクエスト分析: 差分、コミット、コメントを含むマージリクエストの完全な詳細を取得します
ファイル固有の差分: マージリクエスト内の特定のファイルの変更を分析する
バージョン比較: 異なるブランチ、タグ、コミットを比較します
レビュー管理: コメントの追加、マージリクエストの承認または承認解除
プロジェクト概要: プロジェクト内のすべてのマージリクエストのリストを取得する
Related MCP server: AI-PR-Review-MCP
インストール
前提条件
Python 3.10以上
API スコープ (read_api、api) を持つ GitLab 個人アクセス トークン
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.txtGitLab 設定で
.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_トークン | はい | - | GitLab個人アクセストークン |
GITLAB_ホスト | いいえ | gitlab.com | GitLabインスタンスのホスト名 |
GITLAB_API_バージョン | いいえ | v4 | 使用するGitLab APIバージョン |
ログレベル | いいえ | 情報 | ログレベル(DEBUG、INFO、WARNING、ERROR、CRITICAL) |
デバッグ | いいえ | 間違い | デバッグモードを有効にする |
リクエストタイムアウト | いいえ | 30 | APIリクエストのタイムアウト(秒) |
最大再試行回数 | いいえ | 3 | 失敗したリクエストの最大再試行回数 |
カーソル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クローンしたリポジトリへの実際のパスに置き換えます。
クロードデスクトップアプリ統合
この 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 を設定します。
貢献
貢献を歓迎します!お気軽にプルリクエストを送信してください。
リポジトリをフォークする
機能ブランチを作成します(
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