Git Stuff Server

by skurekjakub

183 downloads Not rated yet

About

Git Stuff Server is a Node.js application that implements a Model Context Protocol (MCP) server to provide Git‑related functionalities. Its primary tool generates the textual diff of a Git merge commit against its first parent, intended for developers using MCP‑compatible…

Explore

MCP Server: Runs as a standard MCP server using stdio for communication.
get_git_merge_diff Tool:
Accepts a Git merge commit hash.
Executes the GenerateMergeDiff.ps1 PowerShell script.
* Returns the textual diff content generated by git show -m --first-parent <commitHash>.

Node.js (Version supporting ES Modules, check engines in package.json if specified, otherwise check tsconfig.json target - ES2022)
npm (usually comes with Node.js)
Git installed and accessible in the system's PATH.
PowerShell (Windows) or pwsh (Linux/macOS) installed and accessible in the system's PATH.

commitHash

(string): The Git commit hash (SHA) of the merge commit you want to diff.

When connected via an MCP client, you can call the get_git_merge_diff tool with the following input:

  • commitHash (string): The Git commit hash (SHA) of the merge commit you want to diff.
The tool will return the diff content as text.

This repository contains a Node.js application that acts as an MCP (Model Context Protocol) server to provide Git-related functionalities. Currently, it offers a tool to generate the diff for a Git merge commit against its first parent.

Features

MCP Server: Runs as a standard MCP server using stdio for communication.
get_git_merge_diff Tool:
Accepts a Git merge commit hash.
Executes the GenerateMergeDiff.ps1 PowerShell script.
Returns the textual diff content generated by git show -m --first-parent <commitHash>.

Prerequisites

Node.js (Version supporting ES Modules, check engines in package.json if specified, otherwise check tsconfig.json target - ES2022)
npm (usually comes with Node.js)
Git installed and accessible in the system's PATH.
PowerShell (Windows) or pwsh (Linux/macOS) installed and accessible in the system's PATH.

Installation

1. Clone the repository:

    git clone <your-repo-url>
cd GitStuffServer

2. Install dependencies:
    npm install

Usage

1. Build the TypeScript code:

    npm run build

This compiles the TypeScript code from src/ to JavaScript in build/.

2. Run the server:
To run the compiled code:

        npm start

To build and run in development mode:
        npm run dev

The server will start and listen for MCP requests on standard input/output.

Using the get_git_merge_diff Tool

When connected via an MCP client, you can call the get_git_merge_diff tool with the following input:

commitHash (string): The Git commit hash (SHA) of the merge commit you want to diff.

The tool will return the diff content as text.

How it Works

1. The MCP server (src/index.ts) receives a request for the get_git_merge_diff tool.
2. It validates the commitHash input.
3. It executes the GenerateMergeDiff.ps1 PowerShell script, passing the commitHash.
4. The PowerShell script runs git show -m --first-parent <commitHash> and saves the output (including any errors) to a temporary file named merge_changes.diff in the server's current working directory.
5. The Node.js server reads the content of merge_changes.diff.
6. The server deletes the temporary merge_changes.diff file.
7. The server returns the diff content (or an error message) to the MCP client.

Configuration

Key configuration points are defined as constants within src/index.ts:

SERVER_NAME: The name registered by the MCP server.
SCRIPT_NAME: The filename of the PowerShell script to execute.

  • OUTPUT_DIFF_FILE: The name of the temporary diff file created by the script.


License

This project is licensed under the MIT License - see the package.json file for details.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.