Skip to main content

MCP Server for GitHub/GitLab code review - enables AI assistants to review pull requests and merge requests

Project description

Code Review MCP Server

English | ไธญๆ–‡

PyPI version License: MIT Python 3.10+

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 uvx or pip
  • ๐Ÿณ 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

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

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
โ”‚       โ”œโ”€โ”€ server.py        # MCP server main logic
โ”‚       โ””โ”€โ”€ providers.py     # GitHub/GitLab providers
โ”œโ”€โ”€ .cursor/rules/           # Cursor review rules
โ”œโ”€โ”€ 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

๐ŸŽฏ Custom Review Rules

The included .cursor/rules/code-review.mdc is a general template. Copy to your project and customize:

cp -r .cursor/rules your-project/.cursor/

Customizable items:

  • Priority definitions
  • Checklist items
  • Comment format
  • Deduplication rules

๐Ÿค Contributing

Contributions welcome! See CONTRIBUTING.md for details.

๐Ÿ“„ License

MIT

๐Ÿ”— 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

code_review_mcp-1.0.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_review_mcp-1.0.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file code_review_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: code_review_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for code_review_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e01d76c60ffcc97ab967a8cfdeefb665c428d2d126b17dcae1110066898569d2
MD5 aacd816415b6eea9743284ae05706c68
BLAKE2b-256 a13194b1ebc35100f681143a8fc1679df9f07025aa1da4cad9ba4fa29b22a917

See more details on using hashes here.

File details

Details for the file code_review_mcp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: code_review_mcp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for code_review_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14208f9c7b7f9dc98de533e42694481ce09dc76e1d60b41e6d0675cf311013ea
MD5 372c6617ab8bd058b8428c60952ef544
BLAKE2b-256 10e1b5d6cd332196394b4c146b60f88459bb85ef9e269fd3b0f2763df9a06ff7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page