代码审查服务

一个集成多AI模型的代码审查工具,自动检测安全漏洞、设计问题和性能问题,适用于多种编程语言。

  • by je4550
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 je4550/review-mcp

使用说明

审查MCP服务器

利用集成到Claude Code中的多个AI模型,获取专业代码审查。自动捕捉漏洞、安全问题和设计缺陷。

快速入门

git clone https://github.com/je4550/review-mcp.git
cd review-mcp
npm install
npm run build

配置Claude代码 - 添加到 ~/.config/claude-code/mcp.json:

{
  "mcpServers": {
    "review-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/review-mcp/dist/index.js"]
    }
  }
}

设置一个审阅者命令行界面(CLI) (至少一个):

# Option 1: Codex CLI (recommended)
codex --version  # If you already have it

# Option 2: OpenAI CLI
npm install -g openai
# No API key needed if logged in with ChatGPT subscription
# Otherwise: export OPENAI_API_KEY="sk-..."

# Option 3: Gemini CLI
npm install -g @google/gemini-cli
# No API key needed if logged in with Google account
# Otherwise: export GOOGLE_API_KEY="..."

重启Claude代码 你准备好了!

使用方法

自然地问问克劳德:

"Review this authentication function"
"Get a second opinion on src/auth.ts"
"Check the payment processing code for security issues"
"Review all files in the api/ directory"

克劳德将从Codex/Gemini获取评价,进行分析,并提供全面的反馈。

你将获得什么

测试的真实结果

100行认证服务:

  • 发现:6个严重安全问题
  • SQL注入(5处)、硬编码密钥、不安全的随机数生成、缺少JWT过期时间设置
  • 时间:约5秒

支付处理模块:

  • 发现:5个问题(2个严重,2个高危,1个中危)
  • 硬编码的API密钥、SQL注入、缺失的事务、浮点错误
  • 时间:约4秒

React 组件(90 行):

  • 发现:5个错误
  • 空指针崩溃、跨站脚本(XSS)漏洞、状态突变错误、缺失的依赖项
  • 时间:约5秒

实用函数:

  • 发现:4个安全漏洞
  • 弱密码哈希、不安全的令牌、不充分的清理处理
  • 时间:约4秒

示例评论

你的代码:

function auth(user, pass) {
  if (user === "admin" && pass === "12345") {
    return true;
  }
  return false;
}

法规审查:

- High: auth hard-codes "admin" and "12345" (auth.js:2). Anyone with
  source access gains full access, credentials can't be rotated without
  redeploying, and password is stored in clear text.

- High: Plain string comparison leaks timing information (auth.js:2).
  An attacker can measure response times to infer correct characters;
  use constant-time comparison.

- Medium: No hashing or KDF applied to password before comparison.
  Even if you moved the secret out of source control, you'd still want
  to hash user-supplied passwords.

Next steps: Replace hardcoded credential with configurable secret store,
hash/verify using a KDF, add constant-time compare helper.

克劳德的合成:

两位审稿人都指出了关键的安全问题。硬编码的凭据和时序攻击需要立即关注。我还注意到没有设置速率限制或审计日志。让我来帮你解决这些问题。。。

特点/功能

✅ 高级评审 - 捕获安全漏洞、错误、性能问题 ✅ 多个视角 - 获取Codex + Gemini + Claude的分析 ✅ 自动检测 - 与您已安装的任何命令行界面(CLI)兼容 ✅ 智能验证 - 过滤掉代码重写和无用的回答 ✅ 快 - 每100行代码约5秒 ✅ 全面的 - 查看代码片段、文件或整个目录 ✅ 优先考虑的 - 标记为关键/高/中/低的问题

可用工具

工具 使用场景
check_cli_status 检查已安装哪些审查命令行界面(CLIs)
review_code 直接审查代码片段
review_file 查看特定文件
review_directory 检查目录中的所有代码文件

你无需记住这些——当你请求评论时,克劳德会自动调用它们。

支持的语言

.js .ts .jsx .tsx .py .rb .go .java .c .cpp .cs .php .swift .kt .rs

它是如何运作的

  1. 你编写代码 并请克劳德进行评审
  2. MCP服务器检测到 哪些CLI可用(Codex/Gemini)
  3. 发送你的代码 只需一个简单的提示:“你是一名资深软件工程师。请审查这些更改和实现。不要做任何修改,只需审查。”
  4. 审稿人进行分析 并行执行(每个任务超时时间为5分钟)
  5. 验证过滤器 过滤掉无效回复(代码重写、错误、离题)
  6. 克劳德收到反馈 并加入其自身的专家分析
  7. 你将获得全面的结果 从多个AI视角出发

故障排除

“没有可用的审核命令行界面 (CLIs)”

  • 跑 "Check CLI status" 在克劳德·科德(Claude Code,此处为假设或特定语境下的名称,实际翻译可能需根据具体背景调整)中
  • 至少安装一个: codex, openai,或者 gemini CLI(Command Line Interface,命令行界面)

评论超时

  • 5分钟的冷静时间应该足够了
  • 检查网络连接和API密钥

API密钥无法正常工作

# Note: API keys not needed if you're logged in with:
# - ChatGPT subscription (for OpenAI CLI)
# - Google account (for Gemini CLI)

# If you need to set API keys manually:
# Check if keys are set
echo $OPENAI_API_KEY
echo $GOOGLE_API_KEY

# Add to ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="..."

演出

基于实际测试:

  • 速度: 每100行约5秒
  • 准确性: 测试中无误报
  • 覆盖范围: 发现安全漏洞、错误、性能问题、设计问题
  • 成本: 按照GPT-4的费率,每条评价约0.10美元
  • 代币: 每100行文件约3,000(单位根据上下文确定,可能是元、美元等)

建筑

You write code
     ↓
Claude Code asks for review
     ↓
Review MCP Server
     ├─→ Detects available CLIs
     ├─→ Sends code to Codex/Gemini (parallel)
     ├─→ Validates responses
     └─→ Returns formatted feedback
          ↓
Claude analyzes and synthesizes
     ↓
You get expert recommendations

发展

npm run watch  # Auto-rebuild on changes

许可证

麻省理工学院(MIT)

做出贡献

欢迎在 https://github.com/je4550/review-mcp 提出问题和提交拉取请求(PRs)