git-mcp-server
Git MCP サーバー
Gitリポジトリと連携するためのツールを提供するMCP(Model Context Protocol)サーバー。LLMとAIエージェントがMCP標準を介して、クローン、コミット、プッシュ、プル、ブランチ、差分、ログ、ステータスなどのGit操作を実行できるようにします。
cyanheads/mcp-ts-template上に構築されたこのサーバーは、モジュラー アーキテクチャに従います。
開発者向けメモ: このリポジトリには、コードベース パターン、ファイルの場所、およびコード スニペットのクイック リファレンスを含む、LLM コーディング エージェントの開発者向けチート シートとして機能する.clinerulesファイルが含まれています。
目次
Related MCP server: GIT MCP Server
概要
シームレスな Git 統合により、AI エージェントと開発ツールを強化します。
Git MCP サーバーはブリッジとして機能し、モデル コンテキスト プロトコル (MCP) を理解するアプリケーション (MCP クライアント) (高度な AI アシスタント (LLM)、IDE 拡張機能、カスタム スクリプトなど) がローカル Git リポジトリと直接安全にやり取りできるようにします。
複雑なスクリプトや手動の CLI の代わりに、ツールはこのサーバーを活用して次のことを行うことができます。
Git ワークフローを自動化: リポジトリのクローン作成、ブランチの作成、変更のステージング、作業のコミット、更新のプッシュ、タグの管理をプログラムで実行します。
リポジトリの洞察を得る: ホスト アプリケーションを離れずに、ステータスを確認し、ログを表示し、変更を比較し、Git オブジェクトを検査します。
Git を AI 駆動型開発に統合: LLM がコーディングまたはリファクタリング タスクの一環としてバージョン管理を管理できるようにします。
堅牢なmcp-ts-templateをベースに構築されたこのサーバーは、MCP標準を介してGit機能を公開するための、標準化された安全かつ効率的な方法を提供します。Node.jsのchild_processモジュールを使用して、システムにインストールされている標準のgitコマンドラインツールを安全に実行することでこれを実現し、互換性を確保しながらGitのパワーを最大限に活用します。
特徴
コアユーティリティ(テンプレートから)
mcp-ts-templateによって提供される堅牢なユーティリティを活用します。
ログ記録: 機密データの編集を伴う構造化された構成可能なログ記録 (ファイルのローテーション、コンソール、MCP 通知)。
エラー処理: 集中化されたエラー処理、標準化されたエラー タイプ (
McpError)、および自動ログ記録。設定: 環境変数の読み込み (
dotenv)。入力検証/サニタイズ: スキーマ検証とカスタム サニタイズ ロジック (パスに重要) に
zod使用します。リクエスト コンテキスト: 一意のリクエスト ID による操作の追跡と相関。
型の安全性: TypeScript と Zod スキーマによって強制される強力な型付け。
HTTP トランスポート オプション: SSE、セッション管理、CORS サポートを備えた組み込み Express サーバー。
Git操作
直接 Git CLI 実行: Node.js
child_processを介して標準のgitコマンドライン ツールを安全に実行することで Git と対話し、完全な互換性と Git の機能へのアクセスを確保します。包括的なコマンド カバレッジ: 幅広い Git コマンドを MCP ツールとして公開します (ツールセクションを参照)。
リポジトリインタラクション: ステータスのチェック、ブランチ、ステージング、コミット、フェッチ、プル、プッシュ、比較、ログ記録、リセット、タグ付けなどをサポートします。
作業ディレクトリ管理: 複数の Git 操作にわたってコンテキストを永続化するために、セッション固有の作業ディレクトリを設定およびクリアできます。
安全機能:
git cleanやgit reset --hardなどの潜在的に破壊的な操作に対するチェックが含まれ、明示的な確認が必要です。コミット署名:検証済みコミットのGPGまたはSSH署名をサポートします。GIT_SIGN_COMMITS環境変数とサーバー側のGit設定によって制御されます。署名失敗時に未署名コミットにフォールバックするためのオプションツールパラメータも
GIT_SIGN_COMMITSれています。
インストール
前提条件
npm経由でインストール
パッケージをグローバルにインストールします。
npm install @cyanheads/git-mcp-server
ソースからインストール
リポジトリをクローンします。
git clone https://github.com/cyanheads/git-mcp-server.git cd git-mcp-server依存関係をインストールします:
npm installプロジェクトをビルドします。
npm run build (or `npm run rebuild`)これにより、TypeScript コードが
dist/ディレクトリ内の JavaScript にコンパイルされ、エントリ ポイントが実行可能になります。
構成
環境変数
環境変数を使用してサーバーを設定します。プロジェクトルートに.envファイルを作成するか( .env.exampleからコピー)、環境変数を環境に設定します。
変数 | 説明 | デフォルト |
| トランスポート メカニズム: |
|
| HTTPサーバーのポート( |
|
| HTTP サーバーのホスト アドレス ( |
|
| CORS に許可されるオリジンのコンマ区切りリスト ( | (なし) |
| ログレベル( |
|
|
|
|
| 認証トークンの署名/検証用の秘密キー (将来認証が有効になった場合に必要)。 |
|
MCPクライアント設定
MCP クライアント設定に追加します (例: 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
}
}
}プロジェクト構造
コードベースは、 src/ディレクトリ内でモジュール構造に従います。
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.)詳細なファイル ツリーについては、 npm run treeを実行するか、 docs/tree.mdを参照してください。
ツール
Git MCP サーバーは、モデル コンテキスト プロトコルを介して呼び出すことができる、Git リポジトリと対話するためのツール スイートを提供します。
ツール名 | 説明 | 主な議論 |
| 指定されたファイルまたはパターンをステージングします。 |
|
| ブランチを管理します (一覧表示、作成、削除、名前変更、現在の表示)。 |
|
| ブランチを切り替えたり、作業ツリー ファイルを復元したりします。 |
|
| 既存のコミットによって導入された変更を適用します。 |
|
| 追跡されていないファイルを削除します。force |
|
| セッション固有の作業ディレクトリをクリアします。 | (なし) |
| 指定された絶対パスにリポジトリのクローンを作成します。 |
|
| ステージングされた変更をコミットします。作成者によるオーバーライド、署名制御をサポートします。 |
|
| コミット、作業ツリーなどの間の変更を表示します。 |
|
| 他のリポジトリからオブジェクトと参照をダウンロードします。 |
|
| 指定された絶対パスに新しい Git リポジトリを初期化します。初期ブランチのデフォルトは「main」です。 |
|
| コミット ログを表示します。 |
|
| 指定されたブランチを現在のブランチにマージします。 |
|
| 別のリポジトリまたはローカル ブランチから取得して統合します。 |
|
| ローカル参照を使用してリモート参照を更新します。 |
|
| 別のベースチップの上にコミットを再適用します。 |
|
| リモート リポジトリを管理します (一覧表示、追加、削除、表示)。 |
|
| 現在のHEADを指定された状態にリセットします。ソフト、ミックス、ハードモードをサポートします。 「hard」は注意して使用してください。 |
|
| デフォルトの作業ディレクトリを設定します。リポジトリが存在しない場合は、必要に応じて初期化できます。絶対パスが必要です。 |
|
| Git オブジェクト (コミット、タグなど) に関する情報を表示します。 |
|
| 保存された変更を管理します (リスト、適用、ポップ、ドロップ、保存)。 |
|
| リポジトリのステータス (ブランチ、ステージング済み、変更済み、追跡されていないファイル) を取得します。 |
|
| タグを管理します (リスト、注釈付き/軽量の作成、削除)。 |
|
| Git ワークツリーを管理します (リスト、追加、削除、移動、プルーニング)。 |
|
注: git_set_working_dirで設定されている場合、ほとんどのツールのpathパラメータはデフォルトでセッションの作業ディレクトリに設定されます。
リソース
MCP リソースはこのバージョン (v2.0.12) では実装されていません。
このバージョンでは、最新のmcp-ts-templateとMCP SDK v1.12.0に基づいてリファクタリングされたGitツール実装に重点を置いています。これまで利用可能だったリソース機能は、今回のメジャーアップデート中に一時的に削除されました。
MCP リソース アクセスが必要な場合 (たとえば、サーバー経由でファイル コンテンツを直接読み取る場合) は、安定版の**v1.2.4 リリース**を使用してください。
将来の開発により、後続のリリースでリソース機能が再導入される可能性があります。
**注:**このバージョン (v2.0.0) は、最新の MCP SDK に基づいてコア Git ツールのリファクタリングとアップデートに重点を置いています。MCP リソース機能はこのバージョンでは実装されていません。リソースへのアクセスには、 v1.2.4 をご利用ください。
発達
ビルドとテスト
# 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:httpライセンス
このプロジェクトは、Apache License 2.0 に基づいてライセンスされています。詳細については、 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