Skip to main content
Glama
skurekjakub

Git Stuff Server

by skurekjakub
README.md
# Git Stuff Server

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`](GenerateMergeDiff.ps1) PowerShell script.
    *   Returns the textual diff content generated by `git show -m --first-parent <commitHash>`.

## Prerequisites

*   [Node.js](https://nodejs.org/) (Version supporting ES Modules, check `engines` in [package.json](package.json) if specified, otherwise check `tsconfig.json` target - ES2022)
*   [npm](https://www.npmjs.com/) (usually comes with Node.js)
*   [Git](https://git-scm.com/) installed and accessible in the system's PATH.
*   [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell) (Windows) or `pwsh` (Linux/macOS) installed and accessible in the system's PATH.

## Installation

1.  Clone the repository:
    ```sh
    git clone <your-repo-url>
    cd GitStuffServer
    ```
2.  Install dependencies:
    ```sh
    npm install
    ```

## Usage

1.  **Build the TypeScript code:**
    ```sh
    npm run build
    ```
    This compiles the TypeScript code from `src/` to JavaScript in `build/`.

2.  **Run the server:**
    *   To run the compiled code:
        ```sh
        npm start
        ```
    *   To build and run in development mode:
        ```sh
        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`](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`](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`](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](package.json) file for details.

TDQS

C2.9/5.0

Scored across 4 tools

Disambiguation4/5

Three tools (ado_pr_changes, ado_pr_comment, ado_pr_threads) are clearly distinct and focused on Azure DevOps pull request operations, with no overlap in their purposes. The fourth tool (git_merge_diff) is unrelated to Azure DevOps and operates on local Git repositories, creating a minor domain mismatch but no functional ambiguity.

Naming Consistency2/5

The naming is inconsistent across the tool set. The first three tools use a consistent 'ado_pr_' prefix with descriptive suffixes (changes, comment, threads), but the fourth tool uses a different 'git_' prefix with a different structure (merge_diff). This mixed convention reduces predictability and coherence.

Tool Count3/5

With only 4 tools, the count feels thin for a server named 'Git Stuff Server', which implies broader Git-related functionality. The tools are split between Azure DevOps PR operations and a local Git diff tool, making the scope appear fragmented rather than comprehensive.

Completeness2/5

For Azure DevOps pull requests, the tools cover fetching changes, commenting, and fetching threads, but lack core operations like creating, updating, or merging pull requests. For local Git operations, only one diff tool is provided, missing basic commands like clone, commit, or push. This results in significant gaps that will hinder agent workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues