git-graph-mcp
git-graph-mcp
语言: 简体中文 | English
一个本地优先的 Git 提交图终端工具,同时提供标准 MCP stdio 服务。它让你在终端选择提交或范围,再让 Claude Code、Codex、Cursor 等 MCP 客户端读取同一份受预算约束的 Git 上下文。

当前稳定版本:
0.2.2· GitHub Release
v0.2.2是本次公开化修订版本;已有的v0.2.1tag 保持不可变。
能做什么
在终端查看提交图、分支、提交详情和工作区状态;
保存 commit、range、ref 选择,并在 CLI、TUI、MCP 之间复用;
通过 MCP 读取 graph、status、context、search、diff、history 和 resources;
生成安全的分支动作与 reset 预览,不自动执行 reset、checkout 或 push;
用
doctor检查 Node.js、Git、仓库、MCP 配置和 stdio 握手。
Related MCP server: worktree-map
支持范围
Node.js
22+,Git 必须位于PATH中;GitHub Actions 自动验证 Windows 与 Ubuntu 上的 Node.js 22、24;
Claude Code 的本地 stdio 配置已验证;其他遵循标准 MCP stdio 的客户端可使用同一配置模式;
macOS 没有纳入当前 CI 矩阵,使用前请在目标环境运行
doctor和只读 smoke。
安装并运行
从源码运行
适合贡献代码或需要查看最新主线内容的场景:
git clone https://github.com/ShinonomeAya/git-graph-mcp.git
Set-Location git-graph-mcp
npm ci
node .\bin\git-graph-mcp.js graph --plain --limit 8
node .\bin\git-graph-mcp.js doctor从 GitHub Release 固定包运行
当前 npm registry 没有发布 git-graph-mcp;从 GitHub Releases 下载固定 .tgz,可以在一个独立目录中安装:
New-Item -ItemType Directory git-graph-mcp-runtime -Force | Out-Null
Set-Location git-graph-mcp-runtime
npm init -y
$version = "0.2.2" # 替换为要使用的 Release 版本
npm install "https://github.com/ShinonomeAya/git-graph-mcp/releases/download/v$version/git-graph-mcp-$version.tgz"
npx --prefix . --no-install git-graph-mcp graph --plain --limit 8 --repo <path-to-git-repository>
npx --prefix . --no-install git-graph-mcp doctor --json --repo <path-to-git-repository>发布新版本时,只需要把 $version 改为对应的 Release 版本,并按 Release notes 中的 SHA-256 校验值核对下载文件。
常用命令
以下命令从源码 checkout 运行;如果固定包安装在目标项目中,把入口替换为
npx --no-install git-graph-mcp;如果安装在独立 runtime 目录,则追加
npx --prefix <path-to-git-graph-mcp-runtime> --no-install:
node .\bin\git-graph-mcp.js graph --plain --limit 8
node .\bin\git-graph-mcp.js status
node .\bin\git-graph-mcp.js search --limit 20
node .\bin\git-graph-mcp.js select commit <commit-oid>
node .\bin\git-graph-mcp.js selected
node .\bin\git-graph-mcp.js doctor --json目标仓库不是当前目录时,为命令追加 --repo <path>。
使用交互式 TUI
运行 node .\bin\git-graph-mcp.js graph 后:
按键 | 操作 |
| 上下移动当前提交 |
| 保存当前 commit 选择 |
| 设置 range 起点 |
| 保存当前 range |
| 保存当前可见 ref |
| 退出 |
配置 MCP 客户端
源码 checkout
仓库根目录的 .mcp.json 使用相对路径,适用于从源码 checkout 打开项目:
{
"mcpServers": {
"git-graph": {
"type": "stdio",
"command": "node",
"args": ["./bin/git-graph-mcp.js", "mcp"]
}
}
}已安装固定包
如果把固定包安装到目标项目本身,可以使用项目本地的可执行文件:
{
"mcpServers": {
"git-graph": {
"type": "stdio",
"command": "npx",
"args": ["--no-install", "git-graph-mcp", "mcp"]
}
}
}Claude Code 也可以运行:
claude mcp add --transport stdio --scope local git-graph -- npx --prefix <path-to-git-graph-mcp-runtime> --no-install git-graph-mcp mcp服务器提供 12 个有界工具:
类别 | 工具 |
读取与状态 |
|
上下文查询 |
|
选择与安全动作 |
|
同时提供两个只读 resources:git-graph://default/selection 和 git-graph://default/status。完整输入、输出和错误契约见 MCP server specification。
安全边界
默认工作流是只读的。分支创建要求显式调用,不会移动已有分支;reset 只生成预览,git_revalidate_plan 会在动作前校验仓库状态指纹。项目不启动网络监听器,也不上传仓库内容。
排查连接问题
按顺序检查:
node --version
git --version
node .\bin\git-graph-mcp.js doctor --json --repo <path-to-repository>
npm ci
npm run check遇到 Claude Code 连接问题时,查看 Claude Code setup;需要诊断 stdio 时查看 MCP debug log。
开发与发布
npm run check
npm run test:package-install
npm audit --omit=dev --audit-level=high更多内容:
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for siGit (sigit.si): browse repos, search code, manage PRs/issues, web search.
Render, verify, describe, and safely edit Mermaid diagrams through MCP.
Plain-English git via MCP: 22 tools to branch, commit, push, and tag. No git jargon.
A MCP server built for developers enabling Git based project management with project and personal…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides batch file operations, search, and essential git workflows via stdio MCP.22 npm1Apache 2.0
- FlicenseNot gradedqualityBmaintenanceMCP server that visualizes git branch genealogy and worktree locations within a repository, marking the current session position. Supports creating branches/worktrees, safe deletion/cleanup, and session navigation with fallback guidance.2-
- AlicenseNot gradedqualityAmaintenanceA local git MCP server. It exposes 12 git operations to an MCP client over stdio, allowing the client to inspect and work with a git repository on your machine, including status, diffs, log, branches, staging, and commits.MIT
- AlicenseNot gradedqualityCmaintenanceEnables people and AI agents to query local code repositories as graphs through stdio MCP tools for project listing, search, dependency tracing, impact analysis, bridge detection, node inspection, bounded code reading, and optional LSP definition/reference lookups.MIT