Code Review MCP server

Enables automated code reviews through multiple LLM providers by analyzing repository structures and evaluating code for security, performance, quality, and maintainability with structured output containing issues, strengths, and recommendations.
Back to servers
Setup instructions
Provider
Dennison Bertram
Release date
Mar 24, 2025
Language
TypeScript
Stats
19 stars

The MCP Server for Code Review is a specialized tool that leverages Repomix and Large Language Models to analyze and review code. It flattens codebases and provides structured feedback with specific issues and recommendations, supporting multiple LLM providers including OpenAI, Anthropic, and Gemini.

Installation

# Clone the repository
git clone https://github.com/yourusername/code-review-server.git
cd code-review-server

# Install dependencies
npm install

# Build the server
npm run build

Configuration

Create and edit a .env file in the root directory with your preferred LLM provider settings:

# Copy the example configuration
cp .env.example .env

Edit the .env file to set up your preferred LLM provider and API key:

# LLM Provider Configuration
LLM_PROVIDER=OPEN_AI
OPENAI_API_KEY=your_openai_api_key_here

Usage as an MCP Server

Start the server to make it available to any MCP client:

node build/index.js

Available Tools

The server exposes two main tools:

  1. analyze_repo: Flattens a codebase using Repomix
  2. code_review: Performs a detailed code review using an LLM

When to Use Each Tool

analyze_repo

Use this tool when you need:

  • A high-level overview of codebase structure
  • A flattened repository representation for initial analysis
  • Understanding of directory structure and file contents

Example scenarios:

  • Understanding a repository's structure before reviewing it
  • Viewing files and directories in a codebase
  • Getting a flattened view to understand code organization

code_review

Use this tool when you need:

  • Comprehensive code quality assessment
  • Identification of security vulnerabilities and performance issues
  • Actionable recommendations for code improvement
  • Detailed reviews with severity ratings

Example scenarios:

  • Reviewing for security vulnerabilities
  • Analyzing performance of JavaScript files
  • Getting detailed code quality assessments
  • Improving code maintainability

Available parameters:

  • specificFiles: Limit review to certain files
  • fileTypes: Focus on specific file extensions
  • detailLevel: Choose 'basic' or 'detailed' analysis
  • focusAreas: Prioritize aspects like security or performance

Using the CLI Tool

For testing purposes, you can use the included command-line tool:

node build/cli.js <repo_path> [options]

Options:

  • --files <file1,file2>: Specific files to review
  • --types <.js,.ts>: File types to include
  • --detail <basic|detailed>: Level of detail (default: detailed)
  • --focus <areas>: Focus areas (security,performance,quality,maintainability)

Example:

node build/cli.js ./my-project --types .js,.ts --detail detailed --focus security,quality

LLM Provider Configuration

The server supports multiple LLM providers that can be configured in your .env file:

# Set which provider to use
LLM_PROVIDER=OPEN_AI  # Options: OPEN_AI, ANTHROPIC, or GEMINI

# Provider API Keys (add your key for the chosen provider)
OPENAI_API_KEY=your-openai-api-key
ANTHROPIC_API_KEY=your-anthropic-api-key
GEMINI_API_KEY=your-gemini-api-key

# Optional: Override the default models
OPENAI_MODEL=gpt-4-turbo
ANTHROPIC_MODEL=claude-3-sonnet-20240229
GEMINI_MODEL=gemini-1.5-flash-preview

Default Models

  • OpenAI: gpt-4o
  • Anthropic: claude-3-opus-20240307
  • Gemini: gemini-1.5-pro

Code Review Output Format

Code reviews are returned in a structured JSON format:

{
  "summary": "Brief summary of the code and its purpose",
  "issues": [
    {
      "type": "SECURITY|PERFORMANCE|QUALITY|MAINTAINABILITY",
      "severity": "HIGH|MEDIUM|LOW",
      "description": "Description of the issue",
      "line_numbers": [12, 15],
      "recommendation": "Recommended fix"
    }
  ],
  "strengths": ["List of code strengths"],
  "recommendations": ["List of overall recommendations"]
}

The review provides clear insights into code quality with specific issues categorized by type and severity, along with actionable recommendations for improvement.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "code-review" '{"command":"node","args":["build/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "code-review": {
            "command": "node",
            "args": [
                "build/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "code-review": {
            "command": "node",
            "args": [
                "build/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later