Skip to main content
Glama
git MCP server

git MCP server

Official

mcp-server-git: Ein git MCP-Server

Übersicht

Ein Model Context Protocol-Server für die Interaktion mit und Automatisierung von Git-Repositories. Dieser Server stellt Werkzeuge bereit, um Git-Repositories über Large Language Models zu lesen, zu durchsuchen und zu bearbeiten.

Bitte beachten Sie, dass sich mcp-server-git derzeit in einem frühen Entwicklungsstadium befindet. Die Funktionalität und die verfügbaren Werkzeuge können sich ändern und erweitern, während wir den Server weiterentwickeln und verbessern.

Werkzeuge

  1. git_status

    • Zeigt den Status des Arbeitsverzeichnisses an

    • Eingabe:

      • repo_path (string): Pfad zum Git-Repository

    • Rückgabe: Aktueller Status des Arbeitsverzeichnisses als Textausgabe

  2. git_diff_unstaged

    • Zeigt Änderungen im Arbeitsverzeichnis an, die noch nicht für den Commit vorgemerkt (staged) sind

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • context_lines (number, optional): Anzahl der Kontextzeilen, die angezeigt werden sollen (Standard: 3)

    • Rückgabe: Diff-Ausgabe der nicht vorgemerkten Änderungen

  3. git_diff_staged

    • Zeigt Änderungen an, die für den Commit vorgemerkt sind

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • context_lines (number, optional): Anzahl der Kontextzeilen, die angezeigt werden sollen (Standard: 3)

    • Rückgabe: Diff-Ausgabe der vorgemerkten Änderungen

  4. git_diff

    • Zeigt Unterschiede zwischen Branches oder Commits an

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • target (string): Ziel-Branch oder Commit für den Vergleich

      • context_lines (number, optional): Anzahl der Kontextzeilen, die angezeigt werden sollen (Standard: 3)

    • Rückgabe: Diff-Ausgabe des Vergleichs zwischen aktuellem Zustand und Ziel

  5. git_commit

    • Speichert Änderungen im Repository

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • message (string): Commit-Nachricht

    • Rückgabe: Bestätigung mit dem neuen Commit-Hash

  6. git_add

    • Fügt Dateiinhalte zum Staging-Bereich hinzu

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • files (string[]): Array von Dateipfaden zum Vormerken

    • Rückgabe: Bestätigung der vorgemerkten Dateien

  7. git_reset

    • Hebt die Vormerkung aller vorgemerkten Änderungen auf

    • Eingabe:

      • repo_path (string): Pfad zum Git-Repository

    • Rückgabe: Bestätigung des Reset-Vorgangs

  8. git_log

    • Zeigt die Commit-Logs mit optionaler Datumsfilterung an

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • max_count (number, optional): Maximale Anzahl der anzuzeigenden Commits (Standard: 10)

      • start_timestamp (string, optional): Start-Zeitstempel für die Filterung von Commits. Akzeptiert ISO 8601-Format (z. B. '2024-01-15T14:30:25'), relative Daten (z. B. '2 weeks ago', 'yesterday') oder absolute Daten (z. B. '2024-01-15', 'Jan 15 2024')

      • end_timestamp (string, optional): End-Zeitstempel für die Filterung von Commits. Akzeptiert ISO 8601-Format (z. B. '2024-01-15T14:30:25'), relative Daten (z. B. '2 weeks ago', 'yesterday') oder absolute Daten (z. B. '2024-01-15', 'Jan 15 2024')

    • Rückgabe: Array von Commit-Einträgen mit Hash, Autor, Datum und Nachricht

  9. git_create_branch

    • Erstellt einen neuen Branch

    • Eingaben:

      • repo_path (string): Pfad zum Git-Repository

      • branch_name (string): Name des neuen Branches

      • base_branch (string, optional): Basis-Branch, von dem aus erstellt werden soll (Standard ist der aktuelle Branch)

    • Rückgabe: Bestätigung der Branch-Erstellung

  10. git_checkout

  • Wechselt Branches

  • Eingaben:

    • repo_path (string): Pfad zum Git-Repository

    • branch_name (string): Name des Branches, zu dem gewechselt werden soll

  • Rückgabe: Bestätigung des Branch-Wechsels

  1. git_show

  • Zeigt den Inhalt eines Commits an

  • Eingaben:

    • repo_path (string): Pfad zum Git-Repository

    • revision (string): Die Revision (Commit-Hash, Branch-Name, Tag), die angezeigt werden soll

  • Rückgabe: Inhalt des angegebenen Commits

  1. git_branch

  • Listet Git-Branches auf

  • Eingaben:

    • repo_path (string): Pfad zum Git-Repository.

    • branch_type (string): Ob lokale Branches ('local'), Remote-Branches ('remote') oder alle Branches ('all') aufgelistet werden sollen.

    • contains (string, optional): Der Commit-SHA, den der Branch enthalten sollte. Übergeben Sie nichts an diesen Parameter, wenn kein Commit-SHA angegeben ist

    • not_contains (string, optional): Der Commit-SHA, den der Branch NICHT enthalten sollte. Übergeben Sie nichts an diesen Parameter, wenn kein Commit-SHA angegeben ist

  • Rückgabe: Liste der Branches

Related MCP server: GitHub Tools MCP Server

Installation

Verwendung von uv (empfohlen)

Bei der Verwendung von uv ist keine spezielle Installation erforderlich. Wir verwenden uvx, um mcp-server-git direkt auszuführen.

Verwendung von PIP

Alternativ können Sie mcp-server-git über pip installieren:

pip install mcp-server-git

Nach der Installation können Sie es als Skript ausführen mit:

python -m mcp_server_git

Konfiguration

Verwendung mit Claude Desktop

Fügen Sie dies zu Ihrer claude_desktop_config.json hinzu:

"mcpServers": {
  "git": {
    "command": "uvx",
    "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
  }
}
  • Hinweis: Ersetzen Sie '/Users/username' durch einen Pfad, auf den dieses Werkzeug zugreifen können soll

"mcpServers": {
  "git": {
    "command": "docker",
    "args": ["run", "--rm", "-i", "--mount", "type=bind,src=/Users/username,dst=/Users/username", "mcp/git"]
  }
}
"mcpServers": {
  "git": {
    "command": "python",
    "args": ["-m", "mcp_server_git", "--repository", "path/to/git/repo"]
  }
}

Verwendung mit VS Code

Für eine schnelle Installation verwenden Sie eine der untenstehenden Ein-Klick-Installationsschaltflächen...

Install with UV in VS Code Install with UV in VS Code Insiders

Install with Docker in VS Code Install with Docker in VS Code Insiders

Für eine manuelle Installation können Sie den MCP-Server mit einer dieser Methoden konfigurieren:

Methode 1: Benutzerkonfiguration (Empfohlen) Fügen Sie die Konfiguration zu Ihrer MCP-Konfigurationsdatei auf Benutzerebene hinzu. Öffnen Sie die Befehlspalette (Strg + Umschalt + P) und führen Sie MCP: Open User Configuration aus. Dies öffnet Ihre mcp.json-Datei auf Benutzerebene, in der Sie die Serverkonfiguration hinzufügen können.

Methode 2: Arbeitsbereichskonfiguration Alternativ können Sie die Konfiguration zu einer Datei namens .vscode/mcp.json in Ihrem Arbeitsbereich hinzufügen. Dies ermöglicht es Ihnen, die Konfiguration mit anderen zu teilen.

Weitere Details zur MCP-Konfiguration in VS Code finden Sie in der offiziellen VS Code MCP-Dokumentation.

{
  "servers": {
    "git": {
      "command": "uvx",
      "args": ["mcp-server-git"]
    }
  }
}

Für die Docker-Installation:

{
  "mcp": {
    "servers": {
      "git": {
        "command": "docker",
        "args": [
          "run",
          "--rm",
          "-i",
          "--mount", "type=bind,src=${workspaceFolder},dst=/workspace",
          "mcp/git"
        ]
      }
    }
  }
}

Verwendung mit Zed

Fügen Sie dies zu Ihrer Zed settings.json hinzu:

"context_servers": [
  "mcp-server-git": {
    "command": {
      "path": "uvx",
      "args": ["mcp-server-git"]
    }
  }
],
"context_servers": {
  "mcp-server-git": {
    "command": {
      "path": "python",
      "args": ["-m", "mcp_server_git"]
    }
  }
},

Verwendung mit Zencoder

  1. Gehen Sie zum Zencoder-Menü (...)

  2. Wählen Sie aus dem Dropdown-Menü Agent Tools aus

  3. Klicken Sie auf Add Custom MCP

  4. Fügen Sie den Namen (z. B. git) und die Serverkonfiguration von unten hinzu und stellen Sie sicher, dass Sie auf die Schaltfläche Install klicken

{
    "command": "uvx",
    "args": ["mcp-server-git", "--repository", "path/to/git/repo"]
}

Debugging

Sie können den MCP-Inspektor verwenden, um den Server zu debuggen. Für uvx-Installationen:

npx @modelcontextprotocol/inspector uvx mcp-server-git

Oder wenn Sie das Paket in einem bestimmten Verzeichnis installiert haben oder daran entwickeln:

cd path/to/servers/src/git
npx @modelcontextprotocol/inspector uv run mcp-server-git

Das Ausführen von tail -n 20 -f ~/Library/Logs/Claude/mcp*.log zeigt die Logs des Servers an und kann Ihnen helfen, Probleme zu debuggen.

Entwicklung

Wenn Sie lokal entwickeln, gibt es zwei Möglichkeiten, Ihre Änderungen zu testen:

  1. Führen Sie den MCP-Inspektor aus, um Ihre Änderungen zu testen. Siehe Debugging für Anweisungen zur Ausführung.

  2. Testen Sie mit der Claude Desktop-App. Fügen Sie Folgendes zu Ihrer claude_desktop_config.json hinzu:

Docker

{
  "mcpServers": {
    "git": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "--mount", "type=bind,src=/Users/username/Desktop,dst=/projects/Desktop",
        "--mount", "type=bind,src=/path/to/other/allowed/dir,dst=/projects/other/allowed/dir,ro",
        "--mount", "type=bind,src=/path/to/file.txt,dst=/projects/path/to/file.txt",
        "mcp/git"
      ]
    }
  }
}

UVX

{
"mcpServers": {
  "git": {
    "command": "uv",
    "args": [
      "--directory",
      "/<path to mcp-servers>/mcp-servers/src/git",
      "run",
      "mcp-server-git"
    ]
    }
  }
}

Build

Docker-Build:

cd src/git
docker build -t mcp/git .

Lizenz

Dieser MCP-Server ist unter der MIT-Lizenz lizenziert. Dies bedeutet, dass Sie die Software frei verwenden, ändern und verbreiten dürfen, vorbehaltlich der Bedingungen der MIT-Lizenz. Weitere Details finden Sie in der LICENSE-Datei im Projekt-Repository.

Available Tools

14 tools
git_addC
Idempotent

Adds file contents to the staging area

Inputs: files (required), repo_path (required).

git_branchC
Read-onlyIdempotent

List Git branches

Inputs: repo_path (required), branch_type (required), contains, not_contains.

git_checkoutC

Switches branches

Inputs: repo_path (required), branch_name (required).

git_commitD

Records changes to the repository

Inputs: message (required), repo_path (required).

git_create_branchC

Creates a new branch from an optional base branch or commit

Inputs: repo_path (required), branch_name (required), base_branch.

git_diffB
Read-onlyIdempotent

Shows differences between branches or commits, or across a revision range (main..feature, main...feature)

Inputs: target (required), repo_path (required), context_lines.

git_diff_stagedB
Read-onlyIdempotent

Shows changes that are staged for commit

Inputs: repo_path (required), context_lines.

git_diff_unstagedB
Read-onlyIdempotent

Shows changes in the working directory that are not yet staged

Inputs: repo_path (required), context_lines.

git_logA
Read-onlyIdempotent

Shows the commit log, newest commit first. For the latest commits, pass only repo_path (and optionally max_count). start_timestamp and end_timestamp are optional filters for a date range: omit them unless a specific period is asked for, because a range that holds no commits returns none.

Inputs: repo_path (required), max_count, end_timestamp, start_timestamp.

git_mergeA
Idempotent

Merges a branch into the current branch. Fast-forward only unless fast_forward_only is false; refuses a dirty working tree, and aborts a merge that conflicts, leaving the repository unchanged

Inputs: repo_path (required), source_branch (required), fast_forward_only.

git_remoteA
Read-onlyIdempotent

Lists the repository's remotes with their fetch and push URLs, like git remote -v. Credentials embedded in a URL's userinfo, query values or fragment are shown as ; path segments are shown as configured

Inputs: repo_path (required).

git_resetB
DestructiveIdempotent

Unstages all staged changes

Inputs: repo_path (required).

git_showB
Read-onlyIdempotent

Shows the contents of a commit, or of a file or directory given as :

Inputs: revision (required), repo_path (required).

git_statusB
Read-onlyIdempotent

Shows the working tree status

Inputs: repo_path (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 14 tools

    Disambiguation4/5

    Each tool maps to a recognizable git operation with mostly distinct targets: the three diff variants (git_diff, git_diff_staged, git_diff_unstaged) are the closest overlap, but their descriptions clearly scope each one. git_branch (list) vs git_create_branch (create) vs git_checkout (switch) are distinguishable, though an agent could occasionally reach for the wrong branch tool. No two tools appear to do the same thing.

    Naming Consistency4/5

    All 14 names share a uniform `git_` prefix and snake_case, and most mirror familiar git CLI verbs (log, show, checkout, merge, commit, add, reset). A few are noun-only (git_branch, git_status, git_remote) which deviates slightly from a strict verb_noun pattern, but this matches git conventions and stays predictable.

    Tool Count5/5

    14 tools sit squarely in the well-scoped range: one tool per core local git workflow (status, diff variants, add, commit, log, show, branch, checkout, merge, remote). Nothing feels redundant or padded.

    Completeness3/5

    Local read/write coverage is solid, but the lifecycle dead-ends at the remote boundary: there is no push, pull, or fetch, and no branch deletion, stash, tag, or remote-management operation. Merge and git_remote imply remote collaboration, so the missing publishing step is a notable gap an agent will hit.

    Maintenance

    ActivityActive
    ResponsivenessSyncing

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      A Model Context Protocol server that enables Large Language Models to interact with Git repositories through a robust API, supporting operations like repository initialization, cloning, file staging, committing, and branch management.
      28
      6,847 npm
      246
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables LLMs to interact with Git repositories, providing tools to read, search, and manipulate Git repositories through commands like status, diff, commit, and branch management.
      12
      MIT
    • A
      license
      C
      quality
      B
      maintenance
      A Model Context Protocol server that enables LLMs to interact with Git repositories, providing tools to read, search, and manipulate Git repositories through commands like status, diff, commit, and branch operations.
      22
      4
      MIT