code-reviewer-mcp
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-reviewer-mcp Review the changes on my branch"
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 Reviewer MCP Server
An MCP (Model Context Protocol) server that performs automated code reviews based on customizable reviewer personas. Integrates seamlessly with Cursor IDE and other MCP-compatible tools.
Overview
This server provides automated code review capabilities by analyzing git diffs against configurable review standards. It supports custom reviewer personas, making it easy to enforce team-specific code quality standards.
Related MCP server: pr-mcp-server
Features
The server exposes 7 tools:
Tool | Description |
| Get git diff between current branch and base branch |
| List files changed on current branch with stats |
| Get diff with review context and persona standards |
| Review a specific file against standards |
| View the active reviewer persona |
| Get the full review checklist |
| Generate a markdown review report file |
Custom Persona Support
All review tools accept a persona_file parameter to use a custom reviewer persona:
persona_file: "personas/example_persona.md"Default locations (checked in order):
personas/example_persona.mdin the MCP server directorynotebooks/code_reviewer_persona.mdin your project root (for backward compatibility)Embedded default persona (if no file found)
Example persona: See personas/example_persona.md for a complete example of a reviewer persona.
Installation
Prerequisites
Python 3.10+
uv (recommended) or pip
Setup
Install dependencies:
cd code-reviewer-mcp uv sync # or: pip install -r requirements.txtSet up the Cursor rule (optional but recommended):
Copy the template rule to your project's
.cursor/rules/directory:mkdir -p .cursor/rules cp tools/code-reviewer-mcp/.cursor/rules/code-review.mdc.template .cursor/rules/code-review.mdcThen customize it for your project's review standards.
Configure in Cursor by adding to
~/.cursor/mcp.json:{ "mcpServers": { "code-reviewer": { "command": "uv", "args": [ "--directory", "/path/to/code-reviewer-mcp", "run", "server.py" ] } } }Or if using pip:
{ "mcpServers": { "code-reviewer": { "command": "python", "args": [ "/path/to/code-reviewer-mcp/server.py" ] } } }
Architecture
The code reviewer consists of two components:
MCP Server (
server.py): Provides the tools (get_branch_diff,review_diff, etc.)Cursor Rule (
.cursor/rules/code-review.mdc): Provides workflow instructions and review standards
The MCP server is reusable across projects - it provides generic code review tools.
The Cursor rule is project-specific - it defines your team's review standards and workflow.
When you ask for a code review, the Cursor rule instructs the AI on:
Which MCP tools to call and in what order
What standards to check against
How to format the output
Usage in Cursor
Quick Start
Restart Cursor after installation to load the new MCP server
Ask Claude to review your code:
"Review my current branch"
"Review this PR against development"
"Check this file for issues"
Example Commands
Basic usage (uses default persona):
"Review the changes on my branch"
"Get the diff against development"
"Review src/my_module/file.py"
"Generate a code review report"With custom persona (using @ reference):
"Review my code using @personas/example_persona.md"
"Review this file using the persona at @path/to/strict_reviewer.md"
"Generate a review report with @personas/example_persona.md"The @file syntax in Cursor expands the file reference, making it easy to
select different reviewer personas for different review styles.
Using the Cursor Rule
A Cursor rule at .cursor/rules/code-review.mdc automatically triggers
the reviewer when you say "review", "code review", or "PR review".
What the rule does:
Provides step-by-step workflow instructions for using the MCP tools
Defines the review standards and checklist (type safety, documentation, etc.)
Specifies the output format for reviews
Handles persona file selection via
@syntax
For this project: The rule is located at .cursor/rules/code-review.mdc in the repo root.
For other projects: A template rule file is included at tools/code-reviewer-mcp/.cursor/rules/code-review.mdc.template. Copy it to your project's .cursor/rules/ directory and customize it for your team's standards.
The rule provides:
Workflow instructions: Step-by-step guide on how to use the MCP tools
Review standards: Checklist of what to check (can be customized per project)
Output format: Structure for review comments
Integration guidance: How to combine with Bitbucket MCP for PR comments
Persona Files
How Persona Selection Works
Explicit selection: Pass
persona_fileparameter with the pathDefault locations (checked in order):
personas/example_persona.mdin the MCP server directorynotebooks/code_reviewer_persona.mdin your project root (for backward compatibility)
Embedded fallback: Uses built-in persona if no file found
Example persona: See personas/example_persona.md for a complete example based on real code review patterns.
Creating a Custom Persona
Create a markdown file with your review standards. Example structure:
# Code Reviewer Persona: [Name]
## Review Philosophy
[Your approach to code review]
## Key Standards
### Type Safety
- [Your type checking rules]
### Documentation
- [Your documentation requirements]
### Code Style
- [Your style preferences]
## Common Callouts
- "Missing type hint" → Add type annotations
- "No tests" → Add test coverageSwitching Personas
You can have multiple persona files for different contexts. Store them in the personas/ directory:
personas/example_persona.md- Example persona (included with this repo)personas/strict_reviewer.md- For production code (create your own)personas/junior_friendly.md- Educational, more explanatory (create your own)personas/security_focused.md- Emphasis on security patterns (create your own)
Start with personas/example_persona.md and customize it for your team's needs.
Default Review Standards
The embedded default persona checks for:
Type Safety
Complete type hints on all functions
Modern syntax (
str | NoneoverOptional)No
Anytypes without justification
Documentation
File headers with copyright
Complete docstrings with Args/Returns
Code Organization
Absolute imports only
Magic numbers as constants
Unused code removed
Error Handling
Specific exceptions only
Edge cases handled
Architecture
Layer separation maintained
Common logic in templates
Utilities
Export PR Comments
The utils/export_comments.py script helps export your Bitbucket PR comments to CSV for analysis
or building training data for code review personas.
Usage:
# Set environment variables (recommended)
export ATLASSIAN_EMAIL="your-email@example.com"
export BITBUCKET_API_TOKEN="your-api-token"
export BITBUCKET_WORKSPACE="your-workspace"
export BITBUCKET_REPO_SLUG="your-repo"
export BITBUCKET_ACCOUNT_ID="your-account-id" # Optional: filter to your comments only
# Export comments (from the code-reviewer-mcp directory)
python utils/export_comments.py
# Export only your comments (with account ID filter)
python utils/export_comments.py --account-id your-account-id
# Export all comments (no filter)
python utils/export_comments.py --account-id ""
# Or pass everything as arguments
python utils/export_comments.py \
--email your-email@example.com \
--token your-token \
--workspace your-workspace \
--repo your-repo \
--output my_comments.csv \
--account-id your-account-idNote: This utility requires the requests library. Install with:
pip install requests
# or
uv add requestsOutput: The script generates a CSV file with columns:
pr_id,pr_title,pr_urlcomment_id,contentfile_path,line(for inline comments)created_on,updated_on
Development
Testing the Server
cd code-reviewer-mcp
uv run server.pyThe server communicates via stdio, so you'll see it waiting for JSON-RPC messages.
Modifying the Persona
The reviewer persona is embedded in server.py in the REVIEWER_PERSONA constant.
Update this to change review standards.
Limitations
No inline comments: Cursor doesn't have an API to programmatically add inline comments to files. The server outputs reviews with file:line references that you can navigate to.
Python-focused: Currently filters for
*.pyfiles by default. Thefile_filterparameter can be changed to include other file types.
Troubleshooting
Server not appearing in Cursor
Check
~/.cursor/mcp.jsonhas the correct pathRestart Cursor completely (Cmd+Q on macOS)
Check the MCP logs:
~/Library/Logs/Claude/mcp*.log
Git errors
Ensure you're in a git repository when using the diff-related tools. The server needs access to git commands.
Optional: Bitbucket Integration
For teams using Bitbucket, you can optionally configure the @lexmata/bitbucket-mcp server
to enable programmatic PR comment creation. This allows you to post review comments
directly to Bitbucket pull requests.
Setting up Bitbucket MCP
Install the Bitbucket MCP server (if not already installed):
npm install -g @lexmata/bitbucket-mcpConfigure in
~/.cursor/mcp.json:{ "mcpServers": { "code-reviewer": { "command": "uv", "args": ["--directory", "/path/to/code-reviewer-mcp", "run", "server.py"] }, "bitbucket": { "command": "npx", "args": ["-y", "@lexmata/bitbucket-mcp"], "env": { "BITBUCKET_WORKSPACE": "your-workspace", "BITBUCKET_REPO_SLUG": "your-repo", "BITBUCKET_APP_PASSWORD": "your-app-password" } } } }Usage: Once configured, you can use Bitbucket MCP tools alongside the code reviewer:
Create PR comments programmatically
Fetch PR details
Post review feedback directly to Bitbucket
Example workflow:
1. Use code-reviewer tools to generate review feedback 2. Use bitbucket-mcp tools to post comments to the PRNote: This integration is optional. The code reviewer works perfectly fine without it, generating review reports that you can manually copy to PR comments.
Available Tools
7 toolsgenerate_review_reportB
Generate a comprehensive code review report as a markdown file.
Args: base_branch: The base branch to compare against (default: development). output_file: Path to write the report (default: .code_review.md in repo root). working_directory: Working directory (defaults to current directory). persona_file: Path to a custom reviewer persona markdown file. Example: "notebooks/code_reviewer_persona.md" If not provided, uses the default persona.
Returns: Path to the generated report file and a summary.
Inputs: base_branch, output_file, persona_file, working_directory. Returns: result
get_branch_diffC
Get the git diff between the current branch and a base branch.
Args: base_branch: The base branch to compare against (default: development). file_filter: File pattern to filter (default: *.py for Python files). working_directory: Working directory (defaults to current directory).
Returns: The git diff output showing changes on the current branch.
Inputs: base_branch, file_filter, working_directory. Returns: result
get_changed_filesA
Get a list of changed files on the current branch.
Args: base_branch: The base branch to compare against (default: development). file_filter: File pattern to filter (default: *.py for Python files). working_directory: Working directory (defaults to current directory).
Returns: List of changed file paths with change statistics.
Inputs: base_branch, file_filter, working_directory. Returns: result
get_personaA
Get the code reviewer persona that will be used for reviews.
Use this to view or verify the persona before running a review.
Args: persona_file: Path to a custom reviewer persona markdown file. Example: "notebooks/code_reviewer_persona.md" If not provided, uses the default persona. working_directory: Working directory (defaults to current directory).
Returns: The full persona content that will be used for code reviews.
Inputs: persona_file, working_directory. Returns: result
get_review_checklistB
Get the full code review checklist based on the persona.
Returns: A comprehensive checklist for manual code review.
Inputs: no named parameters. Returns: result
review_diffA
Review the git diff against the code review persona standards.
This tool analyzes the diff between your current branch and the base branch, then provides structured feedback based on the team's code review standards.
Args: base_branch: The base branch to compare against (default: development). working_directory: Working directory (defaults to current directory). focus_areas: Comma-separated focus areas: 'types', 'docs', 'style', 'errors', 'performance', 'architecture', or 'all'. persona_file: Path to a custom reviewer persona markdown file. Example: "notebooks/code_reviewer_persona.md" If not provided, uses the default persona.
Returns: A structured code review with comments organized by file and category.
Inputs: base_branch, focus_areas, persona_file, working_directory. Returns: result
review_fileB
Review a specific file against the code review persona standards.
Args: file_path: Path to the file to review (relative or absolute). working_directory: Working directory (defaults to current directory). persona_file: Path to a custom reviewer persona markdown file. Example: "notebooks/code_reviewer_persona.md" If not provided, uses the default persona.
Returns: Code review feedback for the specified file.
Inputs: file_path (required), persona_file, working_directory. Returns: result
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 targets a distinct artifact (diff, file list, checklist, persona, diff review, file review, report), and descriptions clarify boundaries. The only mild overlap is between review_diff and review_file, but they differ on scope (whole diff vs single file) so agents can still select correctly.
All names are snake_case and follow a predictable verb_noun pattern (get_*, review_*, generate_*). The convention is applied uniformly across all seven tools with no deviations.
Seven tools is well-scoped for a code review server, and each earns its place by covering a distinct step in the review workflow (gather, inspect, review, report). No redundancy or filler.
The surface covers the full local review lifecycle: diff retrieval, changed files, checklist, persona inspection, diff/file review, and report generation. Minor gaps exist around acting on results (e.g. posting comments to a PR or reviewing a commit range), but core workflows are complete.
Maintenance
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
An MCP server that automatically collects feedback on your MCP server.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that automates code reviews through linting, testing, and git diff analysis. It also generates conventional commit messages and detailed pull request descriptions based on file changes and code patterns.ISC
- AlicenseAqualityDmaintenanceMCP server to automate Pull Request creation with AI. Analyzes Git branches, generates descriptions, titles, suggests reviewers, and performs code reviews.84MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides AI-powered code review and architecture analysis, simulating the perspective of an experienced staff engineer. It integrates with IDEs to review diffs, design decisions, and tradeoffs through natural language.1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for automated code review using AI agents. It analyzes code diffs or file paths for bugs, security issues, and style violations.MIT