GitLab Review MCP
Enables code review operations on GitHub and GitLab, including fetching pull/merge requests, viewing diffs, adding comments, analyzing code quality, and creating merge requests directly from your MCP client.
README
Node Code Review MCP
A Node.js implementation of the Model Context Protocol (MCP) server for code review operations, supporting both GitHub and GitLab platforms.
📖 中文文档: README-zh.md | 快速开始 | 功能对比
Features
- 🔍 Fetch pull request/merge request details
- 📄 Get code diffs for PRs or commits
- 💬 Add review comments
- 🔍 Basic code quality analysis
- 🔧 Configurable via command line arguments
- 🌐 Support for both GitHub and GitLab APIs
Installation
Via NPM (when published)
npm install -g gitlab-review-mcp
Local Development
git clone <repository>
cd gitlab-review-mcp
npm install
npm run build
Configuration
Environment Variables
Copy env.example to .env and configure:
# API Configuration
API_BASE_URL=https://api.github.com
API_TOKEN=your_github_token_here
# For GitLab, use:
# API_BASE_URL=https://gitlab.com/api/v4
# API_TOKEN=your_gitlab_token_here
# Server Configuration
TIMEOUT=30000
MAX_RETRIES=3
Command Line Arguments
gitlab-review-mcp \
--api-base-url https://api.github.com \
--api-token your_token \
--timeout 30000 \
--max-retries 3
MCP Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
Using NPX (Recommended)
{
"mcpServers": {
"gitlab-review-mcp": {
"command": "npx",
"args": [
"-y",
"gitlab-review-mcp",
"--api-base-url=https://api.github.com",
"--api-token=your_github_token_here"
],
"alwaysAllow": [
"fetch_pull_request",
"fetch_code_diff",
"add_review_comment",
"analyze_code_quality",
"get_server_config",
"create_merge_request",
"get_current_branch",
"get_project_info"
]
}
}
}
Using Local Installation
{
"mcpServers": {
"gitlab-review-mcp": {
"command": "node",
"args": [
"/path/to/gitlab-review-mcp/dist/index.js",
"--api-base-url=https://api.github.com",
"--api-token=your_github_token_here"
],
"alwaysAllow": [
"fetch_pull_request",
"fetch_code_diff",
"add_review_comment",
"analyze_code_quality",
"get_server_config",
"create_merge_request",
"get_current_branch",
"get_project_info"
]
}
}
}
For GitLab
{
"mcpServers": {
"gitlab-review-mcp": {
"command": "npx",
"args": [
"-y",
"gitlab-review-mcp",
"--api-base-url=https://gitlab.com/api/v4",
"--api-token=your_gitlab_token_here"
],
"alwaysAllow": [
"fetch_pull_request",
"fetch_code_diff",
"add_review_comment",
"analyze_code_quality",
"get_server_config",
"create_merge_request",
"get_current_branch",
"get_project_info"
]
}
}
}
Available Tools
fetch_pull_request
Fetch pull request/merge request details.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project" (aliases:projectId,project_path)pullRequestNumber(number): Pull request numberprovider(string, optional): "github" or "gitlab" (default: "gitlab")
fetch_code_diff
Fetch code diff for a pull request or commit.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"pullRequestNumber(number, optional): Pull request numbercommitSha(string, optional): Commit SHAfilePath(string, optional): Specific file path to get diff forprovider(string, optional): "github" or "gitlab" (default: "gitlab")
add_review_comment
Add a review comment to a pull request.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"pullRequestNumber(number): Pull request numberbody(string): Comment bodyfilePath(string, optional): File path for line commentline(number, optional): Line number for line commentprovider(string, optional): "github" or "gitlab" (default: "gitlab")
analyze_code_quality
Analyze code quality and provide suggestions with detailed metrics.
Parameters:
code(string): Code content to analyzelanguage(string): Programming language (javascript, typescript, python, java, go, etc.)rules(array, optional): Specific rules to check
get_repository_info
Get repository information.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"provider(string, optional): "github" or "gitlab" (default: "gitlab")
analyze_files_batch
Analyze multiple files for code quality issues.
Parameters:
files(array): Array of file objects withpath,content, andlanguagepropertiesrules(array, optional): Specific rules to apply to all files
get_pull_request_files
Get list of files changed in a pull request.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"pullRequestNumber(number): Pull request numberprovider(string, optional): "github" or "gitlab" (default: "gitlab")
get_supported_languages
Get list of supported programming languages for code analysis.
get_language_rules
Get available analysis rules for a specific language.
Parameters:
language(string): Programming language
get_server_config
Get current server configuration and health status.
create_merge_request 🆕
Create a new GitLab merge request from a source branch with enhanced error handling.
Parameters:
projectId(string): GitLab project ID or path- Numeric ID (recommended):
"12345" - Project path:
"group/project"or"group/subgroup/project"
- Numeric ID (recommended):
sourceBranch(string): Source branch name (e.g., "feature/new-feature")targetBranch(string, optional): Target branch name (defaults to "main")title(string, optional): Merge request title (auto-generated from branch name if not provided)description(string, optional): Merge request descriptionassigneeId(number, optional): User ID to assign the merge request toreviewerIds(array, optional): Array of user IDs to request reviews fromdeleteSourceBranch(boolean, optional): Whether to delete source branch when MR is mergedsquash(boolean, optional): Whether to squash commits when merging
Enhanced Error Handling:
- Project ID validation with detailed error messages
- Automatic project verification before MR creation
- Comprehensive troubleshooting guidance for common errors (404, 401, 403, etc.)
- Support for both numeric IDs and project paths
Example:
// Minimal usage
{
"projectId": "mygroup/myproject",
"sourceBranch": "feature/user-authentication"
}
// Full configuration
{
"projectId": "12345",
"sourceBranch": "feature/user-authentication",
"targetBranch": "develop",
"title": "feat: Add user authentication system",
"description": "This MR adds JWT-based authentication with password hashing.",
"assigneeId": 123,
"reviewerIds": [456, 789],
"deleteSourceBranch": true,
"squash": true
}
Auto-generated Titles: The tool automatically generates conventional commit-style titles based on branch prefixes:
feature/→feat:bugfix/→fix:hotfix/→fix:docs/→docs:refactor/→refactor:
get_current_branch 🆕
Get current Git branch and repository information.
Parameters:
workingDirectory(string, optional): Working directory path (defaults to current directory)
Example:
{
"workingDirectory": "/path/to/your/project"
}
Returns:
{
"currentBranch": "feature/user-authentication",
"allBranches": ["main", "feature/user-authentication", "develop"],
"isGitRepository": true,
"repositoryRoot": "/path/to/your/project"
}
get_project_info 🆕
Get current GitLab project information from Git remotes.
Parameters:
workingDirectory(string, optional): Working directory path (defaults to current directory)remoteName(string, optional): Git remote name (defaults to "origin")
Example:
{
"workingDirectory": "/path/to/your/project",
"remoteName": "origin"
}
Returns:
{
"projectId": "group%2Fproject",
"projectPath": "group/project",
"gitlabUrl": "https://gitlab.com",
"remotes": [
{
"name": "origin",
"url": "git@gitlab.com:group/project.git",
"fetch": "git@gitlab.com:group/project.git",
"push": "git@gitlab.com:group/project.git"
}
],
"isGitlabProject": true
}
API Token Setup
GitHub
- Go to GitHub Settings > Developer settings > Personal access tokens
- Generate a new token with appropriate permissions:
reposcope for private repositoriespublic_reposcope for public repositories only
GitLab
- Go to GitLab User Settings > Access Tokens
- Create a personal access token with:
apiscope for full API accessread_apiscope for read-only access
Development
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
# Clean build directory
npm run clean
License
MIT License - see LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。