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
Installation
Configuration
Create a .env
file in the root directory based on the .env.example
template:
Edit the .env
file to set up your preferred LLM provider and API key:
Usage
As an MCP Server
The code review server implements the Model Context Protocol (MCP) and can be used with any MCP client:
The server exposes two main tools:
analyze_repo
: Flattens a codebase using Repomixcode_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 repositoryfileTypes
: 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 analysisfocusAreas
: When you want to prioritize certain aspects (security, performance, etc.)
Using the CLI Tool
For testing purposes, you can use the included CLI tool:
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:
Development
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:
Model Configuration
You can optionally specify which model to use for each provider:
How the LLM Integration Works
- The
code_review
tool processes code using Repomix to flatten the repository structure - The code is formatted and chunked if necessary to fit within LLM context limits
- A detailed prompt is generated based on the focus areas and detail level
- The prompt and code are sent directly to the LLM API of your chosen provider
- The LLM response is parsed into a structured format
- 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:
License
MIT
This server cannot be installed
An MCP server that performs automated code reviews by flattening repositories with Repomix and analyzing code using various LLM providers (OpenAI, Anthropic, Gemini) to deliver structured feedback on security, performance, quality, and maintainability.