Git合并分析工具

一个轻量级的MCP服务器,用于快速分析Git合并,提供核心变更统计和受影响文件列表,适用于开发中的预合并检查。

  • by Aravind4331
  • 本地部署
  • 更新于
在 GitHub 查看 Aravind4331/Git-MCP-Server

使用说明

简单的合并审查MCP

一个轻量级的MCP服务器,用于快速进行Git合并分析。仅显示必要信息,无需复杂的冲突检查。

🚀 特点

  • 快速合并概览 - 核心变更统计
  • 更改的文件列表 - 合并将会对什么产生影响
  • 简单统计 - 提交次数、行数、文件数

📦 安装

# Clone the repository
git clone <repository-url>
cd local-merge-review-mcp

# Install dependencies
npm install

# Build the project
npm run build

🛠️ 就是2个简单工具

1. show_merge_diff

在合并前显示分支之间的差异。

await mcp.call_tool("show_merge_diff", {
  repoPath: "/path/to/your/repo",
  fromBranch: "main", // optional, defaults to main
  toBranch: "feature/new-feature" // optional, defaults to current
});

结果:

{
  "sourceBranch": "main",
  "targetBranch": "feature/new-feature", 
  "filesChanged": ["src/component.js", "package.json", "README.md"],
  "insertions": 45,
  "deletions": 12,
  "commits": 3,
  "summary": "3 commits, 3 files, +45/-12 lines"
}

2. quick_merge_summary

快速合并更改概要。

await mcp.call_tool("quick_merge_summary", {
  repoPath: "/path/to/your/repo",
  branch: "feature/auth" // optional, defaults to current
});

结果:

{
  "currentBranch": "feature/auth",
  "baseBranch": "main",
  "message": "5 commits ahead",
  "aheadBy": 5,
  "behindBy": 0,
  "needsMerge": true
}

📋 常见使用场景

快速合并前检查

"Show changes in feature/payment branch compared to main"
# show_merge_diff

分支状态检查

"How many commits ahead is the current branch?"
# quick_merge_summary

理解变更范围

"How many files will change after merging this branch?"
# show_merge_diff + file list analysis

📝 与Claude使用的示例

"Show changes between main and feature/auth in /home/user/myproject"

"How many commits ahead is current branch from main?"

"Which files will change after merge?"

⚡ 为什么简单更好

  • 快 - 无复杂的冲突检查
  • 清晰 - 仅包含必要信息
  • 可靠的 - 最小化依赖
  • 实用的 - 覆盖90%的使用场景

默认情况下,不期望出现冲突,因此无需进行复杂的检查。此合并冲突解析器(MCP)仅在合并前显示真正重要的内容。

⚠️ 要求

  • Git(一种分布式版本控制系统) 已安装并添加到系统路径(PATH)中
  • Node.js >= 18.0.0

🚧 易于添加功能

  • 特定文件(.js、.py 等)的格式处理
  • package.json版本集成
  • 基本指标(代码行数、注释)
  • 导出为多种格式