Git MCP

MCP开发工具

提供方 selfagency · 包名 @selfagency/git-mcp

开发工具 stdio · 本地进程 API Key 社区 / 第三方 Claude DesktopClaudeCursorVS Code
查看接入方式

git-mcp [![CI](https://github.com/selfagency/git-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/selfagency/git-mcp/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/selfagency/git-mcp/graph/badge.svg?token=LblUcPGFK7)](https://codecov.io/gh/selfagency/git-mcp) ![NPM Version](https://img.shields.io/npm/v/@selfagency/git-mcp) > A Git [MCP](https://modelcontextprotocol.io) se

一句话选型结论

按资料字段整理

Git MCP 属于开发工具类 MCP 服务器,stdio · 本地进程,API Key,可直接接入 Claude Desktop、Claude、Cursor 等,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类开发工具 传输方式stdio · 本地进程 鉴权API Key 部署方式本地部署
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

开发工具
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

git version control development

支持客户端

适用场景

gitversion controldevelopment

安装与配置

stdio · 本地进程 API Key
客户端在本机拉起子进程,数据不出本机
npx @selfagency/git-mcp --repo-path /path/to/your/repo\r

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Cross-platform,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
代码与仓库操作

在对话里直接查代码、提 issue、走 PR,省掉来回切工具。

本地命令与脚本

把构建、测试、格式化这类重复命令交给模型执行。

接口联调与测试

让模型调你的接口、跑一遍用例,快速定位问题。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好API Key对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在开发工具场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Git MCP当前 未标注 stdio · 本地进程 本地部署 有 未标注
Git 838e2ec1 12 stdio · 本地进程 本地部署 有 2026-05-17
Markitdown MCP 2c653a5f 1 stdio · 本地进程 本地部署 有 2026-05-17
JavaGuide 未标注 stdio · 本地进程 本地部署 有 2026-04-11
awesome-claude-skills 未标注 stdio · 本地进程 本地部署 有 2026-04-26
Context7 831acf40 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

开发工具
字段来自项目仓库与公开索引,中文说明由本站标注
提供方selfagency上游标注的维护方 selfagency
分类开发工具本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式API Key远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时@selfagency/git-mcp · Cross-platform本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验未标注上游最后核验时间

详细介绍

18.9 KB
来自项目仓库与上游目录的原文,未做删改

git-mcp

> A Git MCP server that doesn't suck

Exposes the full Git workflow to any MCP-compatible AI agent — inspect, write, branch, remote, stash, rebase, LFS, git-flow, documentation lookup, and more. Designed to be safe by default, composable, and fast. Powered by simple-git.

Built for coding agents in tools like GitHub Copilot, Claude Code, Cursor, and OpenAI Codex, while remaining compatible with any MCP client that can call tools and resources.


Features

  • 18 tools with 80+ actions covering everyday Git workflows, advanced recovery, history rewriting, repository analytics, forge pull requests, and external VCS awareness
  • Safety-first — destructive operations require explicit confirmation; force push and hook bypass are opt-in via server config
  • GPG/SSH signing for commits and tags, with server-level auto-sign support
  • Git LFS — track patterns, manage objects, install hooks, migrate history
  • Git Flow — drives the git-flow-next CLI, so the finish state machine, conflict recovery, and worktree lifecycle stay correct as the CLI evolves. Preset init, overview, config CRUD, generalized topic actions, and classic feature/release/hotfix/support aliases
  • Documentation lookup — search git-scm.com and fetch man pages directly from the LLM
  • MCP Resources — URI-addressable read-only views of status, log, branches, and diff
  • Bundled agent skill — skills/git-mcp-workflow/ documents MCP-first Git workflows, recovery, worktrees, releases, and advanced operations for AI agents and coding agents; installable via skills-npm and skill.sh
  • External VCS awareness — git_but_check / git_jj_check detect GitButler and Jujutsu and guide agents to prefer their native CLIs/MCP (with but teardown guidance) over git-mcp tools when appropriate
  • History rewrite — git_rewrite: reword, squash, rewrite-messages, and backup/restore for safe commit-history rewriting
  • Repository analytics — git_analytics: contributors, churn, activity, summary, and file-stats computed from local git history
  • Pull requests — git_pr: create/list/merge PRs/MRs on GitHub, GitLab, Forgejo, Gitea, and Bitbucket via provider CLI or REST API
  • Tangled & Entire awareness — git_tangled_check / git_entire_check detect Tangled hosting and Entire session/context management
  • Multi-repo — pass repo_path per-call or configure a server-level default
  • Worktrees — git_worktree: plain git worktree by path, or branch-addressed worktrees via git flow worktree with path templates and provenance-aware cleanup
  • Cross-platform — macOS, Linux, Windows (Git for Windows), all covered by CI

Quick Start

npx (no install)```bash

npx @selfagency/git-mcp --repo-path /path/to/your/repo


### Install globally```bash
npm install -g @selfagency/git-mcp
git-mcp --repo-path /path/to/your/repo

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:```json
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@selfagency/git-mcp", "--repo-path", "/path/to/your/repo"]
}
}
}


### VS Code (Copilot)

Add to `.vscode/mcp.json` in your project:```json
{
  "servers": {
    "git": {
      "command": "npx",
      "args": ["-y", "@selfagency/git-mcp", "--repo-path", "${workspaceFolder}"]
    }
  }
}

Configuration

All configuration is via environment variables. Pass them in your MCP client config:

Variable Default Description
GIT_REPO_PATH — Default repository path (also: --repo-path CLI arg)
GIT_ALLOW_NO_VERIFY false Allow --no-verify on commit/push (bypasses hooks)
GIT_ALLOW_FORCE_PUSH false Allow --force on push
GIT_ALLOW_FLOW_HOOKS false Allow git_flow hooks and filters to execute
GIT_AUTO_SIGN_COMMITS false Automatically sign every commit
GIT_AUTO_SIGN_TAGS false Automatically sign every tag
GIT_SIGNING_KEY — Default GPG key ID or SSH key path
GIT_SIGNING_FORMAT — Signing format: openpgp, ssh, or x509
GIT_ALLOW_BUT false Enable GitButler awareness (git_but_check)
GIT_ALLOW_JJ false Enable Jujutsu awareness (git_jj_check)
GIT_ALLOW_TANGLED false Enable Tangled awareness (git_tangled_check)
GIT_ALLOW_ENTIRE false Enable Entire awareness (git_entire_check)
BUT_BINARY but Override the but executable path
JJ_BINARY jj Override the jj executable path
ENTIRE_BINARY entire Override the entire executable path
GITHUB_TOKEN — GitHub token for git_pr REST fallback
GITLAB_TOKEN — GitLab token for git_pr REST fallback
FORGEJO_TOKEN — Forgejo/Gitea token for git_pr REST fallback
BITBUCKET_TOKEN — Bitbucket token for git_pr REST fallback
GIT_FORGE_PROVIDER — Explicit forge provider for self-hosted instances

Tool Reference

Tools are grouped by domain. Each root tool takes an action parameter that selects the operation. Where an action is marked as default, omitting action will use it.

Context (git_context)

Action Description
summary (default) Full repo snapshot: branch, upstream, pending changes, in-progress operations
search Search commit history and working tree content
get_config Read a Git config value
set_config Write a Git config value
aliases List all configured git aliases

Status (git_status)

Action Description
status (default) Working tree and branch status
diff Unstaged, staged, or ref-to-ref diff
diff_main Changes from branch divergence point vs main (or configurable base branch)

History (git_history)

Action Description
log (default) Commit log with filtering, pagination, revision ranges, and pathspecs
show Inspect a single commit
blame Line-by-line attribution for a file
reflog Full reflog — the recovery ledger
lg Compact graph log (--oneline --graph --decorate --all)
who Contributor shortlog (supports optional file_path)

Commits (git_commits)

Action Description
add Stage files or hunks
restore Discard working tree changes
unstage Remove files from the staging area
commit Create a commit with message, signing, and author flags
amend Amend the last commit without editing the message
wip Stage all changes and commit with message WIP
revert Create a revert commit for a given ref
undo Soft-reset the last commit (reset --soft HEAD~1)
reset Reset HEAD with configurable mode (soft/mixed/hard)
nuke Hard-reset the last commit — requires confirm=true

Branches (git_branches)

Action Description
list (default) Local and remote branch listing
create Create a branch
delete Delete a branch
rename Rename a branch
checkout Switch to a branch or ref
set_upstream Set or update tracking upstream
recent Recent branches sorted by committer date

Remotes (git_remotes)

Action Description
list (default) List configured remotes
manage Add, remove, or rename a remote
fetch Fetch from a remote
pull Pull (fetch + merge/rebase)
push Push to a remote; force_with_lease supported

Workspace (git_workspace)

Action Description
stash Stash and pop/apply/drop/list/show stash entries
stash_all Stash tracked and untracked changes in one operation
rebase Start, continue, abort, or skip a rebase
cherry_pick Apply one or more commits; supports continue/abort/skip
merge Merge branches with full flag control
bisect Binary search for a regression (start, good, bad, reset, log)
tag Create, list, delete, or push tags; supports GPG/SSH signing
worktree Add, list, remove, lock, unlock, prune, or repair linked worktrees
submodule Add, update, sync, init, deinit, and list submodules

Git Flow (git_flow)

Drives the git-flow-next CLI, which must be installed and on PATH
(brew install git-flow-next, or the releases page).
Set GIT_FLOW_BINARY to override the path. When the binary is missing, the tool returns an install
hint rather than failing opaquely.

Operation Description
init Initialize a repository with git-flow branch conventions
overview Show the current flow state and active branches
config Read or write git-flow configuration values
topic Generalized topic branch action (start, finish, publish, track)
control Resume or abort an in-progress finish or update

Flags are scoped to the target verb: worktree and worktree_path apply to start and checkout,
while keep_worktree and force_worktree apply to finish and delete. A mismatch raises instead
of being silently dropped. See the tool reference for the full parameter list.

Worktree (git_worktree)

Two backends. Path-addressed actions drive plain git worktree and need nothing but git;
branch-addressed flow_* actions drive git flow worktree, which addresses worktrees by branch
name, computes paths from the gitflow.worktreePath template, and tags provenance so cleanup can
tell a git-flow-created worktree (removed) from a hand-made one (detached, uncommitted work
preserved).

Action Description
add, list, remove, lock, unlock, prune, repair Plain git worktree, identified by path
flow_path, flow_add, flow_remove, flow_list git flow worktree, identified by branch

See the tool reference.

LFS (git_lfs)

Action Description
track Add a tracking pattern to .gitattributes
untrack Remove a tracking pattern
ls-files List tracked LFS files
status Show LFS status
pull Pull LFS objects
push Push LFS objects
install Install LFS hooks in the repository
migrate-import Migrate existing history to LFS
migrate-export Migrate LFS history back to plain objects

Documentation (git_docs)

Action Description
search Search git-scm.com for documentation
man Fetch and return a Git man page

History Rewrite (git_rewrite)

Action Description
reword Change one commit's message (HEAD amends in place; arbitrary via filter-branch)
squash Combine the last N commits into one (requires confirm=true)
rewrite-messages Rewrite messages across a range via a SHA→message map (requires confirm=true)
backup Create a rewrite-backup/ branch before rewriting
restore Hard-reset to a backup branch (requires confirm=true)

Analytics (git_analytics)

Action Description
contributors Per-author commits, +/- lines, first/last activity
churn File hotspots (most commits / most lines changed)
activity Commit frequency per day
summary Branch/tag counts, total commits, top contributors, oldest/newest commit
file-stats File-type breakdown, largest files, recently modified

Pull Requests (git_pr)

Action Description
create Create a PR/MR on the detected forge (GitHub, GitLab, Forgejo, Gitea, Bitbucket)
list List PRs/MRs (state filter)
merge Merge a PR/MR (method: merge/squash/rebase)

Uses the provider CLI (gh/glab/tea) when installed locally, otherwise the REST API with a *_TOKEN env var. Provider auto-detected from the origin remote; self-hosted instances use GIT_FORGE_PROVIDER.

External VCS Awareness

Tool Description
git_but_check Detect GitButler but CLI; prefer but mcp/but, run but teardown before git-mcp tools
git_jj_check Detect Jujutsu jj CLI and .jj/ management; prefer jj CLI for jj-managed repos
git_tangled_check Detect Tangled hosting; git transport works, PRs via web UI
git_entire_check Detect Entire CLI and .entire/ management; use entire for session/context queries

Health Check (git_ping)

Returns server status. Useful for confirming the server is reachable.


MCP Resources

URI-addressable read-only snapshots (subscribe-capable):

Resource URI Content
git+repo://status/{repo_path} Working tree status (JSON)
git+repo://log/{repo_path} Recent commit log (JSON)
git+repo://branches/{repo_path} Branch list (JSON)
git+repo://diff/{repo_path} Unstaged + staged diff (JSON)

Bundled Agent Skill

git-mcp ships a bundled agent skill at skills/git-mcp-workflow/ that teaches any skills-npm-compatible agent to use the MCP tool surface instead of running raw git CLI commands. The skill covers:

  • Why LLMs must not use the Git CLI (quoting hazards, silent failures)
  • Inspect-before-mutate workflow rules
  • Safety order for undo and recovery operations
  • Full registered tool surface with action reference
  • Workflow playbooks: feature branch, rebase, recovery, worktree, backport, release tagging, Git Flow, merge
  • Git concept explanations anchored to MCP tools

Installing the skill

If your agent supports skills-npm:```bash
npm install @selfagency/git-mcp # or pnpm/yarn
npx skills-npm


Or add to your project's `package.json` so it runs automatically:```json
{
  "scripts": {
    "prepare": "skills-npm"
  }
}

Then add to .gitignore:```txt
skills/npm-*


---

## Safety

- All mutating tools have `destructiveHint: true` in their MCP annotations
- `git_commits action=reset mode=hard` requires `confirm=true`
- `git_commits action=nuke` requires `confirm=true`
- Force push (`--force`) is disabled unless `GIT_ALLOW_FORCE_PUSH=true`; `force_with_lease` is always available
- Hook bypass (`--no-verify`) is disabled unless `GIT_ALLOW_NO_VERIFY=true`
- `git_flow` hook and filter execution is disabled unless `GIT_ALLOW_FLOW_HOOKS=true`
- Paths are validated against the repository root — traversal attempts are rejected
- Credentials and tokens are never included in responses

---

## Development```bash
# Clone and install
git clone https://github.com/selfagency/git-mcp.git
cd git-mcp
pnpm install

# Run in development mode (hot reload)
pnpm dev

# Build
pnpm build

# Run tests
pnpm test

# Type check
pnpm typecheck

# Lint
pnpm lint

# Docs (dev server)
pnpm docs:dev

# Docs (build)
pnpm docs:build

License

MIT © Daniel Sieradski

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
Git MCP 怎么安装?

在客户端按下面的安装命令接入:npx @selfagency/git-mcp --repo-path /path/to/your/repo\r。对应的包名是 @selfagency/git-mcp。装完在客户端配置里引用同一个包或端点。

Git MCP 怎么在 Claude Desktop、Claude、Cursor 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Git MCP 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Git MCP 需要 API Key 吗?

资料标注需要API Key认证,使用前准备好对应凭据,并按最小权限配置。

Git MCP 支持哪些客户端?

资料标注支持 Claude Desktop、Claude、Cursor、VS Code、Codex、Zed;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Git MCP 能提供哪些能力?

资料显示能力标签包括 git、version control、development。具体工具清单以官方文档为准。

Git MCP 需要什么运行环境?

运行时为 Cross-platform;属于本地进程,需要在本机装好运行环境。

Git MCP 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 未标注。