A Model Context Protocol (MCP) server that provides Git operations through standardized tools. This server allows AI assistants and other MCP clients to interact with Git repositories programmatically.
This MCP server exposes four main Git operations as MCP tools:
git_add
- Add files to the Git staging area with support for specific files, all files, interactive mode, and patch modegit_commit
- Create commits with custom messages, support for staging all files, and amend functionalitygit_push
- Push commits to remote repositories with configurable remote, branch, force push, and upstream trackinggit_status
- Get the current status of a Git repository to see what files can be added
All tools support:
- Working with any Git repository by specifying a
repository_path
- Comprehensive error handling and timeout protection
- Detailed response information including command output and status
- Python 3.12 or higher
- Git installed on your system
- uv package manager (recommended) or pip
- Clone this repository:
git clone <repository-url>
cd git-mcp-server
- Install dependencies using uv (recommended):
uv sync
Or using pip:
pip install -e .
Run the server directly:
python main.py
The server will start on http://0.0.0.0:5001
by default.
For production use, you can run it with a WSGI server like gunicorn:
uv run gunicorn main:mcp.app -b 0.0.0.0:5001
To use this MCP server with Cursor, you need to configure it in your Cursor settings:
- Open Cursor settings (Cmd/Ctrl + ,)
- Navigate to "Features" → "Model Context Protocol"
- Add a new MCP server configuration:
{
"mcpServers": {
"git-mcp-server": {
"command": "python",
"args": ["/absolute/path/to/your/git-mcp-server/main.py"],
"env": {}
}
}
}
Replace /absolute/path/to/your/git-mcp-server/main.py
with the actual absolute path to your main.py
file.
If you prefer to run the server as a standalone HTTP service:
{
"mcpServers": {
"git-mcp-server": {
"command": "uv",
"args": ["run", "python", "/absolute/path/to/your/git-mcp-server/main.py"],
"env": {}
}
}
}
- Restart Cursor to load the new MCP server
- The Git tools should now be available in your Cursor chat interface
Once configured in Cursor, you can use the Git tools in your chat:
- "Add all modified files to staging"
- "Commit the staged changes with message 'Fix bug in user authentication'"
- "Push the current branch to origin"
- "Show me the git status of this repository"
Add files to the Git staging area.
Parameters:
files
(optional): Space-separated list of file pathsall_files
(bool): Add all modified files (default: False)interactive
(bool): Interactive mode (default: False)patch
(bool): Patch mode (default: False)repository_path
(optional): Path to git repository
Create a Git commit.
Parameters:
message
(required): Commit messageall_files
(bool): Stage all files before committing (default: False)amend
(bool): Amend previous commit (default: False)repository_path
(optional): Path to git repository
Push commits to remote repository.
Parameters:
remote
(str): Remote name (default: "origin")branch
(optional): Branch name (defaults to current branch)force
(bool): Force push (default: False)set_upstream
(bool): Set upstream tracking (default: False)repository_path
(optional): Path to git repository
Get Git repository status.
Parameters:
repository_path
(optional): Path to git repository
- The server runs Git commands with the same permissions as the user running it
- Be cautious with
force
push operations - The server validates repository paths and checks for Git repositories before executing commands
- All commands have timeout protection (10-120 seconds depending on operation)
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
[Add your license information here]