Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

A secure MCP server for local Git operations with path traversal protection, input validation, and 15 supported Git commands.

README.md

Git MCP Server

A Model Context Protocol (MCP) server for local Git operations with security and validation.

Features

  • 🔒 Secure: Path traversal protection and input validation
  • Validated: Runtime Zod validation for all inputs
  • ⏱️ Timeout Protection: Configurable timeouts prevent indefinite blocking
  • 🛠️ Complete: 15 Git operations supported
  • 📝 Well-tested: Comprehensive integration test suite

Available Tools

  • git_clone: Clone a Git repository
  • git_status: Get the status of the repository
  • git_diff: Get the diff of the repository (supports staged files)
  • git_list_branches: List local and remote branches
  • git_checkout: Switch between branches and update files
  • git_list_files: List files in the repository
  • git_read_file: Read the content of a file (with path traversal protection)
  • git_add: Add files to the staging area
  • git_reset: Reset current HEAD to the specified state (supports soft, mixed, hard)
  • git_pull: Pull changes from remote (uses rebase)
  • git_commit: Commit changes to the repository
  • git_push: Push changes to remote (automatically performs pull --rebase first)
  • git_log: Get the commit log of the repository
  • git_create_branch: Create a new branch (optionally from a specific starting point)
  • git_merge: Merge a branch into the current branch (supports --no-ff)

Setup

  1. Install dependencies:
   npm install
  1. Build:
   npm run build
  1. Run:
   npm run start

Configuration Examples

Claude Desktop

{
  "mcpServers": {
    "git-mcp-server": {
      "command": "node",
      "args": ["/absolute/path/to/git-context-mcp/dist/index.js"]
    }
  }
}

Cline / Windsurf

{
  "mcpServers": {
    "git-mcp-server": {
      "command": "npx",
      "args": ["-y", "git-mcp-server"]
    }
  }
}

Usage Examples

Clone a Repository

{
  "tool": "git_clone",
  "arguments": {
    "repoUrl": "https://github.com/user/repo.git",
    "localPath": "/path/to/local/repo"
  }
}

Read a File

{
  "tool": "git_read_file",
  "arguments": {
    "repoPath": "/path/to/repo",
    "filePath": "src/index.ts"
  }
}

Create and Checkout a Branch

{
  "tool": "git_create_branch",
  "arguments": {
    "repoPath": "/path/to/repo",
    "branch": "feature/new-feature",
    "checkout": true
  }
}

Security

  • Path Traversal Protection: File paths are validated to prevent access outside the repository
  • Input Validation: All inputs are validated with Zod schemas before processing
  • Error Handling: Proper error context preservation throughout the stack
  • Timeout Protection: Operations have configurable timeouts (30s default, 60s for clone)

Testing

Run the integration test suite to verify all Git tools work correctly:

npx tsx test_script.ts

The script creates temporary local repositories, exercises all 15 tools plus error handling scenarios, and cleans up automatically.

Troubleshooting

Error: "Path does not exist"

Ensure the repository path exists and is accessible.

Error: "File path must be within the repository"

The requested file path is outside the repository boundaries. This is a security feature to prevent directory traversal attacks.

Timeout errors

Operations have a 30-second timeout by default (60 seconds for clone). For very large repositories or slow networks, operations may timeout. This is a safety feature to prevent indefinite blocking.

Error: "Git pull --rebase failed"

The rebase was automatically aborted to restore the repository to a clean state. Check for uncommitted changes or conflicts.

Development

Running Tests

npx tsx test_script.ts

Building

npm run build

Watching for Changes

npm run watch

Prerequisites

  • Node.js 18+
  • Git

License

MIT

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Developer Tools servers.