Code Review Agent MCP
Code Review Agent MCP
不粉饰的 AI 代码审查代理。如果你的代码很烂,它会直接告诉你。毫不客气。
一个基于 AI 的 MCP(Model Context Protocol)服务器,以资深维护者在严肃项目上审查补丁的方式审查你的代码:技术性、直接、不讲情面。
它能做什么
AI 代码审查 — 审查代码片段、文件、git diff 和提交
返回带有严重性标签的发现:
CRITICAL、MAJOR、MINOR、NIT、CLEAN为每个发现引用具体的行号
解释为什么某处有问题,然后说明如何修复
以明确的结论结束:“可以合并。”或“在……之前不要合并。”
没有虚假的赞美。没有含糊其辞。没有道歉。没有废话。
Related MCP server: greybeard
为什么?
大多数 AI 代码审查者被训练得很有礼貌。他们用“干得不错,但是……”开头,用“你可能需要考虑……”来含糊其辞,用“这可能是一个潜在的问题”来软化发现。
这不是严肃代码审查的方式。在真实项目(Linux 内核、PostgreSQL、Redis、SQLite)中,维护者直接审查补丁。他们发现问题并明确指出来。他们的存在不是为了取悦作者——而是为了让代码变得更好。
这个 MCP 编码了这种传统。个性就是产品。
反 RLHF 工程
LLM 经过 RLHF 训练变得礼貌。这个 AI 代理通过三层来对抗这一点:
系统提示 — 12 条核心原则(对代码不对人、结论优先、严重性标签、行号引用、不虚假赞美、不含糊、不道歉、不废话、第二人称、不涉及人口统计、不拒绝、不幻觉 bug)
后处理器 — 从 LLM 输出中剥离 40+ 个禁用短语(含糊、软化、道歉、废话)
验证器 — 检查输出是否包含严重性标签、行号引用和结论;将模糊的问题陈述标记为幻觉信号
工具
工具 | 描述 |
| 审查代码片段 |
| 从磁盘审查文件(沙箱化) |
| 审查 git diff |
| 审查 git 提交( |
| 列出严重性标签及其定义 |
严厉程度级别
级别 | 行为 |
| 稍微软化语言。仍报告所有发现。 |
| 默认的直率审查。直接、技术性、不讲情面。 |
| 不软化。“这是错的。”而不是“这应该被改变。” |
| 最大程度的直率。短句。祈使语气。 |
安装
pip install code-review-agent-mcp或者使用 uv:
uv pip install code-review-agent-mcp配置
Claude Desktop
添加到 claude_desktop_config.json:
{
"mcpServers": {
"code-review-agent": {
"command": "python",
"args": ["-m", "code_review_agent.server"]
}
}
}或者如果通过 pip 安装:
{
"mcpServers": {
"code-review-agent": {
"command": "code-review-agent-mcp"
}
}
}Cursor
添加到 .cursor/mcp.json:
{
"mcpServers": {
"code-review-agent": {
"command": "python",
"args": ["-m", "code_review_agent.server"]
}
}
}使用示例
审查代码片段
User: Review this code for me
def get_user(username):
import sqlite3
conn = sqlite3.connect("users.db")
cursor = conn.cursor()
query = f"SELECT * FROM users WHERE username = '{username}'"
cursor.execute(query)
return cursor.fetchone()MCP 响应:
## Code Review: snippet
### Findings
**CRITICAL** `snippet:7` — SQL injection
The query uses an f-string with user input, allowing SQL injection. Use parameterized queries: `cursor.execute("SELECT * FROM users WHERE username = ?", (username,))`.
### Verdict
Do not merge until CRITICAL is fixed.审查文件
User: Review src/auth.py
MCP calls review_file with file_path="src/auth.py"
Returns blunt review with line citations.审查提交
User: Review the last commit
MCP calls review_commit with commit_ref="HEAD"
Returns blunt review of the diff.严重性标签
标签 | 使用时机 |
CRITICAL | 安全漏洞、数据丢失、死锁、RCE、任何会导致发布损坏的问题 |
MAJOR | 逻辑错误、竞态条件、资源泄漏、破坏的边界情况、错误的抽象 |
MINOR | 风格、命名、缺少测试、冗余代码、脆弱的假设 |
NIT | 外观、格式、注释措辞 |
CLEAN | 明确说明某部分没问题。防止虚构 bug 的偏见。 |
安全
此 MCP 服务器实现了安全沙箱:
文件访问 默认沙箱化到当前工作目录
敏感路径(
.ssh、.aws、.env、/etc/passwd等)被拒绝Git 引用 通过严格的字符白名单验证,以防止选项注入
子进程调用 使用
shell=False并禁用全局 git 配置
参见 SECURITY.md 了解完整的威胁模型。
开发
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=code_review_agent基准测试片段
benchmarks/ 目录包含 5 个回归测试片段,用于验证审查者:
SQL 注入 — 期望 CRITICAL、行号引用、“不要合并”
可变默认参数 — 期望 MAJOR
干净代码(二分查找)— 期望 CLEAN、“可以合并”(反幻觉测试)
吞掉异常 — 期望 MAJOR
差一错误 — 期望 MAJOR
干净代码基准测试是最重要的——它捕捉幻觉。如果审查者在正确的代码中虚构 bug,那么反 RLHF 系统就坏了。
许可证
MIT
致谢
这个项目编码了内核维护者的代码审查传统——一种在许多项目(Linux 内核、PostgreSQL、Redis、SQLite 等)中由许多资深工程师实践的方法论。我们引用的是这一传统,而不是任何单个实践者。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
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
An MCP server that automatically collects feedback on your MCP server.
An MCP server that integrates with Discord to provide AI-powered features.
Vet any MCP server before you depend on it. Stamp: PASS, REVIEW, or BLOCK.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn MCP server that reviews code with the sarcastic and cynical tone of a grumpy senior developer, helping identify issues in PRs and providing feedback on code quality.1921MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides AI-powered code review and architecture analysis, simulating the perspective of an experienced staff engineer. It integrates with IDEs to review diffs, design decisions, and tradeoffs through natural language.1MIT
- AlicenseNot gradedqualityFmaintenanceAn MCP server that provides senior-level code review, quality checks, security analysis, and refactoring suggestions directly in your editor.1MIT
- AlicenseAqualityBmaintenanceAn MCP server that lets AI agents review code using language models, supporting git diffs, files, and snippets with severity levels. Works with Ollama (local) and hosted providers like OpenAI, Anthropic, and OpenRouter.3MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/frangelbarrera/code-review-agent-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server