git
by: modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
📌Overview
Purpose: To facilitate interaction and automation with Git repositories through a Model Context Protocol server using Large Language Models.
Overview: The mcp-server-git is designed to provide comprehensive tools for reading, searching, and manipulating Git repositories efficiently. Currently in early development, the server's features will evolve to deliver enhanced capabilities over time.
Key Features:
-
git_status: Displays the current working tree status of a Git repository, helping users understand their repository's state.
-
git_commit: Enables users to record changes to the repository with a commit message, providing a unique commit hash upon success.
-
git_diff: Allows users to compare current differences against a specific branch or commit, facilitating better version control and review processes.
-
git_log: Shows commit history with details like author and message, which aids in tracking project progress and decisions.
-
git_create_branch: Simplifies branch creation for branching strategies, enhancing workflow flexibility.
mcp-server-git: A git MCP server
Overview
A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
Please note that mcp-server-git is currently in early development. The functionality and available tools are subject to change and expansion.
Tools
-
git_status
- Shows the working tree status
- Input:
repo_path
(string): Path to Git repository
- Returns: Current status of working directory as text output
-
git_diff_unstaged
- Shows changes in working directory not yet staged
- Input:
repo_path
(string): Path to Git repository
- Returns: Diff output of unstaged changes
-
git_diff_staged
- Shows changes that are staged for commit
- Input:
repo_path
(string): Path to Git repository
- Returns: Diff output of staged changes
-
git_diff
- Shows differences between branches or commits
- Inputs:
repo_path
(string): Path to Git repositorytarget
(string): Target branch or commit to compare with
- Returns: Diff output comparing current state with target
-
git_commit
- Records changes to the repository
- Inputs:
repo_path
(string): Path to Git repositorymessage
(string): Commit message
- Returns: Confirmation with new commit hash
-
git_add
- Adds file contents to the staging area
- Inputs:
repo_path
(string): Path to Git repositoryfiles
(string[]): Array of file paths to stage
- Returns: Confirmation of staged files
-
git_reset
- Unstages all staged changes
- Input:
repo_path
(string): Path to Git repository
- Returns: Confirmation of reset operation
-
git_log
- Shows the commit logs
- Inputs:
repo_path
(string): Path to Git repositorymax_count
(number, optional): Maximum number of commits to show (default: 10)
- Returns: Array of commit entries with hash, author, date, and message
-
git_create_branch
- Creates a new branch
- Inputs:
repo_path
(string): Path to Git repositorybranch_name
(string): Name of the new branchstart_point
(string, optional): Starting point for the new branch
- Returns: Confirmation of branch creation
-
git_checkout
- Switches branches
- Inputs:
repo_path
(string): Path to Git repositorybranch_name
(string): Name of branch to checkout
- Returns: Confirmation of branch switch
-
git_show
- Shows the contents of a commit
- Inputs:
repo_path
(string): Path to Git repositoryrevision
(string): The revision (commit hash, branch name, tag) to show
- Returns: Contents of the specified commit
-
git_init
- Initializes a Git repository
- Inputs:
repo_path
(string): Path to directory to initialize git repo
- Returns: Confirmation of repository initialization
Installation
Using uv (recommended)
When using uv no specific installation is needed. Use uvx to directly run mcp-server-git.
Using PIP
You can install mcp-server-git
via pip:
pip install mcp-server-git
After installation, run it as a script using:
python -m mcp_server_git
Configuration
Usage with Claude Desktop
Add this to your claude_desktop_config.json
:
Using uvx
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "path/to/git/repo"]
}
}
Using docker
- Note: replace '/Users/username' with a path accessible by this tool
"mcpServers": {
"git": {
"command": "docker",
"args": ["run", "--rm", "-i", "--mount", "type=bind,src=/Users/username,dst=/Users/username", "mcp/git"]
}
}
Using pip installation
"mcpServers": {
"git": {
"command": "python",
"args": ["-m", "mcp_server_git", "--repository", "path/to/git/repo"]
}
}
Usage with Zed
Add to your Zed settings.json:
Using uvx
"context_servers": [
"mcp-server-git": {
"command": {
"path": "uvx",
"args": ["mcp-server-git"]
}
}
],
Using pip installation
"context_servers": {
"mcp-server-git": {
"command": {
"path": "python",
"args": ["-m", "mcp_server_git"]
}
}
},
Debugging
Use the MCP inspector to debug the server. For uvx installations:
npx @modelcontextprotocol/inspector uvx mcp-server-git
Or during development:
cd path/to/servers/src/git
npx @modelcontextprotocol/inspector uv run mcp-server-git
Monitoring logs may help debug issues:
tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
Development
For local development, test your changes by:
-
Running the MCP inspector (see Debugging section).
-
Testing with the Claude desktop app by modifying
claude_desktop_config.json
:
Docker
{
"mcpServers": {
"git": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
"--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
"--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
"mcp/git"
]
}
}
}
UVX
{
"mcpServers": {
"git": {
"command": "uv",
"args": [
"--directory",
"/<path to mcp-servers>/mcp-servers/src/git",
"run",
"mcp-server-git"
]
}
}
}
Build
Docker build:
cd src/git
docker build -t mcp/git .
License
This MCP server is licensed under the MIT License. You are free to use, modify, and distribute the software under the terms of the MIT License. See the LICENSE file in the project repository for details.