mcpField
G
git-enhanced

git-enhanced

本地服务
github.com/davidweb3-ctrl版本控制121 周前更新

关于 git-enhanced

git-enhanced 是面向维护者和编码助手的 MCP 服务,用于检查本地 Git 仓库。它以只读工具支持代码审查、提交分析、分支比较和状态检查,不提供破坏性 Git 操作。

主要功能

  1. 01检查工作区与分支差异
  2. 02筛选提交历史
  3. 03比较分支并查找清理候选
  4. 04查看已暂存、未暂存和未跟踪文件
  5. 05分析提交元数据与变更

适用场景

  1. 01审查拉取请求中的变更
  2. 02为问题排查查找相关提交
  3. 03根据分支历史准备发布说明
  4. 04维护前检查仓库状态

MCP 相关

向 MCP 客户端提供差异、日志、分支、状态和提交分析等 Git 检查工具。它会验证仓库路径,且不提供 reset 或 push 等破坏性操作。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"davidweb3-ctrl-git-enhanced": {
"command": "npx",
"args": [
"-y",
"@davidweb3-ctrl/mcp-git-enhanced"
],
"env": {
"YOUR_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
启动命令npx -y @davidweb3-ctrl/mcp-git-enhanced
需要配置的环境变量
YOUR_API_KEY密钥Your API key for the service

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@davidweb3-ctrl/mcp-git-enhanced1.0.1

工具

5

收录的工具列表 · 更新于 2 周前

参数类型必填说明
sourcestring否进行差异比较的源(提交哈希、分支名称)。如果省略此项但指定了 target,则将 target 与工作目录进行比较。
stagedboolean否仅显示已暂存的更改(git diff --cached)
targetstring否进行差异比较的目标(提交哈希、分支名称或 'HEAD')。如果省略,则显示未提交的更改。
filePathstring否要比较差异的特定文件或目录路径(相对于仓库根目录)
repoPathstring是git 仓库的绝对路径

详细介绍

MCP Git Enhanced

CI License MCP

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

项目文件

要求

  • Node.js >= 18.0.0
  • 已安装 Git,且可通过 PATH 使用

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。