Code Review MCP Server
Connects LLMs to GitHub and GitLab to analyze pull and merge requests for logic, security, and architectural alignment. It provides tools for fetching diffs, file contents, and project metadata, alongside guided prompts for professional code reviews.
README
Code Review MCP Server
An MCP server designed to act as a Read-Only Intelligence Provider for code reviews. It connects LLMs (like Claude Desktop or Gemini) to your Git hosting platforms (GitLab & GitHub) to analyze Merge/Pull Requests, understand project context, and provide expert feedback.
Features
- Platform Agnostic: Supports both GitLab and GitHub.
- List PRs/MRs: See what needs review.
- Get Details: Understand the description, author, and intent.
- Get Diff: Retrieve and analyze code changes.
- Read Files: Fetch specific files from repositories at any ref (commit, branch, tag).
- Custom Guidelines: Configure your own code review guidelines.
Installation & Setup
You can use this MCP server in two ways:
Option A: Global Installation (Recommended)
Install the package globally via npm:
npm install -g mcp-server-code-review
Option B: Clone & Build (For Development)
Clone the repository and build it locally:
git clone <your-repo-url> mcp-server-code-review
cd mcp-server-code-review
npm install
npm run build
Configuration
The server requires environment variables for authentication. You should add these to your MCP Client configuration (e.g., Claude Desktop).
Environment Variables
| Variable | Description | Required For |
|---|---|---|
GITLAB_TOKEN |
Your GitLab Personal Access Token. | GitLab |
GITLAB_URL |
GitLab instance URL (default: https://gitlab.com). |
GitLab (Self-Managed) |
GITHUB_TOKEN |
Your GitHub Personal Access Token. | GitHub |
CODE_REVIEW_GUIDELINES_FILE |
Path to a file containing custom code review guidelines. | Optional (Custom Rules) |
CODE_REVIEW_GUIDELINES |
Inline custom code review guidelines text. | Optional (Custom Rules) |
Note: At least one of
GITLAB_TOKENorGITHUB_TOKENmust be provided. IfCODE_REVIEW_GUIDELINES_FILEis set, it takes precedence overCODE_REVIEW_GUIDELINES.
MCP Server Configuration
Using Global Installation
{
"mcpServers": {
"code-review": {
"command": "mcp-server-code-review",
"env": {
"GITLAB_TOKEN": "your_token_here",
"GITHUB_TOKEN": "your_token_here"
}
}
}
}
Using Local Clone
Replace /absolute/path/to/... with the actual full path to the project directory.
{
"mcpServers": {
"code-review": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-code-review/dist/index.js"],
"env": {
"GITLAB_TOKEN": "your_token_here",
"GITHUB_TOKEN": "your_token_here"
}
}
}
}
With Self-Managed GitLab
{
"mcpServers": {
"code-review": {
"command": "mcp-server-code-review",
"env": {
"GITLAB_TOKEN": "your_token_here",
"GITLAB_URL": "https://gitlab.yourcompany.com"
}
}
}
}
With Custom Code Review Guidelines
You can provide custom guidelines either as a file path or inline text:
{
"mcpServers": {
"code-review": {
"command": "mcp-server-code-review",
"env": {
"GITHUB_TOKEN": "your_token_here",
"GITLAB_TOKEN": "your_token_here",
"GITLAB_URL": "https://gitlab.yourcompany.com",
"CODE_REVIEW_GUIDELINES_FILE": "/path/to/your/guidelines.md"
}
}
}
}
Or use inline guidelines:
{
"mcpServers": {
"code-review": {
"command": "mcp-server-code-review",
"env": {
"GITHUB_TOKEN": "your_token_here",
"CODE_REVIEW_GUIDELINES": "Focus on performance and security. Ensure all functions have proper error handling."
}
}
}
}
Claude Desktop Configuration
Add the following to your claude_desktop_config.json file.
Path locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Claude Code (CLI) Configuration
Add the following to your settings.json file for global configuration, or .claude/settings.local.json in your project directory for project-specific configuration.
Path locations (global):
- macOS:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json - Linux:
~/.claude/settings.json
Gemini Configuration
Add the following to your settings.json file.
Path locations:
- macOS:
~/.gemini/settings.json - Windows:
%USERPROFILE%\.gemini\settings.json - Linux:
~/.gemini/settings.json
ChatGPT Configuration
Add the following to your mcp.json file.
Path locations:
- macOS:
~/.chatgpt/mcp.json - Windows:
%USERPROFILE%\.chatgpt\mcp.json - Linux:
~/.chatgpt/mcp.json
Available Tools
GitHub Tools
| Tool | Description |
|---|---|
github_list_prs |
List pull requests with optional status filter |
github_get_pr_details |
Get detailed information about a pull request |
github_get_pr_diff |
Retrieve code changes/diff for a pull request |
github_read_file |
Read file content at a specific ref |
github_get_project_metadata |
Fetch README and manifest files (package.json, etc.) |
GitLab Tools
| Tool | Description |
|---|---|
gitlab_list_mrs |
List merge requests with optional status filter |
gitlab_get_mr_details |
Get detailed information about a merge request |
gitlab_get_mr_diff |
Retrieve code changes/diff for a merge request |
gitlab_read_file |
Read file content at a specific ref |
gitlab_get_project_metadata |
Fetch README and manifest files (package.json, etc.) |
Available Prompts
| Prompt | Description |
|---|---|
review_merge_request |
Guided GitLab MR review with Principal Engineer perspective |
review_pull_request |
Guided GitHub PR review with Principal Engineer perspective |
These prompts instruct the LLM to:
- Act as a Principal Software Engineer
- Focus on logic errors, race conditions, security issues, and architectural alignment
- Provide structured feedback (Summary, Critical Issues, Suggestions, Nitpicks)
- Request issue/ticket details for additional context
Development & Debugging
Run Unit Tests
npm test # Run all tests
npm run test:coverage # Run tests with coverage report
Format Code
npm run format # Format code with Prettier
npm run format:check # Check code formatting
Test with MCP Inspector
The MCP Inspector allows you to test the server and tool calls interactively in your browser without needing the Claude Desktop app.
-
Build the project:
npm run build -
Run the Inspector: (Replace tokens with your actual values)
GITLAB_TOKEN=your_token npx @modelcontextprotocol/inspector node dist/index.js -
Open:
http://localhost:6274(or the port shown in terminal).
License
ISC
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。