home / mcp / git mcp server

Git MCP Server

Provides Git operations over MCP, enabling status, log, commit, push, pull, and more via standard MCP tooling.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "lileeei-mcp-git-tools": {
      "command": "cargo",
      "args": [
        "run",
        "--bin",
        "mcp-git-server"
      ]
    }
  }
}

You can run the MCP Git Tools server to interact with Git repositories through the Model Context Protocol. It exposes a set of Git operations you can invoke from MCP clients, enabling you to check status, inspect history, manage branches, and perform common actions like commit, push, and pull in an automated, protocol-driven way.

How to use

To use the MCP Git Tools server, start it as a standalone stdio server and connect from your MCP client. The server communicates through standard input/output, so you typically launch it and wire your MCP client to its process I/O. Once running, you can invoke the provided Git tool endpoints to inspect repositories, commit changes, and synchronize with remotes.

How to install

Prerequisites: you need a Rust toolchain with Cargo installed. This lets you compile and run the MCP Git Tools server.

Step-by-step commands to set up and run the server locally:

Install and run the MCP Git Tools server locally

# Clone the project
git clone https://github.com/lileeei/mcp-git-tools.git

# Navigate to the project
cd mcp-git-tools

# Build the server
cargo build

# Run the MCP Git Tools server as a stdio server
cargo run --bin mcp-git-server

Connect from an MCP client

Use your MCP client to connect via stdio to the running server. The client should create a StdioTransport to the server process and then initialize the MCP session. From there you can call the available git tools like status, branches, log, commit, pull, push, diff, add, and reset.

use mcp_client::{ client::{ClientCapabilities, ClientInfo, McpClient}, StdioTransport, Transport, McpService };
use std::collections::HashMap;
use std::time::Duration;

let transport = StdioTransport::new(
    "path/to/mcp-git-server", 
    vec![], 
    HashMap::new()
);

let handle = transport.start().await?;
let service = McpService::with_timeout(handle, Duration::from_secs(10));
let mut client = McpClient::new(service);

client.initialize(
    ClientInfo {
        name: "my-client".into(),
        version: "1.0.0".into(),
    },
    ClientCapabilities::default(),
).await?;

let status = client.call_tool("git_status", serde_json::json!({ "repo_path": "/path/to/repo" })).await?;

println!("Git status: {:?}", status);

Integrate into an MCP server

If you are adding these tools to your own MCP server, register the git tools so clients can discover and use them. The server can then expose the full suite of Git operations to MCP clients.

Tool details and capabilities

The MCP Git Tools provide a comprehensive set of Git operations you can invoke via MCP clients. The available tools include status, branches, log, time-filtered log, commit, pull, push, diff, add, and reset. Each tool returns structured data describing the result of the operation, such as the repository status, commit history, and command outputs.

Notes

No sensitive data should be transmitted through the MCP interface. Ensure repository paths and credentials are handled securely in your environment.

Available tools

git_status

Get the status of a repository, returning items like modified and untracked files and whether the working tree is clean.

git_branches

List all branches and indicate the current branch.

git_log

Retrieve commit history with optional maximum count and branch filtering.

git_time_filtered_log

Fetch commits within a specified time range with optional author and branch filters.

git_commit

Create a new commit with a message and option to automatically stage changes.

git_pull

Pull changes from a remote repository, optionally specifying the remote name and branch.

git_push

Push local commits to a remote repository with optional force push and remote/branch selection.

git_diff

Show differences between working state, staged changes, or a specific commit against a path.

git_add

Add file contents to the staging area with options for updating or including all changes.

git_reset

Reset the staging area or working tree to a target state, with an optional hard reset.