关于 mcp-git-enhanced
mcp-git-enhanced 是面向维护者和编码助手的 MCP 服务,用于检查本地 Git 仓库。它以只读工具支持代码审查、提交分析、分支比较和状态检查,不提供破坏性 Git 操作。
主要功能
- 01检查工作区与分支差异
- 02筛选提交历史
- 03比较分支并查找清理候选
- 04查看已暂存、未暂存和未跟踪文件
- 05分析提交元数据与变更
适用场景
- 01审查拉取请求中的变更
- 02为问题排查查找相关提交
- 03根据分支历史准备发布说明
- 04维护前检查仓库状态
MCP 相关
向 MCP 客户端提供差异、日志、分支、状态和提交分析等 Git 检查工具。它会验证仓库路径,且不提供 reset 或 push 等破坏性操作。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
MCP Git Enhanced
MCP Git Enhanced 是一个 Model Context Protocol 服务,可帮助 AI 编码助手检查代码仓库状态,满足日常开源维护需求。
它为维护者提供结构化的 Git 上下文,用于代码审查、提交分析、分支比较和发布准备,而无需让助手运行范围宽泛的 Shell 命令。
维护者为何使用它
开源维护者在审查或合并工作之前,往往要花很多时间回答相同的代码仓库问题:
- 此分支有哪些变更?
- 哪些提交与发布说明有关?
- 此分支是否落后于基础分支?
- 哪些内容已暂存、未暂存或未跟踪?
- 哪些已合并或过时的分支需要清理?
此服务将这些工作流封装为专用的 MCP 工具,帮助助手进行 PR 审查、问题分类、发布管理和代码仓库维护。
可用工具
| 工具 | 用途 |
|---|---|
git_diff | 分析工作树、暂存区、分支、提交或特定路径的差异。 |
git_log | 查看提交历史,并按作者、日期范围、分支、路径和统计信息筛选。 |
git_branch | 列出分支、比较分支与其基础分支,或建议清理候选项。 |
git_status | 汇总代码仓库中已暂存、未暂存和未跟踪的状态。 |
git_commit_analyze | 检查单个提交,包括元数据、变更文件、统计信息和差异输出。 |
安装
从源代码安装
git clone https://github.com/davidweb3-ctrl/mcp-git-enhanced.git
cd mcp-git-enhanced
npm install
npm run build
Claude Code 配置
使用此代码仓库中构建的服务:
{
"mcpServers": {
"git-enhanced": {
"command": "node",
"args": ["/absolute/path/to/mcp-git-enhanced/dist/index.js"]
}
}
}
未来通过 npm 安装
此包已发布为 @davidweb3-ctrl/mcp-git-enhanced:
npm install -g @davidweb3-ctrl/mcp-git-enhanced
发布后,客户端可以使用:
{
"mcpServers": {
"git-enhanced": {
"command": "npx",
"args": ["@davidweb3-ctrl/mcp-git-enhanced"]
}
}
}
工作流示例
PR 审查
Use git_diff to compare this branch with master and summarize the risky files.
Use git_log to list commits since the last release.
Use git_commit_analyze on the largest commit before I review it.
问题分类
Use git_log to find recent commits touching src/tools.ts.
Use git_status to check whether the local reproduction has uncommitted changes.
发布管理
Use git_branch compare against master to prepare release notes.
Use git_log with --stat style output to identify user-visible changes.
Use git_branch suggest_cleanup after the release branch is merged.
工具示例
git_diff
{
"repoPath": "/absolute/path/to/repo",
"target": "HEAD~5",
"source": "HEAD~10",
"filePath": "src/",
"staged": false
}
git_log
{
"repoPath": "/absolute/path/to/repo",
"maxCount": 20,
"author": "Maintainer Name",
"since": "1 week ago",
"stat": true
}
git_branch
{
"repoPath": "/absolute/path/to/repo",
"action": "list",
"includeRemote": true
}
{
"repoPath": "/absolute/path/to/repo",
"action": "compare",
"branchName": "feature/pr-review-summary",
"baseBranch": "master"
}
git_status
{
"repoPath": "/absolute/path/to/repo",
"short": false
}
git_commit_analyze
{
"repoPath": "/absolute/path/to/repo",
"commitHash": "abc123"
}
安全模型
MCP Git Enhanced 旨在作为面向读取的代码仓库检查服务。
- 它通过
spawnSync运行固定的git子命令,不进行 Shell 插值。 - 它不提供具有破坏性的分支删除、重置、检出、变基、推送或强制推送工具。
- 执行工具处理程序前,它会验证
repoPath是否指向 Git 代码仓库。 - 它面向由用户或维护者控制的本地代码仓库。
有关报告方式和受支持版本的详细信息,请参阅 SECURITY.md。
开发
npm install
npm run build
npm test
npm run lint
npm run format:check
项目文件
- CONTRIBUTING.md:开发环境设置和贡献流程。
- SECURITY.md:漏洞报告和信任边界。
- ROADMAP.md:计划中的维护者工作流和发布方向。
- CHANGELOG.md:发布说明。
- docs/CODEX_FOR_OSS.md:Codex 开源维护计划。
要求
- Node.js >= 18.0.0
- 已安装 Git,且可通过
PATH使用
许可证
MIT
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。