git MCP server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Provides tools to read, search, and manipulate Git repositories via Large Language Models. Includes functionalities for viewing git status, diffs, committing changes, managing branches, and other git operations.

mcp-server-git: Git MCP サーバー

概要

Gitリポジトリのインタラクションと自動化のためのモデルコンテキストプロトコルサーバー。このサーバーは、大規模言語モデルを介してGitリポジトリの読み取り、検索、操作を行うツールを提供します。

mcp-server-gitは現在開発初期段階にあります。サーバーの開発と改良に伴い、機能と利用可能なツールは変更・拡張される可能性があります。

ツール

  1. git_status
    • 作業ツリーのステータスを表示します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
    • 戻り値: 作業ディレクトリの現在の状態をテキスト出力として返す
  2. git_diff_unstaged
    • 作業ディレクトリ内のまだステージングされていない変更を表示します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
    • 戻り値: ステージングされていない変更の差分出力
  3. git_diff_staged
    • コミットのためにステージングされた変更を表示します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
    • 戻り値: ステージングされた変更の差分出力
  4. git_diff
    • ブランチまたはコミット間の差異を表示します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
      • target (文字列): 比較する対象のブランチまたはコミット
    • 戻り値: 現在の状態とターゲットを比較した差分出力
  5. git_commit
    • リポジトリへの変更を記録する
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
      • message (文字列): コミットメッセージ
    • 戻り値: 新しいコミットハッシュによる確認
  6. git_add
    • ファイルの内容をステージング領域に追加します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
      • files (文字列[]): ステージングするファイルパスの配列
    • 戻り値: ステージングされたファイルの確認
  7. git_reset
    • ステージングされたすべての変更をステージ解除します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
    • 戻り値: リセット操作の確認
  8. git_log
    • コミットログを表示します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
      • max_count (数値、オプション): 表示するコミットの最大数 (デフォルト: 10)
    • 戻り値: ハッシュ、作成者、日付、メッセージを含むコミットエントリの配列
  9. git_create_branch
    • 新しいブランチを作成します
    • 入力:
      • repo_path (文字列): Gitリポジトリへのパス
      • branch_name (文字列): 新しいブランチの名前
      • start_point (文字列、オプション): 新しいブランチの開始点
    • 戻り値: ブランチ作成の確認
  10. git_checkout
  • スイッチブランチ
  • 入力:
    • repo_path (文字列): Gitリポジトリへのパス
    • branch_name (文字列): チェックアウトするブランチの名前
  • 戻り値: ブランチ切り替えの確認
  1. git_show
  • コミットの内容を表示します
  • 入力:
    • repo_path (文字列): Gitリポジトリへのパス
    • revision (文字列):表示するリビジョン(コミットハッシュ、ブランチ名、タグ)
  • 戻り値: 指定されたコミットの内容
  1. git_init
  • Gitリポジトリを初期化する
  • 入力:
    • repo_path (文字列): gitリポジトリを初期化するディレクトリへのパス
  • 戻り値: リポジトリの初期化の確認

インストール

uvの使用(推奨)

uvを使用する場合、特別なインストールは必要ありません。uvx uvx使用してmcp-server-gitを直接実行します。

PIPの使用

あるいは、pip 経由でmcp-server-gitをインストールすることもできます。

pip install mcp-server-git

インストール後、次のコマンドを使用してスクリプトとして実行できます。

python -m mcp_server_git

構成

Claude Desktopでの使用

これをclaude_desktop_config.jsonに追加します:

"mcpServers": { "git": { "command": "uvx", "args": ["mcp-server-git", "--repository", "path/to/git/repo"] } }
  • 注: '/Users/username' を、このツールでアクセスできるようにするパスに置き換えてください。
"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"] } }

Zedでの使用

Zed のsettings.jsonに追加します:

"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"] } } },

デバッグ

MCPインスペクタを使用してサーバーをデバッグできます。UVXインストールの場合:

npx @modelcontextprotocol/inspector uvx mcp-server-git

または、パッケージを特定のディレクトリにインストールした場合や、そのディレクトリで開発している場合は、次のようにします。

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

tail -n 20 -f ~/Library/Logs/Claude/mcp*.logを実行すると、サーバーのログが表示され、問題のデバッグに役立つ場合があります。

発達

ローカル開発を行っている場合、変更をテストする方法は 2 つあります。

  1. MCPインスペクタを実行して変更内容をテストしてください。実行手順についてはデバッグを参照してください。
  2. Claudeデスクトップアプリを使ってテストしclaude_desktop_config.json 。claude_desktop_config.json に以下のコードを追加してください。

ドッカー

{ "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" ] } }

建てる

Dockerビルド:

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

ライセンス

このMCPサーバーはMITライセンスに基づいてライセンスされています。つまり、MITライセンスの条件に従って、ソフトウェアを自由に使用、改変、配布することができます。詳細については、プロジェクトリポジトリのLICENSEファイルをご覧ください。

-
security - not tested
A
license - permissive license
-
quality - not tested

Gitリポジトリのインタラクションと自動化のためのモデルコンテキストプロトコルサーバー。このサーバーは、大規模言語モデルを介してGitリポジトリの読み取り、検索、操作を行うツールを提供します。

  1. Overview
    1. Tools
  2. Installation
    1. Using uv (recommended)
    2. Using PIP
  3. Configuration
    1. Usage with Claude Desktop
    2. Usage with Zed
  4. Debugging
    1. Development
      1. Docker
      2. UVX
    2. Build
      1. License
        ID: 2sijuvbdae