Git Sync Guardian
Monitors origin/main for new commits, analyzes conflict risk with local AI (Ollama), and syncs your working branch via rebase or merge with automatic stash/unstash and conflict resolution options.
README
Git Sync Guardian
MCP Server that watches main for new commits and keeps your working branch in sync — powered by local AI (Ollama).
What it does
When you're working on a feature branch, main keeps moving. Git Sync Guardian:
- Monitors
origin/mainat regular intervals - Analyzes incoming changes with Ollama (local LLM) to assess conflict risk
- Notifies you via macOS native dialogs with risk level and recommended strategy
- Syncs your branch (rebase or merge) with automatic stash/unstash
- Handles conflicts — offers manual resolution, AI-assisted (Claude Code), or abort
Requirements
- Node.js >= 18
- Claude Code (MCP host)
- Ollama running locally (optional — falls back to heuristics if unavailable)
- macOS (notifications use
osascript)
Installation
Automatic (recommended)
curl -fsSL https://raw.githubusercontent.com/Mamisedra/git-sync-guardian/main/install.sh | bash
This will clone to ~/.git-sync-guardian, build, and register the MCP server in Claude Code automatically.
To install in a custom directory:
curl -fsSL https://raw.githubusercontent.com/Mamisedra/git-sync-guardian/main/install.sh | bash -s -- /path/to/install
Manual
git clone https://github.com/Mamisedra/git-sync-guardian.git
cd git-sync-guardian
npm install
npm run build
Then add to your ~/.claude.json:
{
"mcpServers": {
"git-sync-guardian": {
"command": "node",
"args": ["/absolute/path/to/git-sync-guardian/dist/index.js"]
}
}
}
Restart Claude Code to load the server.
Usage
Git Sync Guardian exposes 4 tools in Claude Code:
init-sync — Start monitoring
> Use init-sync on /path/to/my-repo
| Parameter | Default | Description |
|---|---|---|
repoPath |
required | Absolute path to the git repo |
baseBranch |
main |
Branch to watch |
remoteName |
origin |
Git remote name |
intervalMinutes |
30 |
Check interval in minutes |
Note: You must be on a feature branch (not main) to start monitoring.
status — Check current state
> Check git-sync-guardian status
Shows: monitoring state, divergence info, last analysis (strategy, risk level, conflict probability).
sync-now — Immediate sync
> Run sync-now
| Parameter | Default | Description |
|---|---|---|
strategy |
auto |
rebase, merge, or auto (uses AI recommendation) |
Performs: fetch → stash → rebase/merge → unstash. Detects conflicts and offers resolution options.
stop-sync — Stop monitoring
> Stop git-sync-guardian
How the AI analysis works
When divergence is detected, the diff is sent to a local Ollama model which returns:
- Strategy:
rebase(clean history) ormerge(safer for conflicts) - Risk level:
low/medium/high - Conflict likelihood: 0–100%
- Reasoning: Short explanation
If Ollama is unavailable, a heuristic fallback kicks in:
- No common files modified → rebase, low risk
- Common files modified → risk assessment based on overlap
- Many commits behind (>20) → merge preferred
Configuration
Environment variables:
| Variable | Default | Description |
|---|---|---|
GSG_OLLAMA_URL |
http://localhost:11434 |
Ollama API endpoint |
GSG_OLLAMA_MODEL |
qwen2.5vl |
Ollama model for analysis |
GSG_LOG_LEVEL |
info |
Log level: debug, info, warn, error |
Architecture
src/
index.ts # MCP server entry point
server.ts # Tool registration (4 tools)
core/
sync-monitor.ts # Main monitoring loop & sync orchestration
git-operations.ts # Git commands (fetch, rebase, merge, stash)
diff-analyzer.ts # Ollama AI analysis + heuristic fallback
notifier.ts # macOS native notifications (osascript)
types/
index.ts # TypeScript interfaces & enums
utils/
config.ts # Default configuration
logger.ts # Structured stderr logger
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.