git-mcp-server
by cyanheads·★ 215·综合分 52
一个功能全面的 MCP 服务器,为 AI 代理提供 28 种 Git 操作,包括克隆、提交、分支管理等。
概述
cyanheads 开发的 git-mcp-server 通过模型上下文协议使 AI 代理能够与 Git 仓库交互。它提供了七类广泛的 Git 操作:仓库管理、暂存和提交、历史检查、分析、分支和合并、远程操作以及高级工作流。该服务器支持 STDIO 和 HTTP 传输模式,并提供 JWT 和 OAuth 认证选项。它使用 TypeScript 构建,采用现代软件架构原则,包括依赖注入、可插拔存储后端和全面的错误处理。
试试问 AI
装完之后,这里有 5 个你可以让 AI 做的事:
什么时候选它
当您需要通过 MCP 为 AI 代理提供全面的 Git 操作,特别是您已经使用基于 TypeScript 的系统并且需要 STDIO 和 HTTP 支持时。
什么时候不要选它
如果您需要纯 JavaScript 解决方案而不依赖 TypeScript,或者需要与标准 CLI 之外的特定 Git 提供商直接集成,请避免使用。
此 server 暴露的工具
从 README 抽取出 12 个工具git_initInitialize a new Git repository
git_cloneClone a repository from a remote URL
git_statusShow working tree status
git_addAdd file contents to the staging area
git_commitRecord changes to the repository
git_logShow commit history
git_branchList, create, or delete branches
git_checkoutSwitch branches or restore working tree files
git_mergeJoin two or more development histories together
git_pushUpdate remote refs with local commits
git_pullFetch and integrate remote changes
git_diffShow changes between commits, commit and working tree, etc
可对比工具
安装
安装
git-mcp-server 可以使用 Node.js 或 Bun 安装和运行:
# Node.js
npx @cyanheads/git-mcp-server@latest
# Bun
bunx @cyanheads/git-mcp-server@latestClaude Desktop 配置
将以下内容添加到您的 Claude Desktop 配置文件 (claude_desktop_config.json) 中:
{
"mcpServers": {
"git-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["@cyanheads/git-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"GIT_BASE_DIR": "~/Developer/",
"LOGS_DIR": "~/Developer/logs/git-mcp-server/",
"GIT_USERNAME": "your-username",
"GIT_EMAIL": "your-email",
"GIT_SIGN_COMMITS": "true"
}
}
}
}Bun 用户请将命令替换为 bunx。
FAQ
- 这个服务器是否支持提交签名?
- 是的,默认情况下为提交、合并、变基、拣选和标签启用 GPG/SSH 签名。在失败时会回退到未签名,同时在响应中提供 signed/signingWarning 字段。
- 支持哪些身份验证方法?
- 服务器支持三种身份验证模式:无(默认)、JWT 和 OAuth。可以为已部署的配置 JWT 和 OAuth 进行身份验证。
git-mcp-server 对比
最后更新于 · 由 README + GitHub 公开数据自动生成。