MCP Code Reviewer MCP Server

$git clone https://github.com/whtan410/mcp_code_review.git cd mcp_code_review python -m venv .venv source .venv/bin/activate pip install -r requirements.txt cp .env.example .env
README.md

A powerful second-layer LLM MCP server that refines and reviews code using AI.

MCP Code Refiner

A powerful second-layer LLM MCP server that refines and reviews code using AI. Perfect for improving AI-generated code or enhancing human-written code through natural language feedback.

What is This?

This is an MCP (Model Context Protocol) server that adds code refinement and review capabilities to any MCP client like Claude Desktop. It acts as a "second layer" AI that specializes in code improvement, working alongside your primary AI assistant.

Use it to:

  • Refine code generated by ChatGPT, Claude, or any AI with natural language feedback
  • Get comprehensive code reviews with security and performance analysis
  • Iteratively improve code until it meets your standards
  • Learn from AI-suggested improvements

Features

  • Code Refinement - Improve code with natural language feedback ("make it more logical", "add error handling")
  • Code Review - AI-powered analysis for bugs, security, performance, and best practices
  • Multi-Model Support - Choose between Gemini, Claude, or OpenAI models
  • Plug & Play - Works with Claude Desktop and any MCP client
  • Smart Prompts - Optimized prompts for high-quality, actionable results
  • Diff View - See exactly what changes before applying them

Quick Start

Prerequisites

  • Python 3.10 or higher
  • At least one AI provider API key (Gemini recommended for free tier)

1. Clone and Install

git clone https://github.com/yourusername/mcp_code_review.git
cd mcp_code_review
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

2. Configure API Keys

Create a .env file from the example:

cp .env.example .env

Edit .env and add at least ONE API key:

# Recommended: Google Gemini (free tier available)
GOOGLE_API_KEY=your-gemini-api-key-here

# Alternative: Anthropic Claude
ANTHROPIC_API_KEY=your-anthropic-api-key-here

# Alternative: OpenAI
OPENAI_API_KEY=your-openai-api-key-here

Get API keys from:

3. Connect to Claude Desktop

Edit your Claude Desktop config file:

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

Add the server configuration:

{
  "mcpServers": {
    "code-refiner": {
      "command": "python",
      "args": ["/absolute/path/to/mcp_code_review/mcp_server.py"],
      "env": {
        "GOOGLE_API_KEY": "your-gemini-api-key"
      }
    }
  }
}

Important: Replace /absolute/path/to/mcp_code_review/ with the actual path on your system.

Restart Claude Desktop to load the server.

Usage

Once configured, just talk to Claude naturally in Claude Desktop. The tools are automatically available!

Code Refinement

Improve existing code with natural language instructions:

You: "Refine ./my_script.py to make it more logical and add error handling"

Claude will:

  1. Call refine_code_tool with your request
  2. Show you a diff of proposed changes
  3. Explain what was changed and why
  4. Ask for your approval
  5. Apply changes with apply_refinement_tool if you confirm

Code Review

Get comprehensive code analysis:

You: "Review ./server.py for security issues and performance problems"

Claude will:

  1. Call review_code_tool on the file
  2. Show issues found with severity levels (high/medium/low)
  3. Highlight code strengths
  4. Provide an overall quality score
  5. Suggest specific improvements

Real-World Examples

Refinement:

  • "Make ./app.py more performant by optimizing loops"
  • "Simplify the logic in ./utils/helper.py"
  • "Add comprehensive error handling to ./api/routes.py"
  • "Refactor ./legacy_code.py to follow modern Python best practices"
  • "Add type hints and docstrings to ./calculator.py"

Review:

  • "Review ./authentication.py for security vulnerabilities"
  • "Check ./database.py for SQL injection risks"
  • "Analyze ./api_client.py for error handling issues"
  • "Review ./main.py and suggest improvements"

Available Models

Configure via ai_provider parameter or Claude will use the default (gemini).

Gemini (Google)

  • gemini - Gemini 2.0 Flash (fast, free tier)
  • gemini-pro - Gemini 1.5 Pro (more capable)

Claude (Anthropic)

  • claude or claude-sonnet - Claude 3.5 Sonnet (high quality)
  • claude-opus - Claude 3 Opus (most capable)
  • claude-haiku - Claude 3.5 Haiku (fastest)

OpenAI

  • openai or gpt-4o - GPT-4o (balanced)
  • gpt-4 - GPT-4 Turbo
  • gpt-3.5 - GPT-3.5 Turbo (fastest)

MCP Tools Reference

This server provides three MCP tools that Claude Desktop can call automatically:

1. `refine_code_tool`

Purpose: Improves existing code based on natural language feedback using a second-layer LLM.

Parameters:

  • user_request (string, required) - What yo

Tools (3)

refine_code_toolImproves existing code based on natural language feedback using a second-layer LLM.
review_code_toolAI-powered analysis for bugs, security, performance, and best practices.
apply_refinement_toolApply proposed code changes after human confirmation.

Environment Variables

GOOGLE_API_KEYrequiredGoogle Gemini API key (recommended, free tier available)
ANTHROPIC_API_KEYAnthropic Claude API key (alternative)
OPENAI_API_KEYOpenAI API key (alternative)

Configuration

claude_desktop_config.json
{
  "mcpServers": {
    "code-refiner": {
      "command": "python",
      "args": ["/absolute/path/to/mcp_code_review/mcp_server.py"],
      "env": {
        "GOOGLE_API_KEY": "your-gemini-api-key"
      }
    }
  }
}

Try it

Refine ./my_script.py to make it more logical and add error handling
Review ./server.py for security issues and performance problems
Make ./app.py more performant by optimizing loops
Review ./authentication.py for security vulnerabilities
Simplify the logic in ./utils/helper.py

Frequently Asked Questions

How do I install MCP Code Reviewer?

Install MCP Code Reviewer by running: git clone https://github.com/whtan410/mcp_code_review.git cd mcp_code_review python -m venv .venv source .venv/bin/activate pip install -r requirements.txt cp .env.example .env

What MCP clients work with MCP Code Reviewer?

MCP Code Reviewer works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Use MCP Code Reviewer with Conare

Manage MCP servers visually, upload persistent context, and never start from zero with Claude Code & Codex.

Try Free