Skip to main content
Glama
praneybehl

Claude Code Review MCP

by praneybehl

克劳德代码评审-MCP

一个 MCP(模型上下文协议)服务器,使用 OpenAI、Google 和 Anthropic 模型提供代码审查功能。它作为代码审查的“第二意见”工具,可与任何 MCP 客户端(包括 Claude Code、Claude Desktop、Cursor 和 Windsurf)配合使用。

特征

  • 多提供商支持:利用 OpenAI、Google 的 Gemini 和 Anthropic 的 Claude 模型进行代码审查

  • 两种评审类型:选择结构化评审(包含分类反馈)或自由形式的叙述评审

  • 上下文感知:包括项目结构、相关文件、提交消息和依赖项,以便进行更相关的审查

  • 智能代码处理:自动检测编程语言、处理大文件并适当格式化输出

  • 强大的错误处理:包括 API 故障的重试逻辑和优雅的错误恢复

  • MCP 兼容:可与任何 MCP 客户端(Claude Code、Claude Desktop、Cursor、Windsurf)配合使用

  • 轻松设置:通过环境变量进行简单配置

Related MCP server: mcp-agent-review

安装

全局安装

npm install -g claude-code-review-mcp

与 npx 一起使用(无需安装)

# Set environment variables separately
export OPENAI_API_KEY=<key>
npx -y claude-code-review-mcp

# Or use inline environment setting
OPENAI_API_KEY=<key> npx -y claude-code-review-mcp

# Or with Google API key
GOOGLE_API_KEY=<key> npx -y claude-code-review-mcp

# Or with Anthropic API key
ANTHROPIC_API_KEY=<key> npx -y claude-code-review-mcp

# Or use multiple API keys for more model options
OPENAI_API_KEY=<key> GOOGLE_API_KEY=<key> ANTHROPIC_API_KEY=<key> npx -y claude-code-review-mcp

配置

服务器至少需要以下 API 密钥之一:

  • OPENAI_API_KEY :您的 OpenAI API 密钥

  • GOOGLE_API_KEY :您的 Google Gemini API 密钥

  • ANTHROPIC_API_KEY :您的 Anthropic API 密钥

可选配置:

  • PORT :服务器端口(默认:动态 - 将选择可用端口)

  • HOST :服务器主机(默认值:127.0.0.1)

  • LOG_LEVEL :日志级别(0=DEBUG、1=INFO、2=WARN、3=ERROR;默认值:1)

可用型号

OpenAI 模型(需要 OPENAI_API_KEY)

  • gpt-4.1 - OpenAI GPT-4.1

  • o4-mini ——OpenAI O4 Mini

  • o3-mini ——OpenAI O3 Mini

Google 模型(需要 GOOGLE_API_KEY)

  • gemini-2.5-pro-preview-05-06 - Google Gemini 2.5 Pro

  • gemini-2.5-flash-preview-04-17 - Google Gemini 2.5 Flash

人择模型(需要 ANTHROPIC_API_KEY)

  • claude-3-opus-20240229 - 人类学克劳德 3 作品

  • claude-3-sonnet-20240229 - 人性的克劳德 3 首十四行诗

  • claude-3-haiku-20240307 - 人类学克劳德 3 俳句

可用工具

MCP 服务器提供了三种工具:

1. reviewCodeStructured

提供详细、结构化的代码审查,包括以下部分:

  • 总体摘要

  • 代码质量(优势和劣势)

  • 错误(严重程度和建议的修复)

  • 改进建议

  • 安全问题(如果有)

2. reviewCodeFreeform

以自由格式的文本格式提供叙述性代码审查,适合一般印象和对话反馈。

3. 列表模型

根据提供的 API 密钥列出所有可用的模型,包括模型 ID 和人类可读的名称。

与 Claude Code 集成

要将此 MCP 服务器添加到 Claude 代码:

# Use environment variables properly (recommended approach)
claude mcp add code-review -s user -e OPENAI_API_KEY=<key> -e GOOGLE_API_KEY=<key> -e ANTHROPIC_API_KEY=<key> -- npx -y claude-code-review-mcp

# Alternative: Export the variables before adding the MCP
export OPENAI_API_KEY=<key>
export GOOGLE_API_KEY=<key>
export ANTHROPIC_API_KEY=<key>
claude mcp add code-review -s user -- npx -y claude-code-review-mcp

您还可以通过在.claude/commands/review-with.md创建文件来创建自定义斜线命令:

I'll review your code using alternative LLM models. Model to use: $ARGUMENTS

Claude Code 支持自定义斜线命令,您可以创建这些命令以便轻松与 MCP 服务器交互。在项目的.claude/commands/目录中创建这些命令,即可启用强大的代码审查工作流程。

基本设置

首先,如果命令目录不存在,则创建它:

mkdir -p .claude/commands

模型列表命令

创建一个命令来列出可用的模型:

# Create the list-review-models.md file
cat > .claude/commands/list-review-models.md << 'EOF'
I'll check which alternative code review models are available through our MCP server.

First, I'll use the MCP server to list all available models for code review.
After that, I'll present the models in a clear table format with:
- Model ID (what you'll use when requesting a review)
- Provider (OpenAI or Google)
- Description (size and capabilities)
- Speed (relative performance)

This will help you choose the right model for your code review needs.
EOF

基本代码审查命令

创建一个接受模型名称的简单审查命令:

# Create the review-with.md file
cat > .claude/commands/review-with.md << 'EOF'
I'll review the code I've just worked on using an alternative LLM model to provide a second opinion.

First, I'll identify the code changes or file you want reviewed. If you don't specify a file, I'll look at recent changes.

Then, I'll send this code to be reviewed by the specified model through our MCP server.

Available models (run /project:list-review-models to see all options):
- OpenAI models (if configured): "gpt-4.1", "o4-mini", "o3-mini"
- Google models (if configured): "gemini-2.5-pro-preview-05-06", "gemini-2.5-flash-preview-04-17"

Model to use (leave blank for default): $ARGUMENTS
EOF

结构化审查指挥部

创建一个专门用于结构化评论的命令:

# Create the structured-review.md file
cat > .claude/commands/structured-review.md << 'EOF'
I'll perform a structured code review using an alternative LLM model.

This review will be organized into clear sections:
1. Overall summary
2. Code quality assessment (strengths and weaknesses)
3. Potential bugs with severity ratings (Low/Medium/High)
4. Specific improvement suggestions
5. Security considerations (if applicable)

If you don't specify a model, I'll use the default available model.

Model to use (optional): $ARGUMENTS
EOF

自由格式审阅命令

为叙述式评论创建命令:

# Create the freeform-review.md file
cat > .claude/commands/freeform-review.md << 'EOF'
I'll provide a conversational, narrative-style code review using an alternative LLM model.

This will be a more holistic assessment of your code with flowing paragraphs rather than structured categories. This style works well for:
- General impressions
- High-level feedback
- More nuanced commentary on code style and approach

If you don't specify a model, I'll use the default available model.

Model to use (optional): $ARGUMENTS
EOF

审查特定文件命令

创建一个命令来审查特定文件:

# Create the review-file.md file
cat > .claude/commands/review-file.md << 'EOF'
I'll review a specific file using an alternative LLM model.

Please provide the file path to review and optionally the model to use.
Format: [file_path] [model_name]

For example:
- "src/utils.js gemini-2.5-pro-preview-05-06" - Reviews utils.js with Gemini Pro
- "lib/auth.ts" - Reviews auth.ts with the default model

Input: $ARGUMENTS
EOF

特定焦点的审查命令

创建专门的审核命令:

# Create security review command
cat > .claude/commands/security-review.md << 'EOF'
I'll perform a security-focused code review using an alternative LLM model.

This review will specifically examine:
- Potential security vulnerabilities
- Input validation issues
- Authentication/authorization flaws
- Data protection concerns
- Injection vulnerabilities
- Secure coding best practices

If you don't specify a model, I'll use a model recommended for security analysis.

Model to use (optional): $ARGUMENTS
EOF
# Create performance review command
cat > .claude/commands/performance-review.md << 'EOF'
I'll perform a performance-focused code review using an alternative LLM model.

This review will specifically examine:
- Algorithm efficiency
- Memory usage
- Unnecessary computations
- Loop optimizations
- Data structure choices
- Caching opportunities
- Async/parallel processing considerations

If you don't specify a model, I'll use a model that's good at performance analysis.

Model to use (optional): $ARGUMENTS
EOF

综合项目审查指挥部

创建一个用于审查具有完整项目上下文的代码的命令:

# Create the project-review.md file
cat > .claude/commands/project-review.md << 'EOF'
I'll perform a comprehensive code review with full project context using an alternative LLM model.

This review will:
1. Analyze the code structure and organization
2. Consider related files and dependencies
3. Evaluate consistency with project patterns
4. Assess integration with existing components
5. Check alignment with project architecture

I'll gather project context, including directory structure and related files, to ensure a thorough, context-aware review.

Format: [file_to_review] [model_name]
Example: "src/components/Button.jsx gemini-2.5-pro-preview-05-06"

Input: $ARGUMENTS
EOF

前后审查命令

创建一个命令来比较代码变化:

# Create the diff-review.md file
cat > .claude/commands/diff-review.md << 'EOF'
I'll review the changes you've made to a file using an alternative LLM model.

This will:
1. Identify what was changed between versions
2. Evaluate if the changes address the intended purpose
3. Check for any new issues introduced
4. Suggest potential improvements to the changes

I'll need to know which file to examine. If you've been working on a file with Claude Code, I'll automatically find the changes.

Model to use (optional): $ARGUMENTS
EOF

使用自定义斜线命令

创建这些命令后,您可以在 Claude Code 中输入/project:后跟命令名称来使用它们。例如:

/project:list-review-models
/project:review-with gemini-2.5-pro-preview-05-06
/project:structured-review o4-mini
/project:security-review
/project:review-file src/utils.js gemini-2.5-flash-preview-04-17

自定义命令的提示

  • 命令发现:在 Claude Code 中输入/project:来查看可用命令列表

  • 默认模型:如果您未指定模型,则命令将使用默认模型(如果可用,通常为 o4-mini)

  • 多重评论:您可以通过使用不同的模型运行评论来获得多种视角

  • 项目背景:对于最相关的评论,使用包含项目背景的命令

  • 专业焦点:当您特别关注安全性、性能等时,请使用特定焦点的命令。

示例工作流程

典型的工作流程可能如下所示:

  1. 使用 Claude Code 编写代码

  2. 运行/project:list-review-models查看可用选项

  3. 运行/project:structured-review gemini-2.5-pro-preview-05-06以获取来自 Google 模型的结构化评论

  4. 与克劳德的建议进行比较

  5. 从两个角度进行改进

  6. 运行/project:diff-review来查看更改

这些自定义命令使 Claude Code 和 claude-code-review-mcp 服务器能够顺利集成,为您的代码提供宝贵的“第二意见”。

示例用法

启动 MCP 服务器

# Start with OpenAI API key (using exports, recommended)
export OPENAI_API_KEY=<key>
npx -y claude-code-review-mcp

# Or with inline environment variables
OPENAI_API_KEY=<key> npx -y claude-code-review-mcp

# Start with Google Gemini API key
export GOOGLE_API_KEY=<key>
npx -y claude-code-review-mcp

# Start with Anthropic Claude API key
export ANTHROPIC_API_KEY=<key>
npx -y claude-code-review-mcp

# Use multiple API keys for more model options
export OPENAI_API_KEY=<key>
export GOOGLE_API_KEY=<key>
export ANTHROPIC_API_KEY=<key>
npx -y claude-code-review-mcp

# Use custom port and host
export OPENAI_API_KEY=<key>
export PORT=8080 
export HOST=0.0.0.0
npx -y claude-code-review-mcp

与 MCP 客户端一起使用

服务器启动后,您可以使用服务器的 URL 从任何 MCP 客户端(例如 Claude Code、Claude Desktop、Cursor 或 Windsurf)连接到服务器。服务器会在启动日志中显示实际的 URL 和端口(使用动态分配的端口以避免冲突)。

输入模式

所有审查工具均接受以下输入:

{
  code: string;  // Required: The code to review
  filename?: string;  // Optional: The filename with extension
  language?: string;  // Optional: Programming language
  model: string;  // Required: Model ID to use for review
  projectContext?: {  // Optional: Additional context
    projectStructure?: string;  // Directory structure
    relatedFiles?: Array<{  // Related code files
      name: string;  // Filename with path
      language?: string;  // File language
      content: string;  // File content
    }>;
    commitMessage?: string;  // Purpose of changes
    dependencies?: Record<string, string>;  // Project dependencies
  }
}

输出架构

结构化评审输出

{
  review?: {  // Present on success
    summary: string;  // Overall assessment
    quality: {
      strengths: string[];  // Good aspects
      weaknesses: string[];  // Areas for improvement
    };
    bugs: Array<{
      description: string;  // Issue description
      severity: "Low" | "Medium" | "High";  // Impact level
      suggestion: string;  // How to fix
    }>;
    improvements: string[];  // Enhancement suggestions
    securityIssues?: string[];  // Security concerns if any
  };
  modelUsed: string;  // Human-readable model name
  error?: string;  // Present on error
  availableModels?: Record<string, string>;  // Present on error or listModels
}

自由格式审阅输出

{
  reviewText?: string;  // Present on success
  modelUsed: string;  // Human-readable model name
  error?: string;  // Present on error
  availableModels?: Record<string, string>;  // Present on error or listModels
}

列出模型输出

{
  availableModels: Record<string, string>;  // Model ID to name mapping
  modelUsed: string;  // Always "None" for this tool
}

MCP 客户端集成

克劳德·科德

  1. 添加 MCP 服务器:

claude mcp add code-review -s user npx -y claude-code-review-mcp
  1. 在克劳德代码中的使用:

/code-review:reviewCodeStructured --model o4-mini

克劳德桌面

在 Claude Desktop 设置中,按如下方式配置 MCP:

"claude-code-review-mcp": {
  "command": "npx",
  "args": ["-y", "claude-code-review-mcp"],
  "env": {
    "OPENAI_API_KEY": "your-openai-key",
    "GOOGLE_API_KEY": "your-google-key",
    "ANTHROPIC_API_KEY": "your-anthropic-key"
  }
}

该服务器使用先进的 JSON 输出清理技术,与所有 MCP 客户端(包括 Claude Desktop)完全兼容。

光标和风帆冲浪

遵循客户端的特定 MCP 配置指南,使用相同的命令和环境变量。

故障排除

API 密钥问题

  • “Model X 不可用” :确保您已为该模型提供了适当的 API 密钥。

  • 未提供 API 密钥:您必须提供 OPENAI_API_KEY、GOOGLE_API_KEY 或 ANTHROPIC_API_KEY 中的至少一个。

  • 建议型号:如果您请求的型号不可用,服务器将建议替代型号。

速率限制和 API 错误

  • 如果您遇到速率限制或 API 错误,错误消息将会指出该问题。

  • 如果一个提供商遇到问题,请考虑使用不同的模型。

安全注意事项

  • API 密钥永远不会被记录或暴露

  • 为保护隐私,代码内容仅被最低限度记录

  • 保持最小依赖性以减少安全面

  • 请求处理包括输入验证和清理

  • 错误消息旨在避免泄露敏感信息

兼容性

  • 需要 Node.js 18.0.0 或更高版本

  • 适用于 Linux、macOS 和 Windows(如有必要,可通过 WSL)

  • 与所有 MCP 客户端兼容(Claude Code、Claude Desktop、Cursor、Windsurf)

  • 优雅地处理大型代码文件和项目上下文

  • 暂时性 API 故障的自动重试机制

发展

# Install dependencies
npm install

# Start in development mode
npm run dev

# Build for production
npm run build

# Start in production mode
npm run start

执照

麻省理工学院

贡献者

  • Praney Behl(@praneybehl)

Available Tools

1 tool
perform_code_reviewA

Performs a code review using a specified LLM on git changes. Requires being run from the root of a git repository.

ParametersJSON Schema
NameRequiredDescriptionDefault
targetYesThe git target to review (e.g., 'staged', 'HEAD', or 'branch_diff').
taskDescriptionYesDescription of the task/feature/bugfix that led to these code changes.
llmProviderYesThe LLM provider to use (google, openai, anthropic).
modelNameYesThe specific model name from the provider (e.g., 'gemini-2.5-pro-preview-05-06', 'o4-mini', 'claude-3-7-sonnet-20250219').
reviewFocusNoSpecific areas or aspects to focus the review on (e.g., 'security vulnerabilities', 'performance optimizations', 'adherence to SOLID principles').
projectContextNoGeneral context about the project, its architecture, or coding standards.
diffBaseNoFor 'branch_diff' target, the base branch or commit SHA to compare against (e.g., 'main', 'develop', 'specific-commit-sha'). Required if target is 'branch_diff'.
maxTokensNoMaximum number of tokens to use for the LLM response. Defaults to 32000 if not specified.

TDQS

A3.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While it mentions the git repository requirement, it doesn't describe what the tool actually does behaviorally - whether it makes API calls to LLMs, what format the review output takes, whether it modifies files, or any rate limits/authentication needs. For a complex 8-parameter tool with no annotations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just two sentences that both earn their place. The first sentence states the core purpose, and the second provides essential operational context. There's zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 8 parameters performing code review via LLMs, the description is insufficiently complete. With no annotations, no output schema, and no behavioral details, it leaves critical gaps about what the tool actually produces, how it behaves, and what the user should expect. The description should explain the review output format and operational behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides no parameter-specific information beyond the git context hint. However, with 100% schema description coverage where all 8 parameters have clear descriptions in the schema itself, the baseline score of 3 is appropriate. The description doesn't add value beyond what's already documented in the structured schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('performs a code review') and resources ('using a specified LLM on git changes'). It distinguishes the tool's scope by specifying it works on git changes and requires being run from a git repository root, making it highly specific even without sibling tools for comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use the tool ('requires being run from the root of a git repository'), which is essential operational guidance. However, it doesn't mention when NOT to use it or suggest alternatives, which would be needed for a perfect score since there are no sibling tools to differentiate from.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool update
    • First observedperform_code_review

TDQS

A3.6/5.0
Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined and distinct by default.

Naming Consistency5/5

A single tool inherently has perfect naming consistency, as there are no other tools to compare it against. The name 'perform_code_review' follows a clear verb_noun pattern.

Tool Count2/5

A single tool for a code review server feels thin and incomplete for the domain. While it covers the core action, typical code review workflows might include additional operations like listing reviews, commenting, or approving changes.

Completeness2/5

The server is severely incomplete for code review functionality. It only performs reviews but lacks tools for managing reviews (e.g., get, update, delete), interacting with review comments, or handling review states, which are essential for a full code review workflow.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/praneybehl/code-review-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server