git-mcp-server
The Git MCP Server enables programmatic interaction with Git repositories for AI agents, IDE extensions, and other MCP-compatible applications.
Capabilities include:
Repository Operations: Initialize, clone, and check repository status
Version Control: Stage files, commit changes, push/pull from remotes
Branch Management: Create, list, delete, and switch branches
Tag Handling: Create, list, and delete tags (including signed/annotated tags)
Remote Management: Add, remove, and list remote repositories
Stash Operations: Save, apply, pop, and remove stashed changes
Advanced Operations: Merge branches, rebase commits, reset HEAD, show diffs
Bulk Actions: Execute multiple Git operations in sequence
Safety Features: Includes safeguards for destructive operations
Note: Most operations require absolute paths for precise repository and file targeting.
Provides comprehensive Git operations including repository initialization, cloning, file staging, committing, branch management, tag operations, remote repository handling, and stash management, enabling LLMs to interact with Git repositories.
Supports interactions with GitHub repositories through Git operations like cloning from GitHub URLs, pushing to and pulling from GitHub remotes, enabling LLMs to manage code on GitHub.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@git-mcp-server show me the commit history for the last week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Tools
28 git operations organized into seven categories:
Category | Tools | Description |
Repository Management |
| Initialize repos, clone from remotes, check status, clean untracked files |
Staging & Commits |
| Stage changes, create commits, compare changes |
History & Inspection |
| View commit history, inspect objects, trace authorship, view ref logs |
Analysis |
| Gather git context and instructions for LLM-driven changelog analysis |
Branching & Merging |
| Manage branches, switch contexts, integrate changes, apply specific commits |
Remote Operations |
| Configure remotes, fetch updates, synchronize repositories, publish changes |
Advanced Workflows |
| Tag releases (list/create/delete/verify), stash changes, reset state, manage worktrees, set/clear session directory |
Related MCP server: GIT MCP Server
Resources
Resource | URI | Description |
Git Working Directory |
| The current session working directory, set via |
Prompts
Prompt | Description | Parameters |
Git Wrap-up | Workflow protocol for completing git sessions: review, document, commit, and tag changes. |
|
Getting started
Runtime
Works with both Bun and Node.js. Runtime is auto-detected.
Runtime | Command | Minimum Version |
Node.js |
| >= 20.0.0 |
Bun |
| >= 1.2.0 |
MCP client configuration
Add the following to your MCP client config (e.g., cline_mcp_settings.json). Update the environment variables to match your setup — especially the git identity fields.
{
"mcpServers": {
"git-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["@cyanheads/git-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info",
"GIT_BASE_DIR": "~/Developer/",
"LOGS_DIR": "~/Developer/logs/git-mcp-server/",
"GIT_USERNAME": "cyanheads",
"GIT_EMAIL": "casey@caseyjhand.com",
"GIT_SIGN_COMMITS": "true"
}
}
}
}Bun users: replace "command": "npx" with "command": "bunx".
For Streamable HTTP, set MCP_TRANSPORT_TYPE=http and MCP_HTTP_PORT=3015.
Features
Built on mcp-ts-template.
Feature | Details |
Declarative tools | Define capabilities in single, self-contained files. The framework handles registration, validation, and execution. |
Error handling | Unified |
Authentication | Supports |
Pluggable storage | Swap backends ( |
Observability | Structured logging (Pino) and optional auto-instrumented OpenTelemetry for traces and metrics. |
Dependency injection | Built with |
Cross-runtime | Auto-detects Bun or Node.js and uses the appropriate process spawning method. |
Provider architecture | Pluggable git provider system. Current: CLI. Planned: isomorphic-git for edge deployment. |
Working directory management | Session-specific directory context for multi-repo workflows. |
Configurable git identity | Override author/committer info via environment variables, with fallback to global git config. |
Commit signing | GPG/SSH signing (enabled by default) for commits, merges, rebases, cherry-picks, and tags. Silent fallback to unsigned on failure with |
Safety | Destructive operations ( |
Security
All file paths are validated and sanitized to prevent directory traversal.
Optional
GIT_BASE_DIRrestricts operations to a specific directory tree for multi-tenant sandboxing.Git commands use validated arguments via process spawning — no shell interpolation.
JWT and OAuth support for authenticated deployments.
Optional rate limiting via the DI-managed
RateLimiterservice.All operations are logged with request context for auditing.
Configuration
All configuration is validated at startup in src/config/index.ts. Key environment variables:
Variable | Description | Default |
| Transport: |
|
| HTTP session mode: |
|
| Response format: |
|
| Detail level: |
|
| HTTP server port. |
|
| HTTP server hostname. |
|
| MCP request endpoint path. |
|
| Authentication mode: |
|
| Storage backend: |
|
| Enable OpenTelemetry. |
|
| Minimum log level: |
|
| GPG/SSH signing for commits, merges, rebases, cherry-picks, and tags. Falls back to unsigned on failure (see response |
|
| Git author name. Aliases: |
|
| Git author email. Aliases: |
|
| Absolute path to restrict all git operations to a specific directory tree. |
|
| Path to custom markdown file with workflow instructions. |
|
| Required for |
|
| Required for |
|
Running the server
Via package manager (no install)
npx @cyanheads/git-mcp-server@latestConfigure through environment variables or your MCP client config.
Local development
# Build and run
npm run rebuild
npm run start:stdio # or start:http
# Dev mode with hot reload
npm run dev:stdio # or dev:http
# Checks and tests
npm run devcheck # lint, format, typecheck
npm testCloudflare Workers
npm run build:worker # Build the worker bundle
npm run deploy:dev # Run locally with Wrangler
npm run deploy:prod # Deploy to CloudflareProject structure
Directory | Purpose |
| Tool definitions ( |
| Resource definitions ( |
| HTTP and STDIO transport implementations, including auth. |
|
|
| Git service provider (CLI-based git operations). |
| DI container registrations and tokens. |
| Logging, error handling, performance, security utilities. |
| Environment variable parsing and validation (Zod). |
| Unit and integration tests, mirroring |
Response format
Configure output format and verbosity via MCP_RESPONSE_FORMAT and MCP_RESPONSE_VERBOSITY.
JSON format (default, optimized for LLM consumption):
{
"success": true,
"branch": "main",
"staged": ["src/index.ts", "README.md"],
"unstaged": ["package.json"],
"untracked": []
}Markdown format (human-readable):
# Git Status: main
## Staged (2)
- src/index.ts
- README.md
## Unstaged (1)
- package.jsonThe LLM always receives the complete structured data via responseFormatter — full file lists, metadata, timestamps — regardless of what the client displays. Verbosity controls how much detail is included: minimal (core fields only), standard (balanced), or full (everything).
Development guide
See AGENTS.md for architecture, tool development patterns, and contribution rules.
Testing
Tests use Bun's test runner with Vitest compatibility.
bun test # Run all tests
bun test --coverage # With coverage
bun run devcheck # Lint, format, typecheck, auditRoadmap
The server uses a provider-based architecture for git operations:
CLI provider (current) — Full 28-tool coverage via native git CLI. Requires local git installation.
Isomorphic git provider (planned) — Pure JS implementation for edge deployment (Cloudflare Workers, Vercel Edge, Deno Deploy). Uses isomorphic-git.
GitHub API provider (maybe) — Cloud-native operations via GitHub REST/GraphQL APIs, no local repo required.
Contributing
Issues and pull requests are welcome. Run checks before submitting:
npm run devcheck
npm testLicense
Apache 2.0. See 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,139MIT
- 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