跳到主要内容Skip to main content
← Tools

Git MCP ServerGit MCP Server

Model Context Protocol
版本控制 本地 读写 verified lifecycle: active 核验Checked 2026-10-08

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 版本与配置。

运行位置Where it runs

本地进程,通过 stdio 通信; 也支持容器部署(Docker / Podman),但需显式挂载仓库目录。

2026-08-30 修复了容器 bind mount 在 Docker / Podman / SELinux 下的安全与兼容问题。

本地文件Local files

通过 git 操作仓库,不需要任意文件读写。 每个工具都要求传入 repo_path,作用域限于该 git 仓库。 仓库内文件内容通过 git show / git_log 等命令间接读取。

关机后的任务Tasks after shutdown

不支持。本地进程随客户端生死; 容器部署时取决于容器编排方式,不受本 server 自身控制。

工具与扩展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,可直接消费。

上下文与记忆Context & memory

无跨会话记忆。状态完全由 git 仓库本身承载, 会话断开不影响仓库状态。

权限与限制Permissions & limits

无独立审批机制。权限边界等于本机 git 用户的文件权限, 且具备完整写操作能力,包括提交、重置暂存区与切换分支。

git_reset 只取消暂存,不丢弃工作区改动; 但 git_checkout 可切换到任意分支。

适合什么任务Best for

让 Agent 读取仓库状态、历史与 diff,并在受控前提下执行提交与分支操作。 不适合需要 push / PR / 远程仓库管理的场景。本 server 不提供远程操作。

传输方式Transport

支持 stdio。README 同时给出容器部署方式(Docker / Podman)

与 uvx / pip 本地安装(2026-10-08 全文核验); 没有远程传输(SSE / Streamable HTTP)的官方启动方式。

认证机制Authentication

无独立认证层。stdio 形态继承客户端用户的 git 权限; 容器形态的认证取决于容器编排配置,仓库未说明。

权限范围Permission scope

作用域限定在传入的 git 仓库,比 filesystem server 更收敛。

但具备完整写操作能力(commit / add / reset / checkout), 无独立审批。切分支可改变工作区状态,需注意。

头号误解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 的确切结构

证据来源Evidence sources

判断可回到以下一手源复核。本站核验日Every judgement can be rechecked against the primary sources below. Verified on 2026-10-08,内容更新日content updated on 2026-10-08。

类型Type名称Name链接Link
docsMCP · Git Serverhttps://github.com/modelcontextprotocol/servers/tree/main/src/git
changelogMCP · Git 目录变更历史https://github.com/modelcontextprotocol/servers/commits/main/src/git
changelogMCP · Servers Releaseshttps://github.com/modelcontextprotocol/servers/releases
repoMCP · Servers 仓库 README(生产环境免责声明)https://github.com/modelcontextprotocol/servers

实测记录Measured runs

本站尚未完成实测。测试协议见 tasks/_protocol.md。

变更记录说明

本对象无独立 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。

工具清单与读写属性

工具属性说明
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 切分支会直接改变工作区。如果工作区有未提交改动,行为需要特别留意。

与 filesystem server 的对比

维度filesystemgit
作用域目录白名单传入的 git 仓库
写操作有(write / edit / move)有且更强(commit / reset / checkout)
删除不提供不提供
执行命令不提供内部调用 git 命令行
认证无(靠进程权限)无(靠进程权限)

结论:git server 的写能力更强。但它的作用域限定在 git 仓库内,风险面比 filesystem 小。

能力边界

本 server 只做本地操作,不提供:

  • git push
  • 创建 PR / Issue
  • 远程仓库管理

需要远程操作要另找方案(旧的 github server 已归档,见下文)。

已归档的替代方案

原 github server 提供仓库管理、文件操作与 GitHub API 集成。它已归档至 servers-archived。归档仓库自 2025-05 后基本无更新。

相关条目Related entries

本页由This page is generated from the ai-agent-guide 数据层生成(CC BY 4.0)。data layer (CC BY 4.0). 方法论与坐标系定义见仓库内 METHODOLOGY.md。