Skip to main content
Glama
Code Review MCP Server

Code Review MCP Server

Code Review Server

A custom MCP server that performs code reviews using Repomix and LLMs.

Features

  • Flatten codebases using Repomix

  • Analyze code with Large Language Models

  • Get structured code reviews with specific issues and recommendations

  • Support for multiple LLM providers (OpenAI, Anthropic, Gemini)

  • Handles chunking for large codebases

Related MCP server: Code Review MCP Server

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 a .env file in the root directory based on the .env.example template:

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

The code review server implements the Model Context Protocol (MCP) and can be used with any MCP client:

# Start the server
node build/index.js

The server exposes two main tools:

  1. analyze_repo: Flattens a codebase using Repomix

  2. code_review: Performs a code review using an LLM

When to Use MCP Tools

This server provides two distinct tools for different code analysis needs:

analyze_repo

Use this tool when you need to:

  • Get a high-level overview of a codebase's structure and organization

  • Flatten a repository into a textual representation for initial analysis

  • Understand the directory structure and file contents without detailed review

  • Prepare for a more in-depth code review

  • Quickly scan a codebase to identify relevant files for further analysis

Example situations:

  • "I want to understand the structure of this repository before reviewing it"

  • "Show me what files and directories are in this codebase"

  • "Give me a flattened view of the code to understand its organization"

code_review

Use this tool when you need to:

  • Perform a comprehensive code quality assessment

  • Identify specific security vulnerabilities, performance bottlenecks, or code quality issues

  • Get actionable recommendations for improving code

  • Conduct a detailed review with severity ratings for issues

  • Evaluate a codebase against best practices

Example situations:

  • "Review this codebase for security vulnerabilities"

  • "Analyze the performance of these specific JavaScript files"

  • "Give me a detailed code quality assessment of this repository"

  • "Review my code and tell me how to improve its maintainability"

When to use parameters:

  • specificFiles: When you only want to review certain files, not the entire repository

  • fileTypes: When you want to focus on specific file extensions (e.g., .js, .ts)

  • detailLevel: Use 'basic' for a quick overview or 'detailed' for in-depth analysis

  • focusAreas: When you want to prioritize certain aspects (security, performance, etc.)

Using the CLI Tool

For testing purposes, you can use the included CLI tool:

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

Options:

  • --files <file1,file2>: Specific files to review

  • --types <.js,.ts>: File types to include in the review

  • --detail <basic|detailed>: Level of detail (default: detailed)

  • --focus <areas>: Areas to focus on (security,performance,quality,maintainability)

Example:

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

Development

# Run tests
npm test

# Watch mode for development
npm run watch

# Run the MCP inspector tool
npm run inspector

LLM Integration

The code review server integrates directly with multiple LLM provider APIs:

  • OpenAI (default: gpt-4o)

  • Anthropic (default: claude-3-opus-20240307)

  • Gemini (default: gemini-1.5-pro)

Provider Configuration

Configure your preferred LLM provider in the .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

Model Configuration

You can optionally specify which model to use for each provider:

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

How the LLM Integration Works

  1. The code_review tool processes code using Repomix to flatten the repository structure

  2. The code is formatted and chunked if necessary to fit within LLM context limits

  3. A detailed prompt is generated based on the focus areas and detail level

  4. The prompt and code are sent directly to the LLM API of your chosen provider

  5. The LLM response is parsed into a structured format

  6. The review is returned as a JSON object with issues, strengths, and recommendations

The implementation includes retry logic for resilience against API errors and proper formatting to ensure the most relevant code is included in the review.

Code Review Output Format

The code review is 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"]
}

License

MIT

Available Tools

2 tools
analyze_repoA

Use this tool when you need to analyze a code repository structure without performing a detailed review. This tool flattens the repository into a textual representation and is ideal for getting a high-level overview of code organization, directory structure, and file contents. Use it before code_review when you need to understand the codebase structure first, or when a full code review is not needed.

Inputs: repoPath (required), specificFiles, fileTypes.

code_reviewA

Use this tool when you need a comprehensive code review with specific feedback on code quality, security issues, performance problems, and maintainability concerns. This tool performs in-depth analysis on a repository or specific files and returns structured results including issues found, their severity, recommendations for fixes, and overall strengths of the codebase. Use it when you need actionable insights to improve code quality or when evaluating a codebase for potential problems.

Inputs: repoPath (required), specificFiles, fileTypes, detailLevel, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: analyze_repo provides a high-level structural overview, while code_review offers detailed analysis with specific feedback. There is no overlap in functionality, and the descriptions explicitly differentiate when to use each tool.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun naming pattern (analyze_repo and code_review), using snake_case throughout. The naming is predictable and aligns well with their described functionalities.

    Tool Count2/5

    With only 2 tools, the server feels thin for a 'Code Review MCP Server' domain. While the tools cover analysis and review, the scope suggests potential gaps in operations like managing reviews, tracking issues, or integrating with version control, making the set appear incomplete for the stated purpose.

    Completeness2/5

    The tool set is severely incomplete for code review workflows. It lacks essential operations such as creating, updating, or deleting reviews; commenting on code; or handling pull requests. Agents will face dead ends when trying to perform common code review tasks beyond basic analysis.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables comprehensive codebase analysis using Google's Gemini AI through CLI integration. Provides architectural reviews and targeted code analysis with code2prompt integration for efficient context extraction.
      2
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Connects 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.
      10
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI-powered, zero-trust code review with multiple models, supporting single files, git diffs, and multiple files, with security, performance, and architecture checks across 10+ languages.
      15
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI-powered code review and improvement, including analysis, refactoring suggestions, and automatic test generation, with an optional agentic loop for iterative refinement.
      MIT