Git MCP ServerGit MCP Server
MCP 官方 reference server 里的版本控制实现。它作用域限定在指定 git 仓库,但具备完整的本地写操作能力。
The version-control implementation among MCP's official reference servers, scoped to a given git repository but with full local write capability.
适合与不适合When to use it, when not to
读取仓库状态、历史与 diff,并在受控前提下执行提交与分支操作。 需要明确作用域边界(限于传入的 git 仓库)的场景。
不适合需要 push / 创建 PR / 远程仓库管理的场景—— 本 server 只做本地操作,原 github server 已归档。
Scenarios where an agent should make version-control operations inside a specific repository.
Not a fit for read-only use — full local write capability, so scope matters.
中文生态China availability 国产 / 国内可直接用 / 备案状态 · 快照domestic / direct access / CAC filing · snapshot 2026-10-20
- 出品属地Origin
- 国外出品foreign-made 国外主体(网信办公示名单未见对应备案主体)。foreign entity (no matching filing entity in the CAC registry).
- 国内使用Direct access
- 大陆可直连direct OK 官网仓库在 GitHub,大陆直连波动(同日实测 200/000 混合);npm / PyPI 安装源实测稳定可达。Hosted on GitHub — direct reachability from mainland fluctuates (200/000 mixed on the same day); npm / PyPI install routes measured stable.
- 备案状态CAC filing
- 未见于备案名单not in filing list:未见于网信办公示名单(2026-10-20 检索 13 批附件,https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm);该产品未面向大陆公众提供服务,备案不适用。not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.
备案信息以网信办《生成式人工智能服务已备案信息》公示名单为准(按批次滚动更新,本站只抄编号不解读);「大陆可直连」是本站从大陆网络直连实测的结果,不是厂商承诺。GitHub 类站点当日实测有波动,口径写在依据里。Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.
固定坐标系Fixed coordinate system
11 个维度dimensions, 与同分区其他对象逐项可比each comparable item by item against others in the same section.
- 模型与开放条件Model & openness
本身不调用模型,是被客户端调用的接口实现。 直接调用本机 git 命令行,继承本机 git 版本与配置。
It calls no model itself; it is an interface implementation called by clients. It invokes the local git command line directly, inheriting the local git version and configuration.
- 运行位置Where it runs
本地进程,通过 stdio 通信; 也支持容器部署(Docker / Podman),但需显式挂载仓库目录。
2026-08-30 修复了容器 bind mount 在 Docker / Podman / SELinux 下的安全与兼容问题。
A local process communicating over stdio; container deployment (Docker / Podman) is also supported, but repository directories must be mounted explicitly.
A 2026-08-30 fix addressed security and compatibility issues of container bind mounts under Docker / Podman / SELinux.
- 本地文件Local files
通过 git 操作仓库,不需要任意文件读写。 每个工具都要求传入 repo_path,作用域限于该 git 仓库。 仓库内文件内容通过 git show / git_log 等命令间接读取。
Operates repositories through git; no arbitrary file read/write is needed. Every tool requires a repo_path, scoping it to that git repository. File contents inside the repository are read indirectly via git show / git_log and similar commands.
- 关机后的任务Tasks after shutdown
不支持。本地进程随客户端生死; 容器部署时取决于容器编排方式,不受本 server 自身控制。
Not supported. The local process lives and dies with the client; under container deployment it depends on the container orchestration, not controlled by this server itself.
- 工具与扩展Tools & extensions
提供 11 个工具,含:
- git_status
- git_diff_unstaged
- git_diff_staged
- git_diff
- git_commit
- git_add
- git_reset
- git_log
- git_create_branch
- git_checkout
- git_show
含 4 个写操作(commit / add / reset / checkout), 输出为结构化文本或 diff,可直接消费。
It provides 11 tools, including:
- git_status
- git_diff_unstaged
- git_diff_staged
- git_diff
- git_commit
- git_add
- git_reset
- git_log
- git_create_branch
- git_checkout
- git_show
Including 4 write operations (commit / add / reset / checkout); output is structured text or diffs, ready for direct consumption.
- 上下文与记忆Context & memory
无跨会话记忆。状态完全由 git 仓库本身承载, 会话断开不影响仓库状态。
No cross-session memory. State is carried entirely by the git repository itself; session disconnects do not affect repository state.
- 权限与限制Permissions & limits
无独立审批机制。权限边界等于本机 git 用户的文件权限, 且具备完整写操作能力,包括提交、重置暂存区与切换分支。
git_reset 只取消暂存,不丢弃工作区改动; 但 git_checkout 可切换到任意分支。
No separate approval mechanism. The permission boundary equals the local git user's file permissions, and it has full write capability, including committing, resetting the staging area and switching branches.
git_reset only unstages and does not discard working-tree changes; but git_checkout can switch to any branch.
- 适合什么任务Best for
让 Agent 读取仓库状态、历史与 diff,并在受控前提下执行提交与分支操作。 不适合需要 push / PR / 远程仓库管理的场景。本 server 不提供远程操作。
Lets an Agent read repository status, history and diffs, and perform commits and branch operations under controlled conditions. Not a fit for scenarios needing push / PRs / remote repository management. This server provides no remote operations.
- 传输方式Transport
支持 stdio。README 同时给出容器部署方式(Docker / Podman)
与 uvx / pip 本地安装(2026-10-08 全文核验); 没有远程传输(SSE / Streamable HTTP)的官方启动方式。
Supports stdio. The README also gives container deployment (Docker / Podman)
and uvx / pip local installation (full-text verification 2026-10-08); there is no official launch method for a remote transport (SSE / Streamable HTTP).
- 认证机制Authentication
无独立认证层。stdio 形态继承客户端用户的 git 权限; 容器形态的认证取决于容器编排配置,仓库未说明。
No separate authentication layer. In stdio form it inherits the client user's git permissions; for the container form, authentication depends on the container orchestration configuration and is not stated in the repo.
- 权限范围Permission scope
作用域限定在传入的 git 仓库,比 filesystem server 更收敛。
但具备完整写操作能力(commit / add / reset / checkout), 无独立审批。切分支可改变工作区状态,需注意。
The scope is confined to the git repository passed in — narrower than the filesystem server.
But it has full write capability (commit / add / reset / checkout), with no separate approval. Switching branches can change working-tree state — take care.
头号误解Top misconception
- 以为是只读工具,实际能 commit 和切换分支Assuming it is read-only — it can commit and switch branches
- 以为容器部署后能直接访问宿主仓库,不挂载就读不到Assuming a container deployment can reach the host repo without help — without a mount it cannot read it
- 以为它能 push 或创建 PR,本 server 只做本地操作Assuming it can push or open PRs — this server only does local operations
未知项清单Known unknowns
- 是否支持 SSE / Streamable HTTP(仓库未声明)
- 容器形态下的认证机制
- Python MCP 1.x 具体版本下限对功能的影响
git_log新 schema 的确切结构
- Whether SSE / Streamable HTTP is supported (not declared in the repo)
- The authentication mechanism in the container form
- How the specific lower bound of Python MCP 1.x versions affects functionality
- The exact structure of the new
git_logschema
证据来源Evidence sources
判断可回到以下一手源复核。本站核验日Every judgement can be rechecked against the primary sources below. Verified on 2026-10-23,内容更新日content updated on 2026-10-08。
| 类型Type | 名称Name | 链接Link |
|---|---|---|
| docs | MCP · Git ServerMCP · Git Server | https://github.com/modelcontextprotocol/servers/tree/main/src/git |
| changelog | MCP · Git 目录变更历史MCP · Git directory change history | https://github.com/modelcontextprotocol/servers/commits/main/src/git |
| changelog | MCP · Servers ReleasesMCP · Servers Releases | https://github.com/modelcontextprotocol/servers/releases |
| repo | MCP · Servers 仓库 README(生产环境免责声明)MCP · Servers repo README (production-use disclaimer) | https://github.com/modelcontextprotocol/servers |
实测记录Measured runs
本档未在真实客户端逐项跑通;工具清单与权限来自官方 README。
This site has not completed measured runs. The test protocol is at protocols/mcp/_protocol.md.
变更记录说明Change-log notes
本对象无独立 changelog 页,变更记录在目录 commit 历史中:
| 日期 | 内容 |
|---|---|
| 2026-09-02 | 统一 git_log 输出 schema,移除 run 中的 raise_exceptions |
| 2026-08-30 | 修复 Fetch / Git / Time 的容器 bind mount 安全与兼容问题(Docker / Podman / SELinux) |
| 2026-08-18 | 文档补充 fetch、git、time 的 Python MCP 1.x 版本要求 |
两条值得注意:
- 09-02 的输出 schema 统一说明
git_log返回结构变过。如果你在解析它的输出,需要核对版本。 - 08-30 的容器安全修复说明这些 server 的容器部署路径存在过安全问题,且涉及 SELinux——如果你在企业环境用容器跑,值得读那条 commit。
This object has no standalone changelog page; change records are in the directory's commit history:
| Date | Content |
|---|---|
| 2026-09-02 | Unify the git_log output schema; remove raise_exceptions from run |
| 2026-08-30 | Fix container bind-mount security and compatibility for Fetch / Git / Time (Docker / Podman / SELinux) |
| 2026-08-18 | Document the Python MCP 1.x version requirement for fetch, git, time |
Two entries worth noting:
- The 09-02 output-schema unification means
git_log's return structure has changed. If you parse its output, check the version. - The 08-30 container security fix shows the container deployment path of these servers once had security issues, involving SELinux — if you run containers in an enterprise environment, that commit is worth reading.
工具清单与读写属性Tool inventory and read/write attributes
| 工具 | 属性 | 说明 |
|---|---|---|
git_status | 读 | 工作区与暂存区状态 |
git_diff_unstaged | 读 | 未暂存的改动 |
git_diff_staged | 读 | 已暂存的改动 |
git_diff | 读 | 与目标分支/提交比较 |
git_log | 读 | 提交历史,支持时间过滤 |
git_show | 读 | 某次提交的内容 |
git_add | 写 | 暂存指定文件 |
git_commit | 写 | 提交并返回新 hash |
git_reset | 写 | 取消全部暂存(不动工作区) |
git_create_branch | 写 | 从当前或指定基点建分支 |
git_checkout | 写 | 切换分支,会改变工作区状态 |
6 读 5 写。这不是只读工具。git_checkout 切分支会直接改变工作区。如果工作区有未提交改动,行为需要特别留意。
| Tool | Attribute | Description |
|---|---|---|
git_status | read | working-tree and staging-area status |
git_diff_unstaged | read | unstaged changes |
git_diff_staged | read | staged changes |
git_diff | read | comparison against a target branch/commit |
git_log | read | commit history, with time filtering |
git_show | read | the content of a given commit |
git_add | write | stage specified files |
git_commit | write | commit and return the new hash |
git_reset | write | unstage everything (working tree untouched) |
git_create_branch | write | create a branch from current or a specified base |
git_checkout | write | switch branches, changing working-tree state |
6 read, 5 write. This is not a read-only tool. git_checkout switching branches directly changes the working tree. If it has uncommitted changes, the behaviour deserves special care.
与 filesystem server 的对比Comparison with the filesystem server
| 维度 | filesystem | git |
|---|---|---|
| 作用域 | 目录白名单 | 传入的 git 仓库 |
| 写操作 | 有(write / edit / move) | 有且更强(commit / reset / checkout) |
| 删除 | 不提供 | 不提供 |
| 执行命令 | 不提供 | 内部调用 git 命令行 |
| 认证 | 无(靠进程权限) | 无(靠进程权限) |
结论:git server 的写能力更强。但它的作用域限定在 git 仓库内,风险面比 filesystem 小。
| Dimension | filesystem | git |
|---|---|---|
| Scope | directory allowlist | the git repository passed in |
| Write operations | yes (write / edit / move) | yes and stronger (commit / reset / checkout) |
| Delete | not provided | not provided |
| Command execution | not provided | invokes the git command line internally |
| Authentication | none (relies on process permissions) | none (relies on process permissions) |
Conclusion: the git server's write capability is stronger, but its scope is confined to the git repository, so its risk surface is smaller than filesystem's.
能力边界Capability boundaries
本 server 只做本地操作,不提供:
git push- 创建 PR / Issue
- 远程仓库管理
需要远程操作要另找方案(旧的 github server 已归档,见下文)。
This server does local operations only; it does not provide:
git push- creating PRs / issues
- remote repository management
Remote operations need another solution (the old github server is archived, see below).
已归档的替代方案The archived alternative
原 github server 提供仓库管理、文件操作与 GitHub API 集成。它已归档至 servers-archived。归档仓库自 2025-05 后基本无更新。
The original github server provided repository management, file operations and GitHub API integration. It is archived to servers-archived. The archived repo has seen essentially no updates since 2025-05.
相关条目Related entries
- Filesystem MCP ServerFilesystem MCP Server同仓库,作用域设计更保守Same repository, with more conservative scope design
- Memory MCP ServerKnowledge Graph Memory Server跨会话记忆方向The cross-session memory direction
- AiderAider另一层 · AI 编程Other layer · AI coding
本页由This page is generated from the ai-handbook 数据层生成(CC BY 4.0)。data layer (CC BY 4.0).
方法论与坐标系定义见仓库内For the methodology and coordinate definitions, see METHODOLOGY.md.