MCP Directory
All Tutorials

How to Install the Git MCP Server

Connect your AI assistant to a local Git repository with the official Git MCP reference server.

OVERVIEW The Git MCP Server is an official Python reference implementation in modelcontextprotocol/servers. The repository README summarizes it as providing "Tools to read, search, and manipulate Git repositories." It lets assistants inspect history, search commits, and perform repository-aware operations scoped to a single local repo path. Install commands in this tutorial are taken from https://github.com/modelcontextprotocol/servers — specifically the Python server section recommending uvx. WHAT IT DOES Git MCP bridges the gap between generic file reads and version-control semantics. While Filesystem MCP reads working tree bytes, Git MCP understands commits, branches, logs, and repository structure. The README lists approximately ten tools for Git operations (exact names are in src/git documentation in the official repo). This server is ideal when you want the assistant to answer "what changed last week?" or "who edited this module?" without granting access to unrelated directories. PREREQUISITES - uv / uvx (recommended by the official README) OR pip with python -m mcp_server_git - A local Git repository on disk - An MCP client (Claude Desktop, Cursor, Cline, etc.) Install uv following https://docs.astral.sh/uv/getting-started/installation/ Verify: uvx --version STANDALONE INSTALL COMMAND (OFFICIAL) From the modelcontextprotocol/servers README: uvx mcp-server-git --repository path/to/git/repo Alternative pip path documented in the same README: pip install mcp-server-git python -m mcp_server_git uvx is recommended for ease of setup. CLAUDE DESKTOP CONFIGURATION (OFFICIAL EXAMPLE) The README includes Git alongside other servers: { "mcpServers": { "git": { "command": "uvx", "args": ["mcp-server-git", "--repository", "path/to/git/repo"] } } } Replace path/to/git/repo with the absolute path to your project root containing .git. WINDOWS NOTE The official README states that on Windows you wrap npx with cmd /c, but uvx entries remain unchanged. Git MCP uses uvx directly: { "mcpServers": { "git": { "command": "uvx", "args": ["mcp-server-git", "--repository", "C:\Users\you\project"] } } } Ensure Git for Windows is installed if tools shell out to git binaries. CURSOR NOTES Add Git MCP in mcp.json pointed at the workspace repository. Monorepos: usually point --repository at the git root. Multiple separate repos require multiple MCP entries with distinct names (git-frontend, git-backend). Reload MCP after config edits. CLINE NOTES Cline benefits strongly from Git MCP during refactors and bug hunts. Configure repository path to match the folder opened in VS Code. Review whether Git manipulation tools need manual approval in Cline settings. SECURITY NOTES Scoping to one repository limits exposure compared to whole-disk Filesystem access. However, Git MCP may include manipulation tools — understand which operations modify refs or working tree state. The official README classifies reference servers as educational; use client-side tool approval for write-like Git operations in production codebases. Do not point --repository at a parent folder containing unrelated sensitive repos. FAQ Q: Git MCP vs GitHub MCP? A: Git MCP is local repository operations. The archived GitHub reference server in servers-archived targeted GitHub.com API — different use case. Q: Do I still need Filesystem MCP? A: Often yes — Git for history, Filesystem for editing file contents (npx -y @modelcontextprotocol/server-filesystem /path/to/project). Q: Official command source? A: https://github.com/modelcontextprotocol/servers README. TROUBLESHOOTING Run uvx mcp-server-git --repository /your/path manually. Errors often mean invalid repo path, missing uv, or Git not installed. uvx downloads packages on first run — allow network access. COMBINING SERVERS Official README multi-server config pattern stacks Git with Filesystem and Memory. Example mental model: Git explains what changed; Filesystem applies the fix; Memory records the architectural decision. PYTHON RUNTIME DETAILS The official README positions uvx as the recommended launcher for Python reference servers because it resolves dependencies ephemerally without polluting global site-packages. pip install remains documented for users who prefer traditional virtualenv workflows. Both paths should launch the same mcp-server-git module — choose one style per machine for consistency. REPOSITORY PATH BEST PRACTICES Use absolute paths in config files. Relative paths break when the MCP client starts the server from an unexpected working directory. On Windows, forward slashes often work in uvx args and reduce escaping pain. Verify the path contains a .git directory — pointing at a subfolder without .git fails. WHEN NOT TO USE GIT MCP If you only need to read one file once, Filesystem read_text_file may suffice. If you need GitHub Issues or Pull Requests on github.com, Git MCP does not replace GitHub API servers — the GitHub reference server is archived; use registry community servers instead. EXTENDED TROUBLESHOOTING Permission denied on .git/index: ensure your user account can read the repo. Shallow clones and worktrees are supported in principle but edge cases may differ — test log tools on your clone type. If uvx hangs on first run, check antivirus scanning of temporary Python environments. WORKFLOW EXAMPLE Prompt: "Show commits touching auth/ in the last month, summarize themes, then propose a refactor plan." Git MCP supplies commit metadata; Sequential Thinking structures the plan; Filesystem applies edits; Memory stores the agreed module boundaries for next session. ADDITIONAL OFFICIAL REFERENCES The Git server source and tool list live at https://github.com/modelcontextprotocol/servers/tree/main/src/git — consult that README for the authoritative tool names and any flags beyond --repository. The monorepo README at https://github.com/modelcontextprotocol/servers remains the source for the uvx mcp-server-git --repository path/to/git/repo install line used in this tutorial.