cyanheads/git-mcp-server
If you are the rightful owner of git-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
An MCP server providing tools to interact with Git repositories, enabling LLMs and AI agents to perform Git operations via the MCP standard.
Tools
Functions exposed to the LLM to take actions
git_add
Stages changes in the Git repository for the next commit by adding file contents to the index (staging area). Can stage specific files/patterns or all changes (default: '.'). Returns the result as a JSON object.
git_branch
Manages Git branches. Supports listing (local, remote, all), creating, deleting (with force), renaming (with force), and showing the current branch. Returns results as a JSON object.
git_checkout
Switches branches or restores working tree files. Can checkout branches, commits, tags, or specific file paths. Supports creating new branches and forcing checkout.
git_cherry_pick
Applies the changes introduced by existing commits. Supports picking single commits or ranges, handling merge commits, and options like --no-commit and --signoff. Returns results as a JSON object, indicating success, failure, or conflicts.
git_clean
Removes untracked files from the working directory. Supports dry runs, removing directories, and removing ignored files. CRITICAL: Requires explicit force: true
parameter for safety as this is a destructive operation. Returns results as a JSON object.
git_clear_working_dir
Clears the session-specific working directory previously set by git_set_working_dir
. Subsequent Git tool calls in this session will require an explicit path
parameter or will default to the server's current working directory. Returns the result as a JSON object.
git_clone
Clones a Git repository from a given URL into a specified absolute directory path. Supports cloning specific branches and setting clone depth.
git_commit
Commits staged changes to the Git repository index with a descriptive message. Supports author override, amending, and empty commits. Returns a JSON result.
Commit Message Guidance:
Write clear, concise commit messages using the Conventional Commits format: type(scope): subject
.
type
: feat, fix, docs, style, refactor, test, chore, etc.(scope)
: Optional context (e.g.,auth
,ui
, filename).subject
: Imperative, present tense description (e.g., "add login button", not "added login button").
I want to understand what you did and why. Use the body for detailed explanations, if necessary.
Example Commit Message:
feat(auth): implement password reset endpoint
- Adds the /api/auth/reset-password endpoint to allow users to reset their password via an email link.
- Includes input validation and rate limiting.
Closes #123 (if applicable).
Tool Options & Behavior:
- Commit related changes logically. Use the optional
filesToStage
parameter to auto-stage specific files before committing. - The
path
defaults to the session's working directory unless overridden. IfGIT_SIGN_COMMITS=true
is set, commits are signed (-S
), with an optionalforceUnsignedOnFailure
fallback.
git_diff
Shows changes between commits, commit and working tree, etc. Can show staged changes or diff specific files. An optional 'includeUntracked' parameter (boolean) can be used to also show the content of untracked files. Returns the diff output as plain text.
git_fetch
Downloads objects and refs from one or more other repositories. Can fetch specific remotes or all, prune stale branches, and fetch tags.
git_init
Initializes a new Git repository at the specified path. If path is relative or omitted, it resolves against the session working directory (if you have set the git_working_dir). Can optionally set the initial branch name and create a bare repository.
git_log
Shows commit logs for the repository. Supports limiting count, filtering by author, date range, and specific branch/file. Returns a JSON object containing a list of commit objects (commits
array) by default. If showSignature: true
is used, it returns a JSON object where the commits
array is empty and the raw signature verification output is included in the message
field.
git_merge
Merges the specified branch into the current branch. Supports options like --no-ff, --squash, and --abort. Returns the merge result as a JSON object.
git_pull
Fetches from and integrates with another repository or a local branch (e.g., 'git pull origin main'). Supports rebase and fast-forward only options. Returns the pull result as a JSON object.
git_push
Updates remote refs using local refs, sending objects necessary to complete the given refs. Supports pushing specific branches, tags, forcing, setting upstream, and deleting remote branches. Returns the push result as a JSON object.
git_rebase
Reapplies commits on top of another base tip. Supports starting a rebase (standard or interactive), continuing, aborting, or skipping steps in an ongoing rebase. Returns results as a JSON object.
git_remote
Manages remote repositories (list, add, remove, show).
git_reset
Resets the current HEAD to a specified state. Supports different modes ('soft', 'mixed', 'hard', 'merge', 'keep') to control how the index and working tree are affected. Can reset to a specific commit. USE 'hard' MODE WITH EXTREME CAUTION as it discards local changes.
git_set_working_dir
Sets the default working directory for the current session. Subsequent Git tool calls within this session can use '.' for the path
parameter, which will resolve to this directory. Optionally validates if the path is a Git repository (validateGitRepo: true
). Can optionally initialize a Git repository with 'git init' if it's not already one and initializeIfNotPresent: true
is set. Returns the result as a JSON object. IMPORTANT: The provided path must be absolute.
git_show
Shows information about Git objects (commits, tags, blobs, trees) based on a reference. Can optionally show the content of a specific file at that reference. Returns the raw output.
git_stash
Manages stashed changes in the working directory. Supports listing stashes, applying/popping specific stashes (with conflict detection), dropping stashes, and saving current changes to a new stash with an optional message. Returns results as a JSON object.
git_status
Retrieves the status of a Git repository. Returns a JSON object detailing the current branch, cleanliness, and changes. Staged and unstaged changes are grouped by status (e.g., Added, Modified), alongside lists of untracked and conflicted files.
git_tag
Manages Git tags. Supports listing existing tags, creating new lightweight or annotated tags against specific commits, and deleting local tags. Returns results as a JSON object.
git_worktree
Manages Git worktrees. Supports listing, adding, removing, moving, and pruning worktrees. Returns results as a JSON object.
git_wrapup_instructions
Provides a standard Git wrap-up workflow. This involves reviewing changes with git_diff
, updating documentation (README, CHANGELOG), and making logical, descriptive commits using the git_commit
tool. The tool's response also includes the current git status
output. You should set the working directory using git_set_working_dir
before running this tool.
Prompts
Interactive templates invoked by user choice
No prompts
Resources
Contextual data attached and managed by the client