{"id":24941937,"url":"https://github.com/cyanheads/git-mcp-server","last_synced_at":"2025-03-28T18:40:51.693Z","repository":{"id":268389381,"uuid":"904190702","full_name":"cyanheads/git-mcp-server","owner":"cyanheads","description":"A Model Context Protocol (MCP) server to provide git tools for LLM Agents","archived":false,"fork":false,"pushed_at":"2025-03-15T04:47:52.000Z","size":53,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T05:19:11.453Z","etag":null,"topics":["ai","git","llm","mcp","modelcontextprotocol"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyanheads.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-16T12:21:40.000Z","updated_at":"2025-03-15T04:47:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"91666eba-73c4-4e62-9477-d37048b51a19","html_url":"https://github.com/cyanheads/git-mcp-server","commit_stats":null,"previous_names":["cyanheads/git-mcp-server"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fgit-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fgit-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fgit-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fgit-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyanheads","download_url":"https://codeload.github.com/cyanheads/git-mcp-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246082616,"owners_count":20720830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","git","llm","mcp","modelcontextprotocol"],"created_at":"2025-02-02T18:57:26.879Z","updated_at":"2025-03-28T18:40:51.687Z","avatar_url":"https://github.com/cyanheads.png","language":"TypeScript","funding_links":[],"categories":["📚 Projects (1974 total)","🤖 AI/ML","TypeScript","Developer Tools","Version Control"],"sub_categories":["MCP Servers"],"readme":"# GIT MCP Server\n\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue.svg)](https://www.typescriptlang.org/)\n[![Model Context Protocol](https://img.shields.io/badge/MCP-1.7.0-green.svg)](https://modelcontextprotocol.io/)\n[![Version](https://img.shields.io/badge/Version-1.2.0-blue.svg)]()\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Status](https://img.shields.io/badge/Status-Beta-orange.svg)]()\n[![GitHub](https://img.shields.io/github/stars/cyanheads/git-mcp-server?style=social)](https://github.com/cyanheads/git-mcp-server)\n\nA Model Context Protocol (MCP) server that provides tools for interacting with Git repositories. This server allows AI assistants and LLM agents to manage repositories, branches, commits, and files through a standardized interface without requiring direct filesystem or command-line access. It exposes Git operations as MCP resources and tools while maintaining proper security boundaries.\n\n## Table of Contents\n\n- [Overview](#overview)\n  - [Architecture \u0026 Components](#architecture--components)\n- [Features](#features)\n  - [Resource Access](#resource-access)\n  - [Git Operations](#git-operations)\n- [Installation](#installation)\n  - [Prerequisites](#prerequisites)\n  - [Install from NPM](#install-from-npm)\n  - [Install from Source](#install-from-source)\n- [Usage](#usage)\n  - [Running the Server](#running-the-server)\n  - [Integration with Claude](#integration-with-claude)\n  - [Integration with Other MCP Clients](#integration-with-other-mcp-clients)\n- [Project Structure](#project-structure)\n- [Tools](#tools)\n  - [Repository Operations](#repository-operations)\n  - [Branch Operations](#branch-operations)\n  - [Working Directory Operations](#working-directory-operations)\n  - [Remote Operations](#remote-operations)\n  - [Advanced Operations](#advanced-operations)\n- [Resources](#resources)\n  - [Repository Resources](#repository-resources)\n- [Development](#development)\n  - [Build and Test](#build-and-test)\n- [License](#license)\n\n## Overview\n\nKey capabilities:\n\n- **Repository Management**: Initialize, clone, and check repository status\n- **Branch Operations**: Create, list, checkout, delete, and merge branches\n- **Working Directory**: Stage files, commit changes, create diffs\n- **Remote Operations**: Add remotes, fetch, pull, push\n- **Advanced Git Commands**: Manage tags, stash changes, cherry-pick, rebase\n\n### Architecture \u0026 Components\n\nCore system architecture:\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand Mermaid diagram\u003c/summary\u003e\n\n```mermaid\nflowchart TB\n    subgraph API[\"API Layer\"]\n        direction LR\n        MCP[\"MCP Protocol\"]\n        Val[\"Validation\"]\n\n        MCP --\u003e Val\n    end\n\n    subgraph Core[\"Core Services\"]\n        direction LR\n        GitService[\"Git Service\"]\n        ErrorService[\"Error Service\"]\n\n        GitService \u003c--\u003e ErrorService\n    end\n\n    subgraph Resources[\"Resource Layer\"]\n        direction LR\n        Repo[\"Repository Resources\"]\n        Diff[\"Diff Resources\"]\n        File[\"File Resources\"]\n        History[\"History Resources\"]\n\n        Repo \u003c--\u003e Diff\n        Repo \u003c--\u003e File\n        Repo \u003c--\u003e History\n    end\n\n    subgraph Tools[\"Tool Layer\"]\n        direction LR\n        RepoTools[\"Repository Tools\"]\n        BranchTools[\"Branch Tools\"]\n        WorkdirTools[\"Working Directory Tools\"]\n        RemoteTools[\"Remote Tools\"]\n        AdvancedTools[\"Advanced Tools\"]\n\n        RepoTools \u003c--\u003e BranchTools\n        BranchTools \u003c--\u003e WorkdirTools\n        WorkdirTools \u003c--\u003e RemoteTools\n        RemoteTools \u003c--\u003e AdvancedTools\n    end\n\n    Val --\u003e GitService\n    GitService --\u003e Resources\n    GitService --\u003e Tools\n\n    classDef layer fill:#2d3748,stroke:#4299e1,stroke-width:3px,rx:5,color:#fff\n    classDef component fill:#1a202c,stroke:#a0aec0,stroke-width:2px,rx:3,color:#fff\n    classDef api fill:#3182ce,stroke:#90cdf4,stroke-width:2px,rx:3,color:#fff\n    classDef core fill:#319795,stroke:#81e6d9,stroke-width:2px,rx:3,color:#fff\n    classDef resource fill:#2f855a,stroke:#9ae6b4,stroke-width:2px,rx:3,color:#fff\n    classDef tool fill:#805ad5,stroke:#d6bcfa,stroke-width:2px,rx:3,color:#fff\n\n    class API,Core,Resources,Tools layer\n    class MCP,Val api\n    class GitService,ErrorService core\n    class Repo,Diff,File,History resource\n    class RepoTools,BranchTools,WorkdirTools,RemoteTools,AdvancedTools tool\n```\n\n\u003c/details\u003e\n\nCore Components:\n\n- **MCP Server**: Uses the Model Context Protocol SDK to create a server that exposes resources and tools\n- **Git Service**: Abstraction layer over simple-git to provide clean interfaces for Git operations\n- **Resources**: Expose Git data through MCP resources with consistent URI templates\n- **Tools**: Expose Git operations through MCP tools with well-defined schemas\n- **Error Handling**: Standardized error handling and reporting\n\n## Features\n\n### Resource Access\n\nExpose Git repository information through MCP resources:\n\n- **Repository Information**: Access basic Git repository information including current branch, status, and reference details\n- **Repository Branches**: List all branches in the repository with current branch indicator\n- **Repository Remotes**: List all configured remote repositories with their URLs\n- **Repository Tags**: List all tags in the repository with their references\n- **File Content**: Access content of specific files at a given Git reference\n- **Directory Listing**: View lists of files and directories at a specific path and reference\n- **Diffs**: Get differences between references, unstaged changes, or staged changes\n- **Commit History**: View detailed commit logs with author, date, and message information\n- **File Blame**: See line-by-line attribution showing which commit last modified each line\n- **Commit Details**: Access detailed information about specific commits including diff changes\n\n### Git Operations\n\nExecute Git commands through MCP tools:\n\n- **Repository Operations**: Initialize repositories, clone from remotes, check repository status\n- **Branch Operations**: Create branches, list branches, checkout, delete branches, merge\n- **Working Directory Operations**: Stage files, unstage files, commit changes, create diffs\n- **Remote Operations**: Add remotes, list remotes, fetch, pull, push\n- **Advanced Operations**: Manage tags, stash changes, cherry-pick commits, rebase branches, reset, clean\n\n## Installation\n\n### Prerequisites\n\n- Node.js 16 or higher\n- Git installed and available in the PATH\n\n### Install from NPM\n\n```bash\nnpm install -g git-mcp-server\n```\n\n### Install from Source\n\n```bash\ngit clone https://github.com/cyanheads/git-mcp-server.git\ncd git-mcp-server\nnpm install\nnpm run build\n```\n\n## Usage\n\n### Running the Server\n\n```bash\ngit-mcp-server\n```\n\nThe server communicates through stdin/stdout using the Model Context Protocol, making it compatible with any MCP client.\n\n### Integration with Claude\n\nAdd to your Claude configuration file:\n\n```json\n{\n  \"mcpServers\": {\n    \"git\": {\n      \"command\": \"git-mcp-server\",\n      \"args\": [],\n      \"env\": {},\n      \"disabled\": false\n    }\n  }\n}\n```\n\n### Integration with Other MCP Clients\n\nUse the MCP inspector to test the server:\n\n```bash\nnpx @modelcontextprotocol/inspector git-mcp-server\n```\n\n## Project Structure\n\nThe codebase follows a modular structure:\n\n```\ngit-mcp-server/\n├── src/\n│   ├── index.ts           # Entry point\n│   ├── server.ts          # MCP server implementation\n│   ├── resources/         # Resource implementations\n│   │   ├── descriptors.ts # Resource URI templates\n│   │   ├── diff.ts        # Diff-related resources\n│   │   ├── file.ts        # File-related resources\n│   │   ├── history.ts     # History-related resources\n│   │   ├── index.ts       # Resource registration\n│   │   └── repository.ts  # Repository resources\n│   ├── services/          # Service implementations\n│   │   ├── error-service.ts # Error handling\n│   │   └── git-service.ts   # Git operations abstraction\n│   ├── tools/             # Tool implementations\n│   │   ├── advanced.ts    # Advanced Git operations\n│   │   ├── branch.ts      # Branch operations\n│   │   ├── index.ts       # Tool registration\n│   │   ├── remote.ts      # Remote operations\n│   │   ├── repository.ts  # Repository operations\n│   │   └── workdir.ts     # Working directory operations\n│   ├── types/             # Type definitions\n│   │   └── git.ts         # Git-related types\n│   └── utils/             # Utility functions\n│       └── validation.ts  # Input validation\n└── scripts/               # Development scripts\n```\n\n## Tools\n\nGit MCP Server provides a comprehensive suite of tools for Git operations:\n\n### Repository Operations\n\n| Tool         | Description                                                                                      |\n| ------------ | ------------------------------------------------------------------------------------------------ |\n| `git_init`   | Initialize a new Git repository at the specified path with options for bare repositories.        |\n| `git_clone`  | Clone a Git repository from a remote URL to a local path with branch and depth options.          |\n| `git_status` | Get the current status of a Git repository including working directory and staging area changes. |\n\n### Branch Operations\n\n| Tool                | Description                                                                                    |\n| ------------------- | ---------------------------------------------------------------------------------------------- |\n| `git_branch_list`   | List all branches in a repository with options to include remote branches.                     |\n| `git_branch_create` | Create a new branch with options for specifying the starting point and automatic checkout.     |\n| `git_checkout`      | Checkout a branch, tag, or commit with options to create a new branch during checkout.         |\n| `git_branch_delete` | Delete a branch with options for force deletion of unmerged branches.                          |\n| `git_merge`         | Merge a branch into the current branch with customizable commit messages and merge strategies. |\n\n### Working Directory Operations\n\n| Tool                | Description                                                                                     |\n| ------------------- | ----------------------------------------------------------------------------------------------- |\n| `git_add`           | Stage files for commit with support for individual files or entire directories.                 |\n| `git_reset`         | Unstage files from the staging area with options for specific files or all staged changes.      |\n| `git_commit`        | Commit staged changes with customizable commit messages, author information, and amend options. |\n| `git_diff_unstaged` | Get a diff of all unstaged changes in the working directory with options for specific files.    |\n| `git_diff_staged`   | Get a diff of all staged changes in the index with options for specific files.                  |\n| `git_reset_commit`  | Reset the repository to a specific reference with options for hard, soft, or mixed mode.        |\n| `git_clean`         | Remove untracked files from the working tree with options for directories and force cleaning.   |\n\n### Remote Operations\n\n| Tool              | Description                                                                                  |\n| ----------------- | -------------------------------------------------------------------------------------------- |\n| `git_remote_add`  | Add a new remote repository with a name and URL.                                             |\n| `git_remote_list` | List all configured remote repositories and their URLs.                                      |\n| `git_fetch`       | Fetch updates from a remote repository with options for specific branches.                   |\n| `git_pull`        | Pull changes from a remote repository with options for rebase strategy.                      |\n| `git_push`        | Push local changes to a remote repository with options for force push and upstream tracking. |\n\n### Advanced Operations\n\n| Tool               | Description                                                                               |\n| ------------------ | ----------------------------------------------------------------------------------------- |\n| `git_tag_create`   | Create a new tag with options for annotated tags with messages.                           |\n| `git_tag_list`     | List all tags in the repository with their references.                                    |\n| `git_stash_create` | Stash changes in the working directory with options for untracked files and descriptions. |\n| `git_stash_list`   | List all stashes in the repository with their descriptions.                               |\n| `git_stash_apply`  | Apply a stashed change without removing it from the stash list.                           |\n| `git_stash_pop`    | Apply a stashed change and remove it from the stash list.                                 |\n| `git_cherry_pick`  | Apply changes from specific commits to the current branch.                                |\n| `git_rebase`       | Rebase the current branch onto another branch with interactive mode options.              |\n| `git_log`          | Get commit history with customizable output format and depth.                             |\n| `git_show`         | Show detailed information about a specific commit including diff changes.                 |\n\n## Resources\n\nGit MCP Server exposes Git data through standard MCP resources:\n\n### Repository Resources\n\n| Resource                                                    | Description                                                                              |\n| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------- |\n| `git://repo/{repoPath}/info`                                | Basic Git repository information including current branch, status, and reference details |\n| `git://repo/{repoPath}/branches`                            | List of all branches in the repository with current branch indicator                     |\n| `git://repo/{repoPath}/remotes`                             | List of all configured remote repositories with their URLs                               |\n| `git://repo/{repoPath}/tags`                                | List of all tags in the repository with their references                                 |\n| `git://repo/{repoPath}/file/{filePath}?ref={ref}`           | Returns the content of a specific file at a given Git reference                          |\n| `git://repo/{repoPath}/ls/{dirPath}?ref={ref}`              | Returns a list of files and directories at a specific path and reference                 |\n| `git://repo/{repoPath}/diff/{fromRef}/{toRef}?path={path}`  | Returns a diff between two Git references (commits, branches, tags)                      |\n| `git://repo/{repoPath}/diff-unstaged?path={path}`           | Returns a diff of all unstaged changes in the working directory                          |\n| `git://repo/{repoPath}/diff-staged?path={path}`             | Returns a diff of all staged changes in the index                                        |\n| `git://repo/{repoPath}/log?maxCount={maxCount}\u0026file={file}` | Returns the commit history log with author, date, and message details                    |\n| `git://repo/{repoPath}/blame/{filePath}`                    | Returns line-by-line attribution showing which commit last modified each line            |\n| `git://repo/{repoPath}/commit/{commitHash}`                 | Returns detailed information about a specific commit including diff changes              |\n\n## Development\n\n### Build and Test\n\n```bash\n# Build the project\nnpm run build\n\n# Watch for changes\nnpm run watch\n\n# Test with MCP inspector\nnpm run inspector\n\n# Clean build artifacts\nnpm run clean\n\n# Rebuild completely\nnpm run rebuild\n```\n\n## License\n\nApache License 2.0 - See [LICENSE](LICENSE) for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\nBuilt with the Model Context Protocol\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fgit-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyanheads%2Fgit-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fgit-mcp-server/lists"}