MCP Server for GitHub/GitLab code review - enables AI assistants to review pull requests and merge requests
Project description
Code Review MCP Server
English | ไธญๆ
MCP (Model Context Protocol) server for code review. Enables AI assistants to review GitHub/GitLab Pull Requests and Merge Requests.
โจ Features
- ๐ Multi-platform: Supports both GitHub and GitLab (including self-hosted)
- ๐ Multiple Transports: Supports stdio, SSE, and WebSocket protocols
- ๐ฆ Easy Install: Quick install via
uvxorpip - ๐ณ Containerized: Docker image available
- โ๏ธ Cloud Deploy: One-click Smithery deployment
- ๐ Security First: Environment variable configuration, no data persistence
๐ Quick Start
Option 1: Using uvx (Recommended)
# Run directly, no installation needed
uvx code-review-mcp
Option 2: Using pip
pip install code-review-mcp
# Run the server
code-review-mcp
# (Optional) Install Cursor rules to your project
code-review-mcp init-rules
Option 3: From Source
git clone https://github.com/OldJii/code-review-mcp.git
cd code-review-mcp
pip install -e .
code-review-mcp
๐ง Configuration
Environment Variables
| Variable | Description | Required |
|---|---|---|
GITHUB_TOKEN |
GitHub personal access token | When using GitHub |
GITLAB_TOKEN |
GitLab personal access token | When using GitLab |
GITLAB_HOST |
GitLab host URL | For self-hosted (default: gitlab.com) |
Getting Tokens
GitHub
# Option 1: Using gh CLI (Recommended)
brew install gh
gh auth login
# Option 2: Manual Token Creation
# Visit https://github.com/settings/tokens
# Create Personal Access Token with 'repo' scope
export GITHUB_TOKEN="your-token-here"
GitLab
# Option 1: Using glab CLI (Recommended)
brew install glab
glab auth login
# For self-hosted GitLab
glab auth login --hostname gitlab.yourcompany.com
# Option 2: Manual Token Creation
# Visit GitLab -> Settings -> Access Tokens
# Create token with 'api' scope
export GITLAB_TOKEN="your-token-here"
export GITLAB_HOST="gitlab.yourcompany.com" # For self-hosted
๐ฑ Client Configuration
Cursor
Edit ~/.cursor/mcp.json:
{
"mcpServers": {
"code-review": {
"command": "uvx",
"args": ["code-review-mcp"],
"env": {
"GITHUB_TOKEN": "your-github-token",
"GITLAB_TOKEN": "your-gitlab-token"
}
}
}
}
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"code-review": {
"command": "uvx",
"args": ["code-review-mcp"],
"env": {
"GITHUB_TOKEN": "your-github-token",
"GITLAB_TOKEN": "your-gitlab-token"
}
}
}
}
SSE Mode (Remote Deployment)
# Start SSE server
code-review-mcp --transport sse --port 8000
Client configuration:
{
"mcpServers": {
"code-review": {
"url": "http://your-server:8000/sse"
}
}
}
WebSocket Mode (Remote Deployment)
# Start WebSocket server
code-review-mcp --transport websocket --port 8000
Client configuration:
{
"mcpServers": {
"code-review": {
"url": "ws://your-server:8000/ws"
}
}
}
๐ณ Docker Deployment
Build Image
docker build -t code-review-mcp .
Run Container
stdio mode
docker run -i --rm \
-e GITHUB_TOKEN="your-token" \
code-review-mcp
SSE mode
docker run -d --rm \
-e GITHUB_TOKEN="your-token" \
-p 8000:8000 \
code-review-mcp --transport sse
๐จ MCP Tools
Rules
| Tool | Description |
|---|---|
get_review_rules |
Get review rules (builtin + custom project rules) |
Information Retrieval
| Tool | Description |
|---|---|
get_pr_info |
Get PR/MR details (title, description, branches) |
get_pr_changes |
Get code changes (diff), supports file type filtering |
extract_related_prs |
Extract related PR/MR links from description |
Adding Comments
| Tool | Description |
|---|---|
add_inline_comment |
Add inline comment to specific code line |
add_pr_comment |
Add general comment |
batch_add_comments |
Batch add comments (inline + general) |
๐ฌ Usage Examples
Chat with Cursor or Claude:
Review GitHub PR
Review https://github.com/facebook/react/pull/12345
Review GitLab MR
Review https://gitlab.com/group/project/-/merge_requests/678
Review Self-hosted GitLab MR
Review https://gitlab.yourcompany.com/team/project/-/merge_requests/90
Review Only Specific File Types
Review this PR, only check .py and .js files:
https://github.com/owner/repo/pull/123
๐งช Debugging & Testing
Using MCP Inspector
# Run with MCP Inspector
npx @modelcontextprotocol/inspector uvx code-review-mcp
This launches a web interface where you can:
- View all available tools
- Manually call tools and inspect results
- Debug parameters and responses
Local Development
# Clone repository
git clone https://github.com/OldJii/code-review-mcp.git
cd code-review-mcp
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Debug with Inspector
npx @modelcontextprotocol/inspector python -m code_review_mcp.server
๐ Project Structure
code-review-mcp/
โโโ src/
โ โโโ code_review_mcp/
โ โโโ __init__.py # Package entry
โ โโโ cli.py # CLI commands (init-rules, etc.)
โ โโโ server.py # MCP server main logic
โ โโโ providers.py # GitHub/GitLab providers
โ โโโ rules/ # Bundled Cursor rules
โ โโโ code-review.mdc
โ โโโ code-review-en.mdc
โโโ pyproject.toml # Project config & PyPI publishing
โโโ Dockerfile # Docker build file
โโโ smithery.yaml # Smithery deployment config
โโโ CHANGELOG.md # Changelog
โโโ CONTRIBUTING.md # Contributing guide
โโโ README.md # Documentation
๐ฏ Cursor Rules (Recommended)
This package includes built-in code review rules for Cursor IDE. Install them to your project with one command:
# Install rules to current project
code-review-mcp init-rules
# Install to a specific directory
code-review-mcp init-rules --target /path/to/project
# Overwrite existing rules
code-review-mcp init-rules --force
# List available rules
code-review-mcp list-rules
After installation, the rules will be available in your project's .cursor/rules/ directory:
code-review.mdc- Chinese versioncode-review-en.mdc- English version
Custom Project Rules
You can define project-specific review rules that the MCP server loads at runtime. This allows each project to enforce its own coding standards during reviews.
Quick Setup:
# Generate a custom rules template
code-review-mcp init-rules --custom
This creates .code-review-rules/project-rules.md in your project. Edit it with your project-specific conventions, then configure the MCP server to load it:
{
"mcpServers": {
"code-review": {
"command": "uvx",
"args": ["code-review-mcp"],
"env": {
"GITHUB_TOKEN": "your-token",
"CODE_REVIEW_RULES_DIR": "/absolute/path/to/project/.code-review-rules"
}
}
}
}
How It Works:
- Set
CODE_REVIEW_RULES_DIRto a directory containing.mdor.mdcfiles - Or simply place a
.code-review-rules/directory in your project root (auto-discovered) - The
get_review_rulestool returns both builtin and custom rules - AI assistants use these rules when performing reviews
- Custom rules supplement (not replace) the builtin review guidelines
Environment Variable:
| Variable | Description | Required |
|---|---|---|
CODE_REVIEW_RULES_DIR |
Path to custom rules directory | No (optional) |
๐ค Contributing
Contributions welcome! See CONTRIBUTING.md for details.
๐ License
๐ Related Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_review_mcp-1.2.1.tar.gz.
File metadata
- Download URL: code_review_mcp-1.2.1.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49978eaa53bc9efb13ab5770a5ca6cda6fa3aa2b1484fc1b40ca2c682b2e075d
|
|
| MD5 |
fc75b039f30f891c729667ae20be9cd3
|
|
| BLAKE2b-256 |
e4f7653700bdc3b3b8666e576acda041a51c547ecf9979613d1b50ab94dcb3fd
|
Provenance
The following attestation bundles were made for code_review_mcp-1.2.1.tar.gz:
Publisher:
publish.yml on OldJii/code-review-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code_review_mcp-1.2.1.tar.gz -
Subject digest:
49978eaa53bc9efb13ab5770a5ca6cda6fa3aa2b1484fc1b40ca2c682b2e075d - Sigstore transparency entry: 1566754660
- Sigstore integration time:
-
Permalink:
OldJii/code-review-mcp@920c05e648b436463a69940b6437225755f29c6b -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/OldJii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@920c05e648b436463a69940b6437225755f29c6b -
Trigger Event:
push
-
Statement type:
File details
Details for the file code_review_mcp-1.2.1-py3-none-any.whl.
File metadata
- Download URL: code_review_mcp-1.2.1-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcf61c5f57a27a1f4bcf5430fc1db577d43e289383d8472d11b1ee07a2f0d216
|
|
| MD5 |
1e209d7a3093370f26e399076ac0ec2c
|
|
| BLAKE2b-256 |
fb155ad4aaed303d55e7e751c0532763b0babe925f49044082659dd609b54d31
|
Provenance
The following attestation bundles were made for code_review_mcp-1.2.1-py3-none-any.whl:
Publisher:
publish.yml on OldJii/code-review-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code_review_mcp-1.2.1-py3-none-any.whl -
Subject digest:
fcf61c5f57a27a1f4bcf5430fc1db577d43e289383d8472d11b1ee07a2f0d216 - Sigstore transparency entry: 1566754703
- Sigstore integration time:
-
Permalink:
OldJii/code-review-mcp@920c05e648b436463a69940b6437225755f29c6b -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/OldJii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@920c05e648b436463a69940b6437225755f29c6b -
Trigger Event:
push
-
Statement type: