git-surgeon-mcp
Click on "Deploy 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-surgeon-mcp squash the last 3 commits into one with message 'Fix login bug'"
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-surgeon-mcp
An MCP server that gives AI agents safe, non-interactive Git history editing — squashing, rewording, and reflog rescue — without ever hanging on a Vim buffer.
Why
Agents shell out to Git fine for everyday commands, but git rebase -i and git commit --amend (without -m) open an interactive editor and hang forever waiting for input that never comes. Agents then resort to risky fallbacks like git reset --hard. git-surgeon-mcp wraps these operations in clean, programmatic tools instead.
Related MCP server: MCP Git Manager
How it's safe
No shell execution — every Git call uses
execFilewith an argument array, so command injection is structurally impossible.No
-mquoting issues — messages are written to a temp file and applied viagit commit -F.Non-interactive rebase shim — rewording a non-HEAD commit normally needs two interactive editors; the server points
GIT_SEQUENCE_EDITOR/GIT_EDITORat generated scripts that do it programmatically.Clean-tree checks — every operation requires a clean
git statusand auto-aborts (git rebase --abort) on failure.
Tools
Tool | Description |
| Structured |
| Squash the last N commits with a new message. |
| Reword any commit (HEAD or buried in history). |
| Find dangling/unreachable commits via reflog + fsck. |
Setup
git clone https://github.com/mustafatekiinn/git-surgeon-mcp.git
cd git-surgeon-mcp
npm install && npm run buildAdd to your client's MCP config (Claude Desktop's claude_desktop_config.json, Cursor's .cursor/mcp.json, etc.), using the absolute path to dist/index.js:
{
"mcpServers": {
"git-surgeon": {
"command": "node",
"args": ["/absolute/path/to/git-surgeon-mcp/dist/index.js"]
}
}
}Restart the client — the four tools are now available whenever the agent works inside a Git repo.
Requirements
Node.js 18+, Git on
PATH, a local Git repository
Safety Notes
Squashing/rewording rewrites history — force-push (
--force-with-lease) if already pushed, and coordinate with collaborators first.All operations abort cleanly, leaving no partial state, if the working tree is dirty or a step fails.
License
MIT
Available Tools
4 toolsgit_get_historyGet Git HistoryA
Returns a structured list of recent commits (hash, author, date, message) from HEAD.
Inputs: count.
git_quick_squashQuick Squash CommitsA
Merges the last N commits on HEAD into a single commit via a soft reset, applying a clean new commit message. Requires a clean working directory. Rewrites history.
Inputs: new_message (required), commit_count (required).
git_rescue_reflogRescue Lost Commits via ReflogA
Scans the git reflog and repository object database to identify recent HEAD movements and truly dangling/lost commits (e.g. from a bad rebase or hard reset) so the agent can recover them by hash.
Inputs: no named parameters.
git_reword_commitReword CommitA
Updates the message of a specific commit in history. If it is the latest commit (HEAD), uses git commit --amend. Otherwise performs a fully non-interactive rebase sequence (no editor prompts). Requires a clean working directory. Rewrites history for the target commit and everything after it.
Inputs: commit_hash (required), new_message (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clear, non-overlapping purpose: retrieving commit history, squashing commits, rewording messages, and recovering lost commits. No confusion between tools.
All tools follow a consistent 'git_verb_noun' pattern in snake_case, e.g., git_get_history, git_quick_squash. No deviations.
With 4 tools, the server is well-scoped for a focused 'git surgery' domain, addressing key operations without unnecessary bloat.
Covers essential history viewing, squashing, rewording, and rescue. Missing interactive rebase or commit splitting, but the core surgical workflow is largely complete.
Maintenance
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
An MCP server that gives your AI access to the source code and docs of all public github repos
AI-native git hosting — repos, PRs, issues, CI gates, and AI code review over MCP (60 tools).
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that gives coding agents instant insight into any Git repository — no guessing, no hallucination.162 npm20MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that gives AI agents git repository access: status, log, diff, branch, commit, push, pull, tag, stash, remotes — 24 tools, zero dependencies, pure Python stdlib (subprocess).MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI assistants deep understanding of your local Git repositories, providing instant repo overviews, change summaries, blame analysis, changelogs, branch health checks, and history search.80 npmMIT
- AlicenseNot gradedqualityBmaintenanceAn MCP server that gives AI agents a full, safe interface to Git with automatic backups, isolated worktrees, and structured JSON outputs.46MIT