git-mcp-server
Git MCP Server
Ein MCP-Server (Model Context Protocol), der Tools für die Interaktion mit Git-Repositories bereitstellt. Ermöglicht LLMs und KI-Agenten die Durchführung von Git-Operationen wie Klonen, Commit, Push, Pull, Branch, Diff, Log, Status und mehr über den MCP-Standard.
Dieser Server basiert auf der cyanheads/mcp-ts-template und folgt einer modularen Architektur:
Hinweis für Entwickler : Dieses Repository enthält eine .clinerules- Datei, die als Spickzettel für Entwickler für Ihren LLM-Codierungsagenten mit einer Kurzreferenz für die Codebasismuster, Dateispeicherorte und Codeausschnitte dient.
Inhaltsverzeichnis
| Übersicht | Funktionen | Installation |
| Konfiguration | Projektstruktur |
| Tools | Ressourcen | Entwicklung | Lizenz |
Related MCP server: GIT MCP Server
Überblick
Stärken Sie Ihre KI-Agenten und Entwicklungstools mit nahtloser Git-Integration!
Der Git-MCP-Server fungiert als Brücke und ermöglicht Anwendungen (MCP-Clients), die das Model Context Protocol (MCP) verstehen – wie erweiterte KI-Assistenten (LLMs), IDE-Erweiterungen oder benutzerdefinierte Skripte –, direkt und sicher mit lokalen Git-Repositorys zu interagieren.
Anstelle komplexer Skripts oder manueller CLI können Ihre Tools diesen Server für Folgendes nutzen:
Automatisieren Sie Git-Workflows : Klonen Sie Repositories, erstellen Sie Zweige, stellen Sie Änderungen bereit, committen Sie Arbeit, pushen Sie Updates und verwalten Sie Tags programmgesteuert.
Erhalten Sie Einblicke in das Repository : Überprüfen Sie den Status, zeigen Sie Protokolle und Diff-Änderungen an und untersuchen Sie Git-Objekte, ohne die Hostanwendung zu verlassen.
Integrieren Sie Git in die KI-gesteuerte Entwicklung : Ermöglichen Sie LLMs die Verwaltung der Versionskontrolle als Teil ihrer Codierungs- oder Refactoring-Aufgaben.
Dieser Server basiert auf dem robusten mcp-ts-template und bietet eine standardisierte, sichere und effiziente Möglichkeit, Git-Funktionen über den MCP-Standard bereitzustellen. Dies wird durch die sichere Ausführung des auf dem System installierten Standard- git Kommandozeilentools mithilfe des child_process Moduls von Node.js erreicht. Dies gewährleistet Kompatibilität und nutzt die volle Leistungsfähigkeit von Git.
Merkmale
Kerndienstprogramme (aus Vorlage)
Nutzt die robusten Dienstprogramme der mcp-ts-template :
Protokollierung : Strukturierte, konfigurierbare Protokollierung (Dateirotation, Konsole, MCP-Benachrichtigungen) mit Schwärzung sensibler Daten.
Fehlerbehandlung : Zentralisierte Fehlerverarbeitung, standardisierte Fehlertypen (
McpError) und automatische Protokollierung.Konfiguration : Laden von Umgebungsvariablen (
dotenv).Eingabevalidierung/-bereinigung : Verwendet
zodzur Schemavalidierung und benutzerdefinierten Bereinigungslogik (entscheidend für Pfade).Anforderungskontext : Verfolgung und Korrelation von Vorgängen über eindeutige Anforderungs-IDs.
Typsicherheit : Starke Typisierung wird durch TypeScript- und Zod-Schemas erzwungen.
HTTP-Transportoption : Integrierter Express-Server mit SSE, Sitzungsverwaltung und CORS-Unterstützung.
Git-Operationen
Direkte Git-CLI-Ausführung : Interagiert mit Git durch sichere Ausführung des Standard
git-Befehlszeilentools über Node.jschild_processund gewährleistet so vollständige Kompatibilität und Zugriff auf die Funktionen von Git.Umfassende Befehlsabdeckung : Stellt eine große Bandbreite an Git-Befehlen als MCP-Tools bereit (siehe Abschnitt „Tools “).
Repository-Interaktion : Unterstützt Statusprüfung, Verzweigung, Staging, Commit, Abrufen, Pullen, Pushen, Diffing, Protokollieren, Zurücksetzen, Taggen und mehr.
Arbeitsverzeichnisverwaltung : Ermöglicht das Festlegen und Löschen eines sitzungsspezifischen Arbeitsverzeichnisses für die Kontextpersistenz über mehrere Git-Vorgänge hinweg.
Sicherheitsfunktionen : Beinhaltet Prüfungen und erfordert eine ausdrückliche Bestätigung für potenziell zerstörerische Vorgänge wie
git cleanundgit reset --hard.Commit-Signierung : Unterstützt GPG- oder SSH-Signierung für verifizierte Commits, gesteuert über die Umgebungsvariable
GIT_SIGN_COMMITSund die serverseitige Git-Konfiguration. Enthält einen optionalen Tool-Parameter, um bei fehlgeschlagener Signierung auf nicht signierte Commits zurückzugreifen.
Installation
Voraussetzungen
Installation über npm
Installieren Sie das Paket global:
npm install @cyanheads/git-mcp-server
Von der Quelle installieren
Klonen Sie das Repository:
git clone https://github.com/cyanheads/git-mcp-server.git cd git-mcp-serverInstallieren Sie Abhängigkeiten:
npm installErstellen Sie das Projekt:
npm run build (or `npm run rebuild`)Dadurch wird der TypeScript-Code im Verzeichnis
dist/in JavaScript kompiliert und der Einstiegspunkt ausführbar gemacht.
Konfiguration
Umgebungsvariablen
Konfigurieren Sie den Server mithilfe von Umgebungsvariablen. Erstellen Sie eine .env Datei im Projektstamm (Kopie aus .env.example ) oder legen Sie sie in Ihrer Umgebung fest.
Variable | Beschreibung | Standard |
| Transportmechanismus: |
|
| Port für den HTTP-Server (wenn |
|
| Hostadresse für den HTTP-Server (wenn |
|
| Durch Kommas getrennte Liste zulässiger Ursprünge für CORS (wenn | (keiner) |
| Protokollierungsebene ( |
|
| Auf |
|
| Geheimer Schlüssel zum Signieren/Verifizieren von Authentifizierungstoken (erforderlich, wenn die Authentifizierung in Zukunft aktiviert wird). |
|
MCP-Client-Einstellungen
Fügen Sie zu Ihren MCP-Clienteinstellungen hinzu (z. B. cline_mcp_settings.json ):
{
"mcpServers": {
"git-mcp-server": {
// Use a descriptive name
"command": "node", // Use node to run the script
"args": ["/path/to/your/git-mcp-server/dist/index.js"], // Absolute path to the built entry point
"env": {
// "MCP_TRANSPORT_TYPE": "http", // Optional: if using http
// "MCP_HTTP_PORT": "3010", // Optional: if using http and non-default port
// "GIT_SIGN_COMMITS": "true" // Optional: Enable commit signing attempts if server is configured
},
"disabled": false,
"autoApprove": [] // Configure auto-approval rules if desired
}
}
}Projektstruktur
Die Codebasis folgt einer modularen Struktur innerhalb des src/ -Verzeichnisses:
src/
├── index.ts # Entry point: Initializes and starts the server
├── config/ # Configuration loading (env vars, package info)
│ └── index.ts
├── mcp-server/ # Core MCP server logic and capability registration
│ ├── server.ts # Server setup, capability registration
│ ├── transports/ # Transport handling (stdio, http)
│ ├── resources/ # MCP Resource implementations (currently none)
│ └── tools/ # MCP Tool implementations (subdirs per tool)
├── types-global/ # Shared TypeScript type definitions
└── utils/ # Common utility functions (logger, error handler, etc.)Für einen detaillierten Dateibaum führen Sie npm run tree aus oder sehen Sie sich docs/tree.md an.
Werkzeuge
Der Git MCP-Server bietet eine Reihe von Tools für die Interaktion mit Git-Repositorys, die über das Model Context Protocol aufgerufen werden können.
Werkzeugname | Beschreibung | Hauptargumente |
| Stellt bestimmte Dateien oder Muster bereit. |
|
| Verwaltet Zweige (auflisten, erstellen, löschen, umbenennen, aktuelle anzeigen). |
|
| Wechselt Zweige oder stellt Arbeitsbaumdateien wieder her. |
|
| Wendet durch vorhandene Commits eingeführte Änderungen an. |
|
| Entfernt nicht verfolgte Dateien. Erfordert |
|
| Löscht das sitzungsspezifische Arbeitsverzeichnis. | (keiner) |
| Klont ein Repository in einen angegebenen absoluten Pfad. |
|
| Übernimmt stufenweise Änderungen. Unterstützt Autorüberschreibung und Signaturkontrolle. |
|
| Zeigt Änderungen zwischen Commits, Arbeitsbaum usw. an. |
|
| Lädt Objekte und Referenzen aus anderen Repositories herunter. |
|
| Initialisiert ein neues Git-Repository unter dem angegebenen absoluten Pfad. Der Standardwert für den ersten Zweig ist „main“. |
|
| Zeigt Commit-Protokolle an. |
|
| Führt den angegebenen Zweig mit dem aktuellen Zweig zusammen. |
|
| Ruft Daten aus einem anderen Repository oder lokalen Zweig ab und integriert diese. |
|
| Aktualisiert Remote-Refs mithilfe lokaler Refs. |
|
| Wendet Commits erneut auf einem anderen Basistipp an. |
|
| Verwaltet Remote-Repositorys (auflisten, hinzufügen, entfernen, anzeigen). |
|
| Setzt den aktuellen HEAD auf einen angegebenen Zustand zurück. Unterstützt Soft-, Mixed- und Hard-Modi. Verwenden Sie „hard“ mit Vorsicht . |
|
| Legt das Standardarbeitsverzeichnis fest. Kann optional das Repository initialisieren, falls nicht vorhanden. Erfordert absoluten Pfad. |
|
| Zeigt Informationen zu Git-Objekten (Commits, Tags usw.) an. |
|
| Verwaltet gespeicherte Änderungen (Auflisten, Anwenden, Pop, Drop, Speichern). |
|
| Ruft den Repository-Status ab (Zweig, bereitgestellte, geänderte, nicht verfolgte Dateien). |
|
| Verwaltet Tags (Auflisten, Erstellen mit Anmerkungen/leichtgewichtig, Löschen). |
|
| Verwaltet Git-Arbeitsbäume (auflisten, hinzufügen, entfernen, verschieben, bereinigen). |
|
Hinweis: Der path ist für die meisten Tools standardmäßig das Arbeitsverzeichnis der Sitzung, wenn er über git_set_working_dir festgelegt wird.
Ressourcen
MCP-Ressourcen sind in dieser Version (v2.0.12) nicht implementiert.
Diese Version konzentriert sich auf die überarbeitete Implementierung der Git-Tools basierend auf der neuesten mcp-ts-template und dem MCP SDK v1.12.0. Zuvor verfügbare Ressourcenfunktionen wurden im Rahmen dieses umfangreichen Updates vorübergehend entfernt.
Wenn Sie Zugriff auf MCP-Ressourcen benötigen (z. B. zum Lesen von Dateiinhalten direkt über den Server), verwenden Sie bitte die stabile Version v1.2.4 .
Zukünftige Entwicklungen können die Ressourcenfunktionen in einer nachfolgenden Version wieder einführen.
Hinweis: Diese Version (v2.0.0) konzentriert sich auf die Refaktorierung und Aktualisierung der wichtigsten Git-Tools basierend auf dem neuesten MCP SDK. MCP-Ressourcenfunktionen sind in dieser Version nicht implementiert. Für den Ressourcenzugriff verwenden Sie bitte v1.2.4 .
Entwicklung
Erstellen und Testen
# Build the project (compile TS to JS in dist/ and make executable)
npm run build
# Test the server locally using the MCP inspector tool (stdio transport)
npm run inspector
# Test the server locally using the MCP inspector tool (http transport)
npm run inspector:http
# Clean build artifacts (runs scripts/clean.ts)
npm run clean
# Generate a file tree representation for documentation (runs scripts/tree.ts)
npm run tree
# Clean build artifacts and then rebuild the project
npm run rebuild
# Start the server using stdio (default)
npm start
# Or explicitly:
npm run start:stdio
# Start the server using HTTP transport
npm run start:httpLizenz
Dieses Projekt ist unter der Apache-Lizenz 2.0 lizenziert – Einzelheiten finden Sie in der Datei LICENSE .
Available Tools
28 toolsgit_addGit AddA
Stage files for commit. Add file contents to the staging area (index) to prepare for the next commit.
Inputs: path, files, update, all, +1 more. Returns: success, stagedFiles, totalFiles, status
git_blameGit BlameARead-only
Show line-by-line authorship information for a file, displaying who last modified each line and when. For large files, use startLine/endLine to limit output.
Inputs: file (required), path, startLine, endLine, +1 more. Returns: success, file, lines, totalLines
git_branchGit BranchA
Manage branches: list all branches, show current branch, create a new branch, delete a branch, or rename a branch.
Inputs: path, operation, name, newName, +6 more. Returns: success, operation, branches, currentBranch, +1 more
git_changelog_analyzeGit Changelog AnalyzeARead-only
Gather git history context (commits, tags) and structured review instructions to support LLM-driven changelog analysis. Changelog file should be read separately; this tool provides the supporting git data and analysis framework. Pass one or more review types to control what kind of analysis to perform.
Inputs: reviewTypes (required), path, maxCommits, sinceTag, +1 more. Returns: success, reviewTypes, gitContext, reviewInstructions
git_checkoutGit CheckoutA
Switch branches or restore working tree files. Can checkout an existing branch, create a new branch, or restore specific files.
Inputs: target (required), path, createBranch, force, +2 more. Returns: success, target, branchCreated, filesModified
git_cherry_pickGit Cherry-PickA
Cherry-pick commits from other branches. Apply specific commits to the current branch without merging entire branches.
Inputs: commits (required), path, noCommit, continueOperation, +4 more. Returns: success, pickedCommits, conflicts, conflictedFiles
git_cleanGit CleanA
Remove untracked files from the working directory. Requires force flag for safety. Use dry-run to preview files that would be removed.
Inputs: path, force, dryRun, directories, +1 more. Returns: success, filesRemoved, directoriesRemoved, dryRun
git_clear_working_dirGit Clear Working DirectoryA
Clear the session working directory setting. This resets the context without restarting the server. Subsequent git operations will require an explicit path parameter unless git_set_working_dir is called again.
Inputs: confirm (required). Returns: success, message, previousPath
git_cloneGit CloneA
Clone a repository from a remote URL to a local path. Supports HTTP/HTTPS and SSH URLs, with optional shallow cloning.
Inputs: url (required), localPath (required), branch, depth, +2 more. Returns: success, remoteUrl, localPath, branch, +1 more
git_commitGit CommitA
Create a new commit with staged changes in the repository. Records a snapshot of the staging area with a commit message.
Commit Message Format: Pass commit messages as JSON string parameters. Multi-line messages are supported using standard JSON string escaping.
Examples:
Single line: { "message": "feat: add user authentication" }
Multi-line: { "message": "feat: add user authentication\n\nImplemented OAuth2 flow with JWT tokens.\nAdded tests for login and logout." }
Note: Do not use bash heredoc syntax. Literal escape sequences (\n, \t) in the message string are automatically normalized to their actual characters.
Inputs: message (required), path, author, amend, +5 more. Returns: success, commitHash, message, author, +6 more
git_diffGit DiffBRead-only
View differences between commits, branches, or working tree. Shows changes in unified diff format.
Inputs: path, target, source, paths, +6 more. Returns: success, diff, filesChanged, insertions, +2 more
git_fetchGit FetchA
Fetch updates from a remote repository. Downloads objects and refs without merging them.
Inputs: path, remote, prune, tags, +1 more. Returns: success, remote, fetchedRefs, prunedRefs
git_initGit InitA
Initialize a new Git repository at the specified path. Creates a .git directory and sets up the initial branch.
Inputs: path, initialBranch, bare. Returns: success, path, initialBranch, isBare
git_logGit LogARead-only
View commit history with optional filtering by author, date range, file path, or commit message pattern.
Inputs: path, maxCount, skip, since, +9 more. Returns: success, commits, totalCount
git_mergeGit MergeB
Merge branches together. Integrates changes from another branch into the current branch with optional merge strategies.
Inputs: branch (required), path, strategy, noFastForward, +3 more. Returns: success, strategy, fastForward, conflicts, +3 more
git_pullGit PullA
Pull changes from a remote repository. Fetches and integrates changes into the current branch.
Inputs: path, remote, branch, rebase, +1 more. Returns: success, remote, branch, strategy, +2 more
git_pushGit PushC
Push changes to a remote repository. Uploads local commits to the remote branch.
Inputs: path, remote, branch, force, +7 more. Returns: success, remote, branch, upstreamSet, +2 more
git_rebaseGit RebaseB
Rebase commits onto another branch. Reapplies commits on top of another base tip for a cleaner history.
Inputs: path, mode, upstream, branch, +3 more. Returns: success, conflicts, conflictedFiles, rebasedCommits, +1 more
git_reflogGit ReflogARead-only
View the reference logs (reflog) to track when branch tips and other references were updated. Useful for recovering lost commits.
Inputs: path, ref, maxCount. Returns: success, ref, entries, totalEntries
git_remoteGit RemoteA
Manage remote repositories: list remotes, add new remotes, remove remotes, rename remotes, or get/set remote URLs.
Inputs: path, mode, name, url, +2 more. Returns: success, mode, remotes, url, +3 more
git_resetGit ResetA
Reset current HEAD to specified state. Can be used to unstage files (soft), discard commits (mixed), or discard all changes (hard).
Inputs: path, mode, target, paths, +1 more. Returns: success, mode, target, filesReset
git_set_working_dirGit Set Working DirectoryA
Set the session working directory for all git operations. This allows subsequent git commands to omit the path parameter and use this directory as the default.
Inputs: path (required), validateGitRepo, initializeIfNotPresent, includeMetadata. Returns: success, path, message, repositoryContext
git_showGit ShowARead-only
Show details of a git object (commit, tree, blob, or tag). Displays commit information and the diff of changes introduced.
Inputs: object (required), path, format, stat, +1 more. Returns: success, object, type, content, +1 more
git_stashGit StashA
Manage stashes: list stashes, save current changes (push), restore changes (pop/apply), or remove stashes (drop/clear).
Inputs: path, mode, message, stashRef, +2 more. Returns: success, mode, stashes, created, +3 more
git_statusGit StatusARead-only
Show the working tree status including staged, unstaged, and untracked files.
Inputs: path, includeUntracked. Returns: success, currentBranch, isClean, stagedChanges, +3 more
git_tagGit TagA
Manage tags: list all tags, create a new tag, or delete a tag. Tags are used to mark specific points in history (releases, milestones).
Inputs: path, mode, tagName, commit, +5 more. Returns: success, mode, tags, created, +1 more
git_worktreeGit WorktreeB
Manage multiple working trees: list worktrees, add new worktrees for parallel work, remove worktrees, or move worktrees to new locations.
Inputs: path, mode, worktreePath, branch, +6 more. Returns: success, mode, worktrees, added, +3 more
git_wrapup_instructionsGit Wrap-up InstructionsARead-only
Provides the user's desired Git wrap-up workflow and instructions. Returns custom workflow steps (if configured) or default best practices for reviewing, documenting, and committing changes. Includes current repository status to guide next actions.
Inputs: acknowledgement (required), updateAgentMetaFiles, createTag. Returns: instructions, gitStatus, gitStatusError
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Every tool has a clearly distinct purpose with no ambiguity. Each tool corresponds to a specific Git command or operation, such as git_add for staging files, git_commit for creating commits, and git_merge for merging branches. The descriptions reinforce these distinctions, making it easy for an agent to select the correct tool without confusion.
The tool names follow a highly consistent verb_noun pattern throughout, all prefixed with 'git_' and using snake_case uniformly. Examples include git_clone, git_pull, and git_status, with no deviations in style or structure. This predictability enhances readability and usability for agents.
With 28 tools, the count feels heavy for a Git server, as many tools cover niche or advanced operations like git_changelog_analyze and git_wrapup_instructions. While comprehensive, it may overwhelm agents with less common commands, suggesting a borderline scope that could benefit from consolidation or simplification.
The tool set provides complete coverage of Git operations, including core commands (e.g., clone, commit, push), branch management, history viewing, and advanced features like stashing and worktrees. There are no obvious gaps; agents can perform full CRUD/lifecycle tasks for repository management without dead ends.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
A MCP server built for developers enabling Git based project management with project and personal…
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
Related MCP Servers
- AlicenseBqualityBmaintenanceA Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.14115,976 PyPI92,301MIT
- AlicenseCqualityCmaintenanceNode.js server implementing Model Context Protocol for git operations, enabling AI assistants to manage git repositories through natural language commands.11MIT
- AlicenseBqualityDmaintenanceA 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.12MIT
- AlicenseCqualityBmaintenanceA 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.224MIT