Git MCP Server
An MCP server for performing Git operations.
Git MCP Server
A Model Context Protocol (MCP) server for Git operations that provides comprehensive Git functionality to MCP clients like Claude Desktop.
Features
- Context-aware: Automatically detects the current project based on working directory
- Comprehensive Git operations: status, branches, diffs, logs, file contents, commits, and more
- Multi-project support: Works seamlessly across different project directories
- Error handling: Proper MCP error responses
- Branch management: Create, switch, and manage branches
- Remote operations: Push, pull, and fetch from remote repositories
Installation
Option 1: Global Installation (Recommended)
npm install -g git-mcp-server
Option 2: Local Development Setup
-
Clone and install:
git clone https://github.com/yourusername/git-mcp-server.git cd git-mcp-server npm install -
Build the project:
npm run build
Configuration
Claude Desktop
Add this server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"git": {
"command": "git-mcp-server",
"args": []
}
}
}
Other MCP Clients
For other MCP clients, use the server binary directly:
git-mcp-server
The server will automatically use the current working directory as the Git repository context.
Usage
Once configured, you can use Git operations through your MCP client. The server automatically detects the Git repository in your current working directory.
Example Commands
Ask your MCP client (like Claude) to perform Git operations:
- "What's the current git status?"
- "Show me the diff with the main branch"
- "Create a new branch called feature/new-feature"
- "Commit these changes with message 'Fix bug in parser'"
- "Push the current branch to origin"
Testing the Server
You can test the server manually from any Git repository:
cd /path/to/your/git/repo
git-mcp-server
Available Tools
Repository Information
git_status- Get current git statusgit_current_branch- Get current branch namegit_staged_changes- Get staged changesgit_working_directory- Get current working directory info
File and History Operations
git_diff- Show diff between branches/commitsgit_log- Get commit historygit_show_file- Show file contents at specific commit
Branch Operations
git_branches- List all branchesgit_checkout- Switch to different branch or create new branch
Staging and Commit Operations
git_add- Add files to staging areagit_commit- Create commits with message and files
Remote Operations
git_pull- Pull changes from remote repositorygit_fetch- Fetch changes from remote without merging
Repository Management
git_init- Initialize a new git repository
Prerequisites
- Node.js 18+
- npm or yarn
- Git installed on your system
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Project Structure
git-mcp-server/
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── src/
│ └── index.ts # Main server implementation
├── build/
│ └── index.js # Compiled JavaScript (generated)
└── README.md # This file
Development
npm run build- Build the TypeScript codenpm run dev- Watch mode for developmentnpm start- Run the built server
Related Servers
Git
Tools to read, search, and manipulate Git repositories
GitHub Repos Manager MCP Server
Token-based GitHub automation management. No Docker, Flexible configuration, 80+ tools with direct API integration.
GitMCP
Transforms any GitHub project into a documentation hub, enabling AI tools to access up-to-date documentation and code.
GitHub Explorer MCP
Explore GitHub repositories, including file content, directory structure, and other metadata.
GitHub GraphQL API
Query and interact with the GitHub GraphQL API. Requires a personal access token.
GitLab Kanban
A server for managing GitLab Kanban board operations.
MCP Git Repo Browser
A Git repository browser that allows you to navigate and inspect local Git repositories using the Model Context Protocol.
Bitbucket
Access the Bitbucket Cloud API for automation, CI/CD pipelines, and integrations.
GitHub Pages MCP Server
Hello! This is a GitHub MCP server designed to enable MCP-compatible LLMs, such as Claude, to communicate with the server and interact with the GitHub API to manage GitHub Pages deployments.
Bitbucket
Manage Bitbucket repositories, pull requests, and pipelines via the Bitbucket API for both Cloud and Server.