Model Context Protocol Git Server
mcp-server-git is a Model Context Protocol (MCP) server designed to enable Large Language Models (LLMs) and AI agents to interact with Git repositories programmatically. It provides tools for reading, searching, and manipulating Git repositories. As of version 2026.1.14, it is actively developed, though still in early stages, with frequent updates often addressing security and functionality enhancements.
Warnings
- breaking The `git_init` tool was removed due to a path traversal vulnerability. The server is now intended to operate exclusively on *existing* Git repositories, not to initialize new ones at arbitrary filesystem locations.
- breaking Argument injection vulnerabilities were present in `git_diff` and `git_checkout` functions, allowing user-controlled arguments to be interpreted as CLI options, potentially leading to arbitrary file overwrites.
- gotcha Path traversal vulnerability in `git_add` allowed staging files outside the designated repository boundaries using relative paths (e.g., `../`). This could enable exfiltration of sensitive files via subsequent Git operations.
- gotcha Missing path validation when the server was started with the `--repository` flag. This allowed tool calls to operate on repositories outside the explicitly configured path.
- gotcha The library is explicitly stated to be in 'early development', meaning functionality and available tools are subject to frequent change and expansion.
Install
-
pip install mcp-server-git -
uvx mcp-server-git
Imports
- mcp-server-git
The library is primarily a server process, not intended for direct programmatic import by end-user applications for its core functionality. It is run as a standalone service.
Quickstart
# Start the mcp-server-git in a Git repository context
# (Replace /path/to/your/git/repo with an actual Git repository path)
cd /path/to/your/git/repo
mcp-server-git
# Example MCP client configuration (e.g., for VS Code .vscode/mcp.json or user mcp.json)
# This tells an MCP-compatible client how to connect to the server.
# Note: The 'command' path might need to be absolute depending on your environment.
{
"servers": {
"git": {
"command": "mcp-server-git",
"args": [],
"env": {
"GIT_DEFAULT_PATH": "${input:git_repo_path}"
}
}
},
"inputs": [
{
"type": "promptString",
"id": "git_repo_path",
"description": "Path to Git Repository",
"default": "/path/to/your/git/repo"
}
]
}