G

Git 提交助手

@MrOrz/mcp-git-commit-aider
0 Stars 137 次浏览 MrOrz 更新于 2026-08-23

通过在提交者名称后添加“(aider)”来代表AI进行git提交,从而可以在代码库中跟踪AI的贡献。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "git-commit-aider": {
      "args": [
        "mcp-git-commit-aider"
      ],
      "command": "npx"
    }
  }
}

服务介绍

git-commit-aider MCP 服务器

代表 AI 进行 git 提交,以便您可以在代码库中跟踪 AI 的贡献。

这是一个基于 TypeScript 的 MCP 服务器,提供了一个工具,用于提交 Git 仓库中的暂存更改,并在提交者的名称后追加 "(aider)"。

功能

此 MCP 服务器仅提供一个工具:

commit_staged - 使用特定消息提交暂存的更改。

  • 接受 message(字符串,必需)作为提交消息。
  • 接受 cwd(字符串,可选)以指定 git 命令的工作目录。
  • 自动在提交者名称后追加 "(aider)"。
  • 如果设置了环境变量 (GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL),则从中读取提交者名称和电子邮件,否则回退到 git config user.namegit config user.email

将此工具安装到您的代码编辑器中后,您可以使用类似以下提示让 AI 执行操作:

为我提交这些更改

这通常发生在 AI 对您的代码库进行了一些更改之后,因此很多时候 AI 能够根据上下文提供一个好的提交消息。

带有 "(aider)" 的提交可以通过运行 aider --stats 命令来统计,该命令会显示 AI 在您的代码库中的贡献情况。

安装

要使用此服务器,请将其配置添加到您的 MCP 设置文件中。

{
  "mcpServers": {
    "git-commit-aider": {
      "command": "npx",
      "args": ["mcp-git-commit-aider"]
    }
  }
}

提交者信息是从以下位置获取的:

  1. 环境变量 GIT_COMMITTER_NAMEGIT_COMMITTER_EMAIL,遵循 git 的约定
  2. git config user.namegit config user.email 命令的输出。

开发

安装依赖项:

npm install

构建服务器:

npm run build

对于带有自动重建功能的开发:

npm run watch

示例 MCP 配置:

{
  "mcpServers": {
    "git-commit-aider": {
      "command": "node",
      "args": [
        "/path/to/git-commit-aider/build/index.js"
      ]
    }
  }
}

(将 /path/to/git-commit-aider 替换为此服务器目录的实际路径。)

调试

由于 MCP 服务器通过 stdio 通信,调试可能会比较困难。我们推荐使用 MCP Inspector,它作为一个包脚本可用:

npm run inspector

Inspector 将提供一个 URL,您可以在浏览器中访问调试工具。