MCP Code Review Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Code Review Server Generate a code review for my feature branch against main"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Code Review Server
一个基于 MCP (Model Context Protocol) 的代码审查工具,帮助前端开发者在迭代结束后自动生成详细的代码 Review 文档(HTML 格式),方便在小组内分享和讲解代码改动。
功能特性
🔍 分支对比: 对比开发分支与目标分支(如 main/master/develop)的代码差异
🔗 Commit Hash 模式: 支持指定起始 commit hash,无需目标分支即可获取变更
👤 作者筛选: 根据 Git 提交作者筛选出你自己的改动(多人协作场景下非常有用)
📊 智能分析: 自动分析代码变更类型、复杂度、关键改动点
📋 文件功能描述: 通过 LLM 根据文件路径批量生成文件功能描述(50字以内),展示在报告中
📄 HTML 报告: 生成美观的 HTML 格式 Review 文档,包含代码差异高亮
📋 提交时间线: 展示完整的提交记录
🚫 智能过滤: 自动排除图片、字体等二进制资源文件,以及无实际代码差异的文件
Related MCP server: MCP Review Server
安装
# 克隆或进入项目目录
cd mcp-xl-code-review
# 安装依赖
npm install
# 构建项目
npm run build配置 MCP Server
在 Claude Desktop 中配置
编辑 Claude Desktop 配置文件:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
添加以下配置:
{
"mcpServers": {
"code-review": {
"command": "node",
"args": ["/path/to/mcp-xl-code-review/build/index.js"]
}
}
}在 Cursor 中配置
在 Cursor 的 MCP 设置中添加:
{
"mcpServers": {
"code-review": {
"command": "node",
"args": ["/path/to/mcp-xl-code-review/build/index.js"]
}
}
}使用 npx 运行(无需全局安装)
{
"mcpServers": {
"code-review": {
"command": "npx",
"args": ["-y", "mcp-xl-code-review"]
}
}
}工具说明
本 MCP Server 提供 3 个工具和 3 个提示词模板:
所有工具均支持两种使用模式:
分支对比模式: 提供
target_branch,对比开发分支与目标分支的差异Commit Hash 模式: 提供
from_commit,获取该 commit 之后到开发分支的所有变更,无需指定目标分支
提示词模板(Prompts)
在 MCP 面板中可以直接看到以下提示词模板,点击即可快速使用:
模板名称 | 说明 |
| 生成代码Review报告(分支对比模式) |
| 生成代码Review报告(Commit Hash模式) |
| 查看提交作者列表 |
使用方式:在 MCP 面板的 Prompts 区域选择对应模板,填入参数即可自动生成提示词并执行。
1. list_branch_authors
列出变更范围内所有提交的作者信息,帮助用户确认自己的 Git 用户名。
2. get_changed_files
获取变更文件的路径列表。用于:
了解本次迭代涉及哪些文件
根据文件路径让 LLM 批量生成文件功能描述
3. generate_code_review
生成代码 Review 报告(HTML 格式)。支持接收文件功能描述参数,在报告中展示。
使用方式
配置完成后,在 AI 助手中使用以下指令:
一句话生成 Review 报告(推荐)
直接告诉 AI 你要生成代码 Review 报告,AI 会自动完成以下流程:
分支对比模式:
"帮我生成代码 Review 报告,仓库路径是 /path/to/my-project,开发分支是 feature/my-branch,目标分支是 main,作者是 Zhang San"
Commit Hash 模式:
"帮我生成代码 Review 报告,仓库路径是 /path/to/my-project,开发分支是 feature/my-branch,从 commit abc1234 开始,作者是 Zhang San"
AI 会自动:
调用
generate_code_review获取变更文件列表根据每个文件的完整路径理解其功能,生成简短的中文功能描述(50字以内)
再次调用
generate_code_review传入文件描述,生成完整的 HTML 报告
整个过程在一轮对话中自动完成,无需手动干预。
文件功能描述示例
AI 会根据文件路径智能生成功能描述,例如:
src/api/settlement.ts→ "结算管理API接口"src/views/Settlement/Corporate.vue→ "结算列表页面"src/utils/date.ts→ "日期格式化工具函数"src/store/user.ts→ "用户状态管理"src/components/UploadFile.vue→ "文件上传组件"
查看提交作者列表
当你不确定自己的 Git 用户名时:
"帮我查看 /path/to/my-project 仓库中 feature/my-branch 分支相对于 main 分支的所有提交作者"
generate_code_review 参数说明
参数 | 必填 | 说明 |
| ✅ | Git 仓库的本地绝对路径 |
| ✅ | 开发分支名称(你的工作分支) |
| ⚠️ | 目标对比分支(如 main、master、develop),与 |
| ⚠️ | 起始 commit hash,与 |
| ❌ | Git 提交作者名称或邮箱,用于筛选特定作者的提交 |
| ❌ | HTML 报告输出路径,默认生成在仓库根目录 |
| ❌ | 文件功能描述列表,每个元素包含 |
get_changed_files 参数说明
参数 | 必填 | 说明 |
| ✅ | Git 仓库的本地绝对路径 |
| ✅ | 开发分支名称 |
| ⚠️ | 目标对比分支(如 main、master、develop),与 |
| ⚠️ | 起始 commit hash,与 |
| ❌ | Git 提交作者名称或邮箱,用于筛选特定作者的提交 |
list_branch_authors 参数说明
参数 | 必填 | 说明 |
| ✅ | Git 仓库的本地绝对路径 |
| ✅ | 开发分支名称 |
| ⚠️ | 目标对比分支,与 |
| ⚠️ | 起始 commit hash,与 |
报告内容
生成的 HTML 报告包含以下内容:
变更概览: 统计信息(文件数、提交数、新增/删除行数)、参与开发者列表
文件功能描述: 每个文件的功能描述(由 LLM 根据文件路径生成,50字以内)
文件变更详情: 每个文件的关键改动点、代码差异
代码差异高亮: 带语法高亮的 diff 视图,支持 Vue SFC 多段语言高亮
文件目录导航: 左侧固定目录栏,展示文件名和功能描述,支持快速跳转
项目结构
mcp-xl-code-review/
├── src/
│ ├── index.ts # MCP Server 入口
│ ├── git-utils.ts # Git 操作工具类
│ ├── analyzer.ts # 代码分析器
│ └── report-generator.ts # HTML 报告生成器
├── build/ # 编译输出目录
├── package.json
├── tsconfig.json
└── README.md技术栈
TypeScript: 主要开发语言
MCP SDK: Model Context Protocol 服务端 SDK
Git: 通过 child_process 调用 Git 命令
Node.js: 运行环境
开发
# 开发模式(监听文件变化)
npm run dev
# 构建
npm run build
# 清理构建产物
npm run clean注意事项
确保本地已安装 Git 并且可以在命令行中使用
仓库路径必须是本地已克隆的 Git 仓库
分支名称需要是本地已存在的分支(如果远程分支未拉取,请先
git fetch)作者名称匹配使用 Git 的
--author参数,支持部分匹配图片、字体、压缩包等二进制资源文件会被自动过滤,不会出现在报告中
无实际代码差异的文件(如仅格式变更)也会被自动排除
License
MIT
Available Tools
3 toolsgenerate_code_reviewA
生成代码Review报告。支持两种模式:
模式一:分支对比模式(需要 target_branch) 对比开发分支与目标分支的代码差异。
模式二:Commit Hash 模式(需要 from_commit,不需要 target_branch) 指定一个起始 commit hash,获取该 commit 之后到开发分支的所有变更并生成报告。
使用场景:
迭代结束后,需要在小组内分享代码改动
代码评审会议前准备Review材料
记录本次迭代的技术细节
使用方式: 直接调用此工具即可。如果不传 file_descriptions,系统会返回变更文件列表,你需要根据每个文件的完整路径理解其功能,生成简短的中文功能描述(50字以内),然后再次调用此工具传入 file_descriptions 参数。
参数说明:
repo_path: Git仓库的本地路径
dev_branch: 开发分支名称(你的工作分支)
target_branch: 目标对比分支(通常是main/master/develop),使用 from_commit 模式时可不传
from_commit: 起始 commit hash,指定后无需 target_branch
author: 你的Git用户名或邮箱(用于筛选你的提交,可选)
output_path: HTML报告输出路径(可选,默认生成在仓库根目录)
file_descriptions: 文件功能描述列表(可选,不传则返回文件列表供你生成描述)
Inputs: repo_path (required), dev_branch (required), author, ai_summary, +4 more.
get_changed_filesA
获取变更文件的路径列表。支持两种模式:
模式一:分支对比模式(需要 target_branch) 对比开发分支与目标分支之间的代码差异。
模式二:Commit Hash 模式(需要 from_commit,不需要 target_branch) 指定一个起始 commit hash,获取该 commit 之后到开发分支的所有变更。适用于不想指定目标分支的场景。
使用流程:
调用此工具获取变更文件路径列表
根据每个文件的完整路径名称,生成简短的中文功能描述(10-20字)
将描述通过 file_descriptions 参数传给 generate_code_review 工具
描述示例:
src/api/settlement.ts -> "结算管理API接口"
src/views/Settlement/Corporate.vue -> "结算列表页面"
src/utils/date.ts -> "日期格式化工具函数"
src/store/user.ts -> "用户状态管理"
src/components/UploadFile.vue -> "文件上传组件"
Inputs: repo_path (required), dev_branch (required), author, from_commit, +1 more.
list_branch_authorsA
列出变更范围内所有提交的作者信息,帮助用户确认自己的Git用户名。支持两种模式:
模式一:分支对比模式(需要 target_branch) 模式二:Commit Hash 模式(需要 from_commit,不需要 target_branch)
使用场景:
不确定自己的Git用户名时,先查看提交作者列表
了解本次迭代有哪些人参与了代码提交
Inputs: repo_path (required), dev_branch (required), from_commit, target_branch.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools have distinct primary purposes (list changed files, generate review, list authors), but generate_code_review can also return a changed file list when file_descriptions is omitted, creating a slight functional overlap with get_changed_files. This overlap is minor because the intended workflow is clearly described, but it could cause an agent to call the wrong tool first.
All tool names follow a consistent verb_noun pattern: get_changed_files, generate_code_review, list_branch_authors. The naming is uniform in style and clearly communicates each tool's action and target.
Three tools are appropriate for a specialized code review server. Each tool serves a distinct step in the workflow (identify files, generate review, identify authors), and no tool feels redundant or excessive for the scope.
The tool surface covers the essential workflow for generating code reviews: retrieving changed files, generating the review report, and listing authors for context. There are no obvious gaps within the stated purpose of the server.
Maintenance
Related MCP Connectors
Generate and review codebase docs. 77 tools; scoped, credit-approved repository reviews.
Code review for diffs: rule-based checks for leaked secrets, unsafe migrations and more.
Code review by AI models from different companies, usually two. Shows where they agree and disagree.
Multi-brand AI code review for Claude: up to 12 reviewers and a judge, no install.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA tool that integrates with GitHub and Notion to analyze and review pull requests, enabling automated code reviews and documentation in Notion.-
- AlicenseNot gradedqualityFmaintenanceA specialized code review service that provides 36+ critics for different programming aspects and 3 fixing strategies to automatically address identified issues in a two-step workflow.MIT
- AlicenseNot gradedqualityDmaintenanceAutomatically generates comprehensive merge request summaries from git logs, analyzing commit history and categorizing changes into structured descriptions. Provides tools to analyze git repositories, compare branches, and create detailed summaries with change categorization, impact analysis, and review time estimates.1MIT
- AlicenseNot gradedqualityBmaintenanceA collaborative code and markdown review tool that bridges human reviewers and AI agents, enabling both to browse files, inspect git diffs, leave structured comments, and save a final review report from the same UI in real time.68 PyPI2MIT