MCP 服务器自动提交变更🛠️
此实现提供了一个 Git 更改分析器,它使用 OpenAI 的 GPT 模型生成提交消息。
演示

特征
分析存储库中的 git 更改(暂存和未暂存)
使用 GPT-4o-mini 生成常规提交消息
提供以下详细摘要:
📝 修改的文件
✨ 新添加的文件
🗑️ 已删除的文件
📄 详细更改(每个文件最多 10 行)
为每个提交添加自动提交签名
项目结构
先决条件
Node.js 已安装
OpenAI API 密钥
要分析的 Git 存储库
pnpm 包管理器
入门
克隆此存储库:
安装依赖项:
使用以下方法之一设置您的 OpenAI API 密钥:
设置为环境变量:
OPENAI_API_KEY=your-api-key作为命令行参数传递:
--key your-api-key添加到项目根目录中的
.env文件
构建项目:
这将生成/build/index.js文件 - 已编译的 MCP 服务器脚本。
与游标一起使用
前往“光标设置”->“MCP”->“添加新的 MCP 服务器”
配置您的 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 配置中:
可用工具
git 更改提交消息
此工具会分析存储库中当前的 git 更改,并使用 OpenAI 的 GPT-4o-mini 模型生成提交消息。它提供以下功能:
带有状态指示器的已修改文件列表
新添加的文件列表
已删除文件列表
每个文件的详细更改(为便于阅读,每个文件限制为 10 行)
生成的提交消息遵循常规提交格式
自动提交签名
使用参数:
autoCommitPath:用于分析特定目录/文件的可选路径。如果未提供,则使用当前工作目录。
发展
index.ts中的实现展示:
使用正确的配置设置 MCP 服务器
处理命令行参数和环境变量
使用 GPT-4o-mini 模型与 OpenAI 的 API 集成
使用子进程的 Git 操作
错误处理和回退机制
详细的变更分析和格式
要修改或扩展实施:
更新
index.ts中的服务器配置:
该工具使用
server.tool()定义,并使用 Zod 模式进行适当的参数验证。构建并测试您的更改:
贡献
请随时提交问题和增强请求!
执照
麻省理工学院
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
分析存储库中的 git 更改并使用 OpenAI 的 GPT 模型生成常规提交消息,支持暂存和非暂存更改以及详细摘要。
Related Resources
Related MCP Servers
- Asecurity-licenseAqualityGenerates comprehensive and formatted release notes from GitHub repositories, efficiently organizing commits by type and including detailed statistics using smart API usage.Last updated -2
 - Asecurity-licenseAqualityA specialized MCP server for in-depth analysis of git repositories, offering tools for branch overview, time period analysis, file changes, and merge recommendations.Last updated -42Apache 2.0
 - Asecurity-licenseAqualityProvides comprehensive Git operations as tools for AI assistants and applications. This server enables AI systems to interact with Git repositories, allowing to initialize, fetch, commit, log, status, etc..Last updated -1021MIT License
 - Asecurity-licenseAqualityAutomatically generates conventional commit messages from staged git changes and checks repository status. Analyzes git diffs to create properly formatted commit messages following conventional commit standards.Last updated -28MIT License