Provides Git operations over MCP, enabling status, log, commit, push, pull, and more via standard MCP tooling.
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.
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.
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:
# 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-serverUse 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);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.
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.
No sensitive data should be transmitted through the MCP interface. Ensure repository paths and credentials are handled securely in your environment.
Get the status of a repository, returning items like modified and untracked files and whether the working tree is clean.
List all branches and indicate the current branch.
Retrieve commit history with optional maximum count and branch filtering.
Fetch commits within a specified time range with optional author and branch filters.
Create a new commit with a message and option to automatically stage changes.
Pull changes from a remote repository, optionally specifying the remote name and branch.
Push local commits to a remote repository with optional force push and remote/branch selection.
Show differences between working state, staged changes, or a specific commit against a path.
Add file contents to the staging area with options for updating or including all changes.
Reset the staging area or working tree to a target state, with an optional hard reset.