code-review-mcp
This MCP server enables AI assistants to review GitHub/GitLab PRs and MRs by loading review rules, retrieving PR/MR data, and posting review comments.
Fetch PR/MR details such as title, description, author, and branches.
Fetch code changes/diffs with optional file-extension filtering.
Retrieve builtin and custom code review rules, with optional language filtering.
Extract related PR/MR links from a description.
Add inline comments to specific lines, marking old/deleted or new/added lines.
Add general PR/MR comments.
Batch add multiple inline comments and optionally a general comment.
Work with GitHub and GitLab, including self-hosted GitLab via a host setting.
Support stdio, SSE, and WebSocket transports, with uvx, pip, source, and Docker deployment options.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-review-mcp Review https://github.com/facebook/react/pull/12345"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
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
Related MCP server: GitHub Code Review Assistant
π Quick Start
Option 1: Using uvx (Recommended)
# Run directly, no installation needed
uvx code-review-mcpOption 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-rulesOption 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 personal access token | When using GitHub |
| GitLab personal access token | When using GitLab |
| 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 8000Client configuration:
{
"mcpServers": {
"code-review": {
"url": "http://your-server:8000/sse"
}
}
}WebSocket Mode (Remote Deployment)
# Start WebSocket server
code-review-mcp --transport websocket --port 8000Client 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-mcpSSE 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 (builtin + custom project rules) |
Information Retrieval
Tool | Description |
| Get PR/MR details (title, description, branches) |
| Get code changes (diff), supports file type filtering |
| Extract related PR/MR links from description |
Adding Comments
Tool | Description |
| Add inline comment to specific code line |
| Add general comment |
| Batch add comments (inline + general) |
π¬ Usage Examples
Chat with Cursor or Claude:
Review GitHub PR
Review https://github.com/facebook/react/pull/12345Review GitLab MR
Review https://gitlab.com/group/project/-/merge_requests/678Review Self-hosted GitLab MR
Review https://gitlab.yourcompany.com/team/project/-/merge_requests/90Review 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-mcpThis 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-rulesAfter 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 --customThis 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.mdcfilesOr simply place a
.code-review-rules/directory in your project root (auto-discovered)The
get_review_rulestool returns both builtin and custom rulesAI assistants use these rules when performing reviews
Custom rules supplement (not replace) the builtin review guidelines
Environment Variable:
Variable | Description | Required |
| 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
Available Tools
7 toolsadd_inline_commentA
Add inline comment to a specific code line in PR/MR
Inputs: provider (required), repo (required), pr_id (required), file_path (required), +4 more.
add_pr_commentB
Add a general comment to PR/MR
Inputs: provider (required), repo (required), pr_id (required), comment (required), +1 more.
batch_add_commentsA
Batch add multiple inline comments and optionally a general comment
Inputs: provider (required), repo (required), pr_id (required), inline_comments (required), +2 more.
get_pr_changesARead-only
Get PR/MR code changes (diff) with optional file extension filtering
Inputs: provider (required), repo (required), pr_id (required), host, +1 more.
get_pr_infoARead-only
Get PR/MR detailed information including title, description, author, and branches
Inputs: provider (required), repo (required), pr_id (required), host.
get_review_rulesARead-only
Get code review rules (builtin + custom project rules). Call this before starting a review to load all applicable rules. Custom rules are loaded from CODE_REVIEW_RULES_DIR env var, or auto-discovered from .code-review-rules/ in the working directory.
Inputs: lang, include_builtin.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose: inline comments, general comments, batch comments, extracting PR links, getting PR changes, PR info, and review rules. No ambiguity.
All tool names follow a consistent verb_noun pattern (e.g., add_inline_comment, get_pr_changes), making them predictable and easy to understand.
Seven tools is well-scoped for a code review server, covering commenting, information retrieval, and rule loading without unnecessary bloat.
The tool set covers core review operations (viewing info, changes, adding comments, rules), but lacks edit/delete comment functionality, which is a minor gap.
Maintenance
Related MCP Connectors
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
AI-native git hosting β repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
AI code review for GitHub PRs with an MCP autofix loop for Claude Code and Cursor
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables automated GitHub Pull Request reviews using local Ollama, Cursor CLI, or Gemini CLI as AI providers. Supports customizable review prompts, comprehensive PR analysis, and optional auto-posting of reviews to GitHub.16 npm5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform comprehensive GitHub pull request code reviews, including analysis of code patterns, complexity, and security issues, while managing review comments and ensuring compliance with team coding standards.2MIT
- AlicenseBqualityDmaintenanceConnects 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.1018 npmISC

Selvageofficial
AlicenseNot gradedqualityDmaintenanceEnables AI-powered code review of Git diffs through natural language, supporting multiple AI models and Git workflows.28 PyPI36Apache 2.0