git-mcp-server
Provides tools for interacting with Git repositories, enabling AI agents to manage repository status, staging, commits, branches, remotes, and other version control operations.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@git-mcp-servershow me the current git status and recent commits"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
git-mcp-server
本地 Git MCP 服务器:将 git 操作封装为 29 个 MCP 工具,供 AI 客户端直接调用。让 AI 像人一样读写仓库——查看状态、暂存提交、查询历史、管理分支与远程,全程无需离开对话。
快速开始
前置条件
系统已安装 git
方式一:配置到 opencode(opencode.json)
{
"mcp": {
"git": {
"type": "local",
"command": ["uvx", "--from", "git+https://github.com/JessPig/git-mcp-server", "git-mcp-server"],
"enabled": true
}
}
}方式二:在对话中让 opencode 自动安装
添加 git MCP 服务器,用 uvx --from git+https://github.com/JessPig/git-mcp-server git-mcp-server 启动安装后即可在对话中说「查看仓库状态」「提交所有更改」「创建新分支」——AI 会直接调用对应工具完成。
Related MCP server: GitHub MCP Server
配置
环境变量 | 说明 |
|
|
| 是否允许强制推送(默认 false 禁用,设为 true 启用;启用后 force 仍需 confirmed) |
工具一览
共 29 个工具,分 6 大分组:
仓库管理
工具 | 说明 |
| 初始化仓库(可指定初始分支、裸仓库) |
| 克隆远程仓库到本地(支持浅克隆、指定分支) |
| 查看工作区状态(可隐藏未跟踪文件) |
| 删除/预览未跟踪文件(需确认) |
| 读取 git 配置(指定 key 或全量列出) |
暂存与提交
工具 | 说明 |
| 暂存文件(全量/更新/指定文件) |
| 创建提交(支持 amend、no-verify) |
| 查看差异(工作区/暂存区/提交间对比,支持 stat) |
历史查询
工具 | 说明 |
| 查看提交历史(支持作者/日期/消息过滤) |
| 查看提交的元数据与补丁 |
| 逐行追溯文件修改归属(可限定行范围) |
| 查看引用日志 |
| 在跟踪文件中搜索模式 |
分支操作
工具 | 说明 |
| 列出/创建/删除分支(delete 需确认) |
| 切换分支、标签或提交(可先创建新分支) |
| 合并分支到当前分支(冲突返回详情) |
| 变基或管理进行中的 rebase |
| 将指定提交应用到当前分支 |
远程操作
工具 | 说明 |
| 管理远程仓库(list/add/remove/rename) |
| 从远程拉取引用 |
| 拉取并合并(支持 rebase) |
| 推送到远程(force/tags,拒绝时返回详情) |
高级操作
工具 | 说明 |
| 列出/创建/删除标签(annotated 标签需 message) |
| 管理stash(list/push/pop/drop) |
| 重置到指定提交(soft/mixed/hard,需确认) |
| 反向提交(不改变历史) |
| 管理并行工作树(list/add/remove) |
| 二分查找引入 bug 的提交 |
| 管理子模块(status/add/update) |
核心特性
完整的 git 工作流覆盖:从 init/clone 到 bisect/submodule,29 个工具涵盖日常开发全场景
官方 MCP SDK:基于
mcp包标准stdio传输,兼容任意支持 MCP 的客户端;工具契约由 Pydantic schema 定义可自纠的错误反馈:失败时返回
is_error结果及具体信息,调用方 LLM 可据此自行修正只读/破坏性标注:工具标注
readOnlyHint/destructiveHint,客户端可据此给予不同级别的安全提示四层安全防线:路径白名单、防 flag 注入、ref 预校验、破坏性操作显式确认(详见下方)
安全模型
防线 | 机制 |
路径白名单 | 仓库路径经 |
防 flag 注入 | ref / branch / target 等参数拒绝以 |
ref 预校验 |
|
破坏性确认 |
|
只读 vs 破坏性工具分类
只读(8 个):
git_statusgit_diffgit_loggit_showgit_blamegit_refloggit_grepgit_config破坏性(12 个):
git_resetgit_cleangit_revertgit_mergegit_rebasegit_cherry_pickgit_pushgit_branchgit_checkoutgit_stashgit_taggit_worktree
工作原理
AI 客户端 (opencode / Claude Desktop / ...)
│
│ stdio (MCP 协议)
▼
git-mcp-server
│
├─ list_tools → 29 个工具名 + Pydantic schema + 只读/破坏性标注
│
└─ call_tool → 路径边界校验 → ref/确认校验 → GitPython 执行 → 文本返回服务器启动时读取 GIT_MCP_ALLOWED_DIRS,随后通过 stdio 与客户端通信。所有 git 操作经 GitPython 执行,按 6 个模块组织(tools_repo / tools_stage / tools_history / tools_branch / tools_remote / tools_advanced)。
许可
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- -licenseAquality-maintenanceProvides 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 updated1021
- AlicenseAqualityDmaintenanceA Model Context Protocol server that provides Git version control operations as structured tools for AI coding agents. It enables LLMs to programmatically manage repositories through actions like committing changes, rolling back code, and comparing diffs.Last updated10Apache 2.0
- Alicense-quality-maintenanceA lightweight MCP server that enables AI assistants to manage local Git repositories by executing commands like status, add, and commit. It streamlines development workflows by providing repository context and diffs directly to the assistant.Last updated
- Alicense-qualityDmaintenanceAn MCP server that provides tools for interacting with Git repositories, enabling AI assistants to manage repositories, branches, commits, and files through a standardized interface.Last updated5,0171Apache 2.0
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
MCP server exposing the Backtest360 engine API as tools for AI agents.
A MCP server built for developers enabling Git based project management with project and personal…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jesspig/git-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server