git-context-mcp
Provides tools for interacting with local Git repositories, supporting operations like clone, status, diff, branch management, commit, push, pull, and more.
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-context-mcpshow the status of the current repository"
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 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
Related MCP server: chatgpt-codex-local-mcp
Available Tools
git_clone: Clone a Git repositorygit_status: Get the status of the repositorygit_diff: Get the diff of the repository (supports staged files)git_list_branches: List local and remote branchesgit_checkout: Switch between branches and update filesgit_list_files: List files in the repositorygit_read_file: Read the content of a file (with path traversal protection)git_add: Add files to the staging areagit_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 repositorygit_push: Push changes to remote (automatically performspull --rebasefirst)git_log: Get the commit log of the repositorygit_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
Install dependencies:
npm installBuild:
npm run buildRun:
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.tsThe 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.tsBuilding
npm run buildWatching for Changes
npm run watchPrerequisites
Node.js 18+
Git
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
MCP server for siGit (sigit.si): browse repos, search code, manage PRs/issues, web search.
Related MCP Servers
- FlicenseAqualityDmaintenanceMCP server for managing Git operations on local repositories, allowing users to list repositories, get and create tags, list commits, push tags, and refresh repositories through a standardized interface.63-
- FlicenseAqualityDmaintenanceA secure MCP server that exposes local repository context to ChatGPT/Codex with read-only access, path validation, and no generic shell.17-
- AlicenseNot gradedqualityDmaintenanceA secure, git-aware MCP server for working with local repositories, enabling file management, shell commands, and full git operations within allowed directories.100 npm1GPL 3.0
- AlicenseAqualityBmaintenanceA local MCP server that provides a safe, explicit set of Git operations for version control tasks like status, diff, branching, staging, committing, fetching, merging, and pushing.1318 npmMIT