code-review MCP server
Commit Nov 5, 2026Enables AI assistants to review GitHub and GitLab pull requests and merge requests by fetching diffs and posting inline comments.
Also known as folay-git/code-review-mcp
- Stars
- 4
- Tools
- 7
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 5, 2026
- License
- MIT
What is code-review MCP?
code-review is an MCP server. Enables AI assistants to review GitHub and GitLab pull requests and merge requests by fetching diffs and posting inline comments. It exposes 7 tools, such as get_review_rules, get_pr_info, get_pr_changes.
Summary generated from the project's README
About code-review MCP server
Automating the inspection of pull requests and merge requests from within your AI assistant is what this server enables. It allows developers using Claude Desktop or Cursor to fetch code diffs and post feedback directly to GitHub or GitLab. By integrating with these platforms, an AI can act as a participant in the code review process, providing inline comments on specific lines or general feedback on the entire change.
Users can deploy this server locally via stdio using uvx or pip, or remotely using SSE and WebSocket transports. It supports both GitHub and GitLab, including self-hosted GitLab instances through specific environment variable configurations. To function, the server requires a GitHub personal access token or a GitLab personal access token, and optionally a GITLAB_HOST setting for private servers. It provides specialized tools like get_pr_changes for retrieving diffs, add_inline_comment for specific line feedback, and get_review_rules to ensure reviews follow project-specific coding standards.
What you can do with it
- 1Reviewing GitHub Pull RequestsAsk your AI assistant to analyze a specific GitHub pull request link to find potential issues.
- 2Performing GitLab Merge Request ReviewsDirect an AI client to examine a GitLab merge request and provide feedback.
- 3Enforcing Custom Coding StandardsUse project-specific rules to guide the AI during the automated review process.
- 4Targeted File Type InspectionsInstruct the AI to only perform code reviews on specific file extensions like Python or JavaScript.
Written from the project's README. Every use case is checked against a quote from it.
code-review MCP tools 7
Detected from the READMEget_review_rulesget_pr_infoget_pr_changesextract_related_prsadd_inline_commentadd_pr_commentbatch_add_comments
| get_review_rules | — | |
| get_pr_info | — | |
| get_pr_changes | — | |
| extract_related_prs | — | |
| add_inline_comment | — | |
| add_pr_comment | — | |
| batch_add_comments | — |
Configuration
CODE_REVIEW_RULES_DIRGITHUB_TOKENGITLAB_HOSTGITLAB_TOKEN
| Name | Description | |
|---|---|---|
| CODE_REVIEW_RULES_DIR | — | |
| GITHUB_TOKEN | — | |
| GITLAB_HOST | — | |
| GITLAB_TOKEN | — |
README
View on GitHubCode Review MCP Server
English | 中文
MCP (Model Context Protocol) server for code review. Enables AI assistants to review GitHub/GitLab Pull Requests and Merge Requests.
Keywords: MCP server, AI code review, GitHub pull request review, GitLab merge request, Cursor IDE, Claude Desktop, Model Context Protocol, automated PR comments.
✨ 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/folay-git/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/folay-git/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
❓ FAQ
What is code-review-mcp?
An MCP server that lets AI assistants (Cursor, Claude, etc.) fetch PR/MR diffs and post inline or general review comments on GitHub and GitLab.
How do I install it?
Fastest: uvx code-review-mcp. Or pip install code-review-mcp. See Quick Start.
Does it work with self-hosted GitLab?
Yes. Set GITLAB_TOKEN and GITLAB_HOST=gitlab.yourcompany.com.
Which AI clients are supported?
Any MCP client — Cursor, Claude Desktop, and custom integrations via stdio, SSE, or WebSocket.
Can I add project-specific review rules?
Yes. Run code-review-mcp init-rules --custom or set CODE_REVIEW_RULES_DIR.
Is my code stored on a server?
No persistent storage. Tokens are read from environment variables; diffs are fetched on demand from GitHub/GitLab APIs.
Where can AI assistants read a structured summary?
See llms.txt in this repository.
🔗 Related Links
code-review MCP questions
What tools does code-review MCP provide?
It exposes 7 tools, including get_review_rules, get_pr_info, get_pr_changes, extract_related_prs, add_inline_comment.
Does it work with self-hosted GitLab?
Yes, you can use self-hosted GitLab by setting the GITLAB_TOKEN and GITLAB_HOST environment variables.
Which AI clients are supported?
It supports any MCP client, including Cursor, Claude Desktop, and custom integrations using stdio, SSE, or WebSocket.
Can I add project-specific review rules?
Yes, you can add custom rules by running the init-rules command with the custom flag or by setting the CODE_REVIEW_RULES_DIR environment variable.
Is my code stored on a server?
No, the server does not use persistent storage; it fetches diffs on demand from GitHub or GitLab APIs using environment variable tokens.