Anthropic’s MCP: Set up Git MCP Agentic Tooling with Claude Desktop
In this quick guide, I'll walk you through setting up and using Model Context Protocol (MCP) Git integration with Claude Desktop. This powerful tooling enables Claude to analyze and interact with your Git repositories directly, providing advanced code analysis and version control capabilities. We'll cover everything from basic setup to advanced use cases, troubleshooting, and best practices. Let's start by understanding what MCP is and why it's important.
Here's what we'll cover in this quick guide:
Background Information on MCP - Anthropic’s Agentic Tooling
Anthropic recently introduced the Model Context Protocol (MCP), an open-source standard that aims to revolutionize how AI assistants interact with data sources. This innovative protocol provides a unified framework, replacing previously fragmented systems. With Anthropic’s MCP, developers can efficiently expose data through servers or create AI applications that connect to these servers, significantly enhancing AI models’ ability to generate contextually relevant responses. While offering substantial benefits, the protocol has encountered scrutiny over privacy and data security concerns.
The Model Context Protocol (MCP) consists of three core components that work together seamlessly. As IKANGAI's overview describes, servers function as data gateways, exposing resources, tools, and prompts from various sources like databases and code repositories. Clients, typically AI-powered tools, communicate with these servers to access the exposed data and functionalities. According to the MCP Quickstart guide, hosts are applications that initiate server connections, discover their capabilities, and strategically utilize them to solve user problems. The system operates through a secure protocol layer that facilitates message exchanges using JSON-RPC 2.0, as detailed in Anthropic's introduction to MCP.
In the Model Context Protocol (MCP), the host and client serve distinct roles. According to the MCP Quickstart guide, the host application (like Claude Desktop) initiates connections to servers and discovers their capabilities to address user needs. The client operates within the host application, managing server connections and ensuring seamless access to data and functionalities (Metadocs' overview,). Put simply, while the host orchestrates the interactions, the client handles the technical execution.
This is the 3rd article in this series. Be sure to check out Setting up Claude with Brave Search and Setting up Claude Filesystem MCP. In this guide, I will also cover some of the challenges of using MCP and some common workarounds.
Check out this article on my site for better formatting.
Setting Up MCP Agentic Tooling - Git Integration
Now that we have some background on MCP is and how it works, let's walk through the process of setting up Git integration with Claude Desktop. This setup will allow Claude to analyze and interact with your Git repositories directly, providing powerful code analysis and version control capabilities. We'll cover everything from basic requirements to advanced configurations.
Prerequisites
Installing uvx
% brew search uvx
% brew install uv
% uvx --version
uv-tool-uvx 0.5.5 (Homebrew 2024-11-27)
To install and use uvx, you first need to install the uv package manager. The steps are:
Note that uvx is a tool built on top of uv, so having uv properly installed first is essential. The uv package manager is recommended over pip for its improved performance and dependency resolution.
If you encounter any issues during installation, make sure:
💡 What is uv?
uv is a modern Python package and project management tool, written in Rust, designed to streamline Python development. It serves as a fast and unified alternative to various existing Python tools such as pip, pipx, pyenv, poetry, and others. One of its key features is uvx, which functions similarly to pipx.
What is uvx? uvx is a command provided by uv for running Python tools or scripts without requiring explicit installation. It creates temporary, isolated virtual environments for the execution of these tools, ensuring minimal setup and cleanup after execution. This makes it particularly useful for one-off tool usage.
Why use uv and uvx? The broader appeal of uv lies in its ability to unify multiple aspects of Python development: • Dependency Management: Handles dependencies efficiently using a fast resolver • Python Installation: Automatically installs required Python versions • Virtual Environments: Simplifies creation and management of virtual environments • Tool Management: Provides a centralized way to manage command-line tools via uv tool install or ephemeral execution via uvx
In summary, uvx is an efficient, user-friendly alternative to tools like pipx, offering speed, flexibility, and seamless integration with the broader capabilities of the uv ecosystem. We use in this article because the Anthropic’s tools are built with it.
Installation Steps
1. Create/Edit Configuration File
First, we need to locate or create the Claude Desktop configuration file:
For macOS:
# Configuration path
~/Library/Application Support/Claude/claude_desktop_config.json
For Windows:
# Configuration path
%APPDATA%\\Claude\\claude_desktop_config.json
2. Configure MCP Git Server
Add the following configuration to your claude_desktop_config.json:
{
"mcpServers": {
"git": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository",
"/path/to/your/git/repo"
]
}
}
}
Replace /path/to/your/git/repo with the actual path to the Git repository you want to analyze.
3. Install the Git MCP Server
Open your terminal and run:
# Using uv (recommended)
uv tool install mcp-server-git
uv tool update-shell
4. Verify Installation
Could you show me the recent commits in my repository?
Features Available
The Git MCP server provides several capabilities:
Troubleshooting
Common Issues and Solutions
Debug Steps
git --version
cd /path/to/your/git/repo
git status
uvx mcp-server-git --repository /path/to/your/git/repo
Additional Configuration Options
For more advanced setups, you can add additional parameters to the configuration:
{
"mcpServers": {
"git": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/path/to/your/git/repo",
"--branch", "main",
"--depth", "100"
]
}
}
}
Use Cases
I'll walk through some powerful capabilities of the Git MCP integration with practical examples. Later we will cover some actual sessions and I can tell you where there are some pitfalls.
Code Analysis and Understanding
Code History Analysis
Author Contributions
Impact Analysis
Development Insights
Bug Pattern Detection
Feature Development Tracking
Code Quality Analysis
Repository Management
Branch Analysis
Merge History
Release Analysis
Documentation and Knowledge Management
Documentation Updates
Change Documentation
Best Practices Analysis
Advanced Search and Analysis
Complex Code Search
Pattern Recognition
Security Analysis
Team Collaboration Insights
Work Patterns
Code Review Insights
Knowledge Distribution
Project Health Metrics
Codebase Growth
Refactoring Impact
Test Coverage Evolution
Practical Tips for Advanced Usage
Working with multiple git repos
Let me explain how MCP handles multiple Git repositories through configuration.
When setting up multiple Git repositories, you need to give each repository a unique identifier in your configuration. Here's how it works:
{
"mcpServers": {
"git-project1": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/path/to/first/repo"
]
},
"git-project2": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/path/to/second/repo"
]
},
"git-project3": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/path/to/third/repo"
]
}
}
}
Key Points:
Recommended by LinkedIn
Example Working Configuration:
{
"mcpServers": {
"main-app": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/Users/me/projects/main-application",
"--branch", "main"
]
},
"api-service": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/Users/me/projects/api-service",
"--branch", "develop"
]
},
"documentation": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository", "/Users/me/projects/docs",
"--branch", "main"
]
}
}
}
Then in your interactions with Claude Desktop, you can be specific:
"Show me the recent commits in the api-service repository"
"What changes were made to the documentation repository last week?"
"Compare the test coverage between main-app and api-service"
This can get confusing if you have too many MCP server tools installed at once. I had a really hard time getting Claude to select the correct Git repo, as it would get confused between the GitHub tool, the filesystem tools, and the Git tools. You have to be fairly specific in your prompts to get it to work when multiple tools are installed. I assume this will get better over time, or I will get better at it. But it is not all roses and rainbows.
Debugging
When debugging issues with Claude MCP (Model Context Protocol) servers, particularly when they fail to use installed MCP servers, follow these systematic troubleshooting steps:
1. Verify Configuration
2. Check Server Logs
3. Use Debugging Tools
4. Common Issues and Solutions
5. Restart and Test
If you continue experiencing issues after following these steps, reach out through official support channels or community forums for additional assistance.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"--allow-write",
"/Users/richardhightower/src",
"/Users/richardhightower/clients"
]
},
"brave-search": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-brave-search"
],
"env": {
"BRAVE_API_KEY": "MY_ACTUAL_KEY"
}
},
"git-markdown": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository",
"/Users/richardhightower/src/project-markdown-creator"
]
},
"git-meeting-buddy": {
"command": "uvx",
"args": [
"mcp-server-git",
"--repository",
"/Users/richardhightower/src/meeting_buddy/pythonProject"
]
}
}
}
Claude Desktop
Once you install and restart the Claude Desktop, you should see the following tools:
Git
git_add
Adds file contents to the staging area
From server: git-meeting-buddy
git_commit
Records changes to the repository
From server: git-meeting-buddy
git_create_branch
Creates a new branch from an optional base branch
From server: git-meeting-buddy
git_diff_staged
Shows changes that are staged for commit
From server: git-meeting-buddy
git_diff_unstaged
Shows changes in the working directory that are not yet staged
From server: git-meeting-buddy
git_log
Shows the commit logs
From server: git-meeting-buddy
git_reset
Unstages all staged changes
From server: git-meeting-buddy
git_status
Shows the working tree status
From server: git-meeting-buddy
Open Claude Desktop and click the tools icon (hammer symbol) in the bottom right corner of the initial chat window. This will show you that the Git MCP Server Plugins are installed.
You should see the following tools for Git MCP Server Plugins tools.
Check out the article on my site for better formatting.
Sample Session 1
RH (Me):
Could you show me the recent commits in my repository?
Claude:
I'll need the path to your repository to check the commit history. Could you provide the repository path?
RH:
"git-meeting-buddy": { "command": "uvx", "args": [ "mcp-server-git", "--repository", "/Users/richardhightower/src/meeting_buddy/pythonProject" ] },
Claude:
I'll check the commit history of your repository at /Users/richardhightower/src/meeting_buddy/pythonProject.
View Result from git_log from git-meeting-buddy (local)
{ repo_path: /Users/richardhightower/src/meeting_buddy/pythonProject }
`Commit history: Commit: 98eec5eeaeb42efffe38ee22a1b1f5fac099144e Author: Rick Hightower Date: 2024-12-04 15:40:55-06:00 Message: improved recordign so it restarts if there are any issues
Commit: f1a84b3f252fbb8ca604ac45a1e0bf65a728119b Author: Rick Hightower Date: 2024-11-19 08:12:00-06:00 Message: fixed broken all.md ref
Commit: c166784576b08087dfd0a473e17cdc3f031317f8 Author: Rick Hightower Date: 2024-11-13 18:34:40-07:00 Message: update to markdown
Commit: 7192ec2ca52cbdb7ca17d082815711b3645a07d2 Author: Rick Hightower Date: 2024-11-13 08:37:33-07:00 Message: meeting notes
Commit: d74e1541b52c98dc865c261236985cbbd96aa94d Author: Rick Hightower Date: 2024-10-31 12:20:36-05:00 Message: updated clean to create context files to begin
Commit: fb248cbd855bf7c652bdbf0550889cf9fd9fb6c3 Author: Rick Hightower Date: 2024-10-30 11:14:54-05:00 Message: new branch
Commit: e20bcffb44a6d14ec692a70c4783d9a3c020aeda Author: Rick Hightower Date: 2024-10-29 15:33:30-05:00 Message: improved question simulation
Commit: 8e96a3b0e3571da2e7764caa25d41c729606529b Author: Rick Hightower Date: 2024-10-29 14:52:06-05:00 Message: added a new tab to view question answer status
Commit: 85d5bddfe6685b0a0c83fc44c1cbb02708bc933d Author: Rick Hightower Date: 2024-10-29 14:33:24-05:00 Message: initial attempt at adding question status
Commit: 36fa5085b777dafde19470de9566f61c74970d09 Author: Rick Hightower Date: 2024-10-29 01:47:58-05:00 Message: added ability to detect and answer reasoning questions`
Claude
The most recent commit (Dec 4) improved recording restart functionality. Earlier commits show work on markdown updates, meeting notes, and question-answering features. Would you like to see any specific commit details?
Notice that Claude needed clarification about which repository to use. When you have multiple repositories or tools configured, it's helpful to provide more specific context upfront, as demonstrated in the following session. I found having less MCP tools/servers installed meant Claude got confused less.
In this next session, I am more specific in what I ask for and Claude knows right away.
Sample Session 2
RH:
Could you show me the recent commits in my git repository (/Users/richardhightower/src/meeting_buddy/pythonProject)?
Claude:
View Result from git_log from git-meeting-buddy (local)
{ repo_path: /Users/richardhightower/src/meeting_buddy/pythonProject }
`Commit history: Commit: 98eec5eeaeb42efffe38ee22a1b1f5fac099144e Author: Rick Hightower Date: 2024-12-04 15:40:55-06:00 Message: improved recordign so it restarts if there are any issues
Commit: f1a84b3f252fbb8ca604ac45a1e0bf65a728119b Author: Rick Hightower Date: 2024-11-19 08:12:00-06:00 Message: fixed broken all.md ref
Commit: c166784576b08087dfd0a473e17cdc3f031317f8 Author: Rick Hightower Date: 2024-11-13 18:34:40-07:00 Message: update to markdown
Commit: 7192ec2ca52cbdb7ca17d082815711b3645a07d2 Author: Rick Hightower Date: 2024-11-13 08:37:33-07:00 Message: meeting notes
Commit: d74e1541b52c98dc865c261236985cbbd96aa94d Author: Rick Hightower Date: 2024-10-31 12:20:36-05:00 Message: updated clean to create context files to begin
Commit: fb248cbd855bf7c652bdbf0550889cf9fd9fb6c3 Author: Rick Hightower Date: 2024-10-30 11:14:54-05:00 Message: new branch
Commit: e20bcffb44a6d14ec692a70c4783d9a3c020aeda Author: Rick Hightower Date: 2024-10-29 15:33:30-05:00 Message: improved question simulation
Commit: 8e96a3b0e3571da2e7764caa25d41c729606529b Author: Rick Hightower Date: 2024-10-29 14:52:06-05:00 Message: added a new tab to view question answer status
Commit: 85d5bddfe6685b0a0c83fc44c1cbb02708bc933d Author: Rick Hightower Date: 2024-10-29 14:33:24-05:00 Message: initial attempt at adding question status
Commit: 36fa5085b777dafde19470de9566f61c74970d09 Author: Rick Hightower Date: 2024-10-29 01:47:58-05:00 Message: added ability to detect and answer reasoning questions`
These are the 10 most recent commits in your repository. The latest commit from December 4th improves recording functionality, with earlier commits including markdown updates, meeting notes, and various feature additions like question simulation and status tracking.
Sample Session 3
RH:
Using this MCP Tool:
"git-meeting-buddy": {
"command": "uvx", "args": [ "mcp-server-git", "--repository", "/Users/richardhightower/src/meeting_buddy/pythonProject" ] }, ....
What files were most frequently changed in the last month? Can you identify potential hotspots in the codebase?
Claude:
Let me analyze the git repository to identify frequently changed files and potential hotspots.
View Result from git_log from git-meeting-buddy (local)
Let me get the specific files changed in these commits.
View Result from git_status from git-meeting-buddy (local)
Based on the commit history, here are the key findings:
To get more specific file-level hotspots, I'd recommend:
Based on the commit messages alone, the codebase shows concentrated activity around:
Would you like me to analyze any specific component in more detail?
Claude experienced some issues because I had multiple servers installed: filesystem, several GitHub servers, and several Git servers. I needed to explicitly specify which MCP tool I wanted Claude to use—and even then, it would sometimes pick the wrong one. I worked around this by reducing the number of active tools. Since MCP is still very new, I expect these issues will improve over time. It may just be a matter of refining the prompt engineering to achieve flawless performance.
Conclusion
Setting up and using Model Context Protocol (MCP) Git integration with Claude Desktop offers powerful capabilities for code analysis and repository interaction. While the technology is still in its early stages and may present some challenges with multiple tool configurations, the potential benefits are significant.
Key takeaways from implementing MCP Git integration include:
As MCP continues to develop, it promises to become an increasingly valuable tool for developers working with AI assistants like Claude, enabling more sophisticated code analysis and version control integration.
About the Author
Meet Rick Hightower, a software architect and tech wizard with over three decades of experience in building enterprise software. He’s also a TensorFlow Certified Developer and a Stanford University grad with a specialization in Machine Learning/AI. Rick is all about advancing AI and data engineering, and he’s got a knack for sharing his knowledge through technical publications and contributing to open-source projects.
Rick has been at the forefront of AI innovation lately, focusing on big data engineering and creating AI-powered solutions. He’s been working on some really cool projects, like:
As a mentor and thought leader, Rick has spoken at conferences and seminars sharing his ideas on how AI, data engineering, and enterprise software are going to change the world. He has a practical approach to solving tough problems, and he’s really respected in the tech community.
Recent articles by Rick