Git Auto Commit MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Analyzes git changes in repositories, including modified, added, and deleted files, and generates commit messages

  • Uses OpenAI's GPT-4o-mini model to generate commit messages based on code changes

MCP 服务器自动提交变更🛠️

此实现提供了一个 Git 更改分析器,它使用 OpenAI 的 GPT 模型生成提交消息。

演示

特征

  • 分析存储库中的 git 更改(暂存和未暂存)
  • 使用 GPT-4o-mini 生成常规提交消息
  • 提供以下详细摘要:
    • 📝 修改的文件
    • ✨ 新添加的文件
    • 🗑️ 已删除的文件
    • 📄 详细更改(每个文件最多 10 行)
  • 使用@modelcontextprotocol/sdk构建
  • 为每个提交添加自动提交签名

项目结构

mcp-server-auto-commit/ ├── index.ts # Main server implementation with git analysis tool ├── package.json # Project dependencies ├── tsconfig.json # TypeScript configuration └── build/ # Compiled JavaScript output

先决条件

  • Node.js 已安装
  • OpenAI API 密钥
  • 要分析的 Git 存储库
  • pnpm 包管理器

入门

  1. 克隆此存储库:
git clone https://github.com/jatinsandilya/mcp-server-auto-commit.git cd mcp-server-auto-commit
  1. 安装依赖项:
pnpm install
  1. 使用以下方法之一设置您的 OpenAI API 密钥:
    • 设置为环境变量: OPENAI_API_KEY=your-api-key
    • 作为命令行参数传递: --key your-api-key
    • 添加到项目根目录中的.env文件
  2. 构建项目:
pnpm run build

这将生成/build/index.js文件 - 已编译的 MCP 服务器脚本。

与游标一起使用

  1. 前往“光标设置”->“MCP”->“添加新的 MCP 服务器”
  2. 配置您的 MCP:
    • 名称:git-auto-commit
    • 类型:命令
    • 命令: node ABSOLUTE_PATH_TO_MCP_SERVER/build/index.js --key your-api-key (如果环境中未设置,请将your-api-key替换为您的实际 OpenAI API 密钥)

与 Claude Desktop 一起使用

将以下 MCP 配置添加到您的 Claude Desktop 配置中:

{ "mcpServers": { "git-auto-commit": { "command": "node", "args": ["ABSOLUTE_PATH_TO_MCP_SERVER/build/index.js", "--key", "your-api-key"] } } }

可用工具

git 更改提交消息

此工具会分析存储库中当前的 git 更改,并使用 OpenAI 的 GPT-4o-mini 模型生成提交消息。它提供以下功能:

  • 带有状态指示器的已修改文件列表
  • 新添加的文件列表
  • 已删除文件列表
  • 每个文件的详细更改(为便于阅读,每个文件限制为 10 行)
  • 生成的提交消息遵循常规提交格式
  • 自动提交签名

使用参数:

  • autoCommitPath :用于分析特定目录/文件的可选路径。如果未提供,则使用当前工作目录。

发展

index.ts中的实现展示:

  1. 使用正确的配置设置 MCP 服务器
  2. 处理命令行参数和环境变量
  3. 使用 GPT-4o-mini 模型与 OpenAI 的 API 集成
  4. 使用子进程的 Git 操作
  5. 错误处理和回退机制
  6. 详细的变更分析和格式

要修改或扩展实施:

  1. 更新index.ts中的服务器配置:
const server = new McpServer({ name: "git-auto-commit", version: "0.0.1", });
  1. 该工具使用server.tool()定义,并使用 Zod 模式进行适当的参数验证。
  2. 构建并测试您的更改:
pnpm run build

贡献

请随时提交问题和增强请求!

执照

麻省理工学院

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

分析存储库中的 git 更改并使用 OpenAI 的 GPT 模型生成常规提交消息,支持暂存和非暂存更改以及详细摘要。

  1. Demo
    1. Features
      1. Project Structure
        1. Prerequisites
          1. Getting Started
            1. Using with Cursor
              1. Using with Claude Desktop
                1. Available Tools
                  1. git-changes-commit-message
                2. Development
                  1. Contributing
                    1. License
                      ID: xm2dqoc1s6