git-mcp-server

bkbatchelor/git-mcp-server

3.2

If you are the rightful owner of git-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Git MCP Server is a Java 21 implementation that allows AI assistants to interact with Git repositories using the Model Context Protocol.

Tools
5
Resources
0
Prompts
0

Git MCP Server

A Model Context Protocol (MCP) server for Git, enabling AI agents to interact with repositories safely and efficiently.

Overview

The git-mcp-server bridges the gap between Large Language Models (LLMs) and your version control system. It allows AI agents to perform Git operations—starting with reading repository state and commit history—in a structured, controlled environment.

Features

  • MCP Infrastructure: Full implementation of the Model Context Protocol over Standard I/O (Stdio).
  • Branch Listing: Retrieve a list of local branches.
  • Commit History: Fetch commit logs with structured metadata (hash, author, date, message).
  • Safety: Designed with read-only operations first, ensuring safe interaction for AI agents.

Technology Stack

  • Language: Java 21
  • Framework: Spring Boot 4.0.1
  • Build System: Gradle (Kotlin DSL)
  • Git Interaction: Native Git CLI Wrapper

Prerequisites

  • Java 21 or later
  • Git installed and available on the system PATH

Getting Started

1. Clone the Repository

git clone <repository-url>
cd git-mcp-server

2. Build the Project

./gradlew build

3. Run the Server

java -jar build/libs/git-mcp-server-0.0.1-SNAPSHOT.jar

The server will start and listen for MCP JSON-RPC messages on Standard Input (stdin).

Usage

This server is designed to be used by an MCP Client (like an IDE extension or an AI agent runner). However, you can test it manually via the command line.

MCP Client Configuration

For best performance and to avoid timeouts (especially in Gemini CLI or Claude Desktop), it is recommended to use the provided optimized wrapper script:

{
  "mcpServers": {
    "git-mcp-server": {
      "command": "/path/to/your/git-mcp-server/git-mcp-server.sh",
      "args": []
    }
  }
}

Replace /path/to/your/git-mcp-server with the actual absolute path to the project directory.

Alternatively, if you prefer to call java directly, ensure you use the following optimized JVM flags:

java -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -jar build/libs/git-mcp-server-0.0.1-SNAPSHOT.jar

Example: List Branches

Input (stdin):

{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "list_branches", "arguments": {}}, "id": 1}

Output (stdout):

{"jsonrpc":"2.0","id":1,"result":{"content":[{"type":"text","text":"main\nfeature/branch..."}]}}

Example: Get Commit Log

Input (stdin):

{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "get_log", "arguments": {"count": 5}}, "id": 2}

Available Tools

Tool NameDescriptionArguments
list_branchesLists all local branches.None
get_logRetrieves commit history.count (integer, default: 10)

Development

Running Tests

./gradlew test

Project Structure

  • src/main/java/io/sandboxdev/gitmcpserver/mcp: Core MCP infrastructure (JSON-RPC, Transport).
  • src/main/java/io/sandboxdev/gitmcpserver/git: Git service and tool definitions.

License