Skip to content

Git Status: main

mcp-server-git

A secure and scalable Git MCP server giving AI agents powerful version control for local and (soon) serverless environments. STDIO & Streamable HTTP

27 Tools • 1 Resource • 1 Prompt

Version MCP Spec MCP SDK License Status TypeScript Bun


This server provides 27 comprehensive Git operations organized into six functional categories:

CategoryToolsDescription
Repository Managementgit_init, git_clone, git_status, git_cleanInitialize repos, clone from remotes, check status, and clean untracked files
Staging & Commitsgit_add, git_commit, git_diffStage changes, create commits, and compare changes
History & Inspectiongit_log, git_show, git_blame, git_reflogView commit history, inspect objects, trace line-by-line authorship, and view ref logs
Branching & Merginggit_branch, git_checkout, git_merge, git_rebase, git_cherry_pickManage branches, switch contexts, integrate changes, and apply specific commits
Remote Operationsgit_remote, git_fetch, git_pull, git_pushConfigure remotes, download updates, synchronize repositories, and publish changes
Advanced Workflowsgit_tag, git_stash, git_reset, git_worktree, git_set_working_dir, git_clear_working_dir, git_wrapup_instructionsTag releases, stash changes, reset state, manage worktrees, set/clear session directory, and access workflow guidance

The server provides resources that offer contextual information about the Git environment:

ResourceURIDescription
Git Working Directorygit://working-directoryProvides the current session working directory for git operations. This is the directory set via git_set_working_dir and used as the default.

The server provides structured prompt templates that guide AI agents through complex workflows:

PromptDescriptionParameters
Git Wrap-upA systematic workflow protocol for completing git sessions. Guides agents through reviewing, documenting, committing, and tagging changes.changelogPath, skipDocumentation, createTag, and updateAgentFiles.

This server works with both Bun and Node.js runtimes:

RuntimeCommandMinimum VersionNotes
Bunbunx git-mcp-server@latest≥ 1.2.0Native Bun runtime (optimal performance)
Node.jsnpx git-mcp-server@latest≥ 20.0.0Via npx/bunx (universal compatibility)

The server automatically detects the runtime and uses the appropriate process spawning method for git operations.

Add the following to your MCP Client configuration file (e.g., cline_mcp_settings.json). Clients have different ways to configure servers, so refer to your client’s documentation for specifics.

Be sure to update environment variables as needed (especially your Git information!)

{
"mcpServers": {
"git-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["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": "your-username",
"GIT_EMAIL": "your-email@example.com",
"GIT_SIGN_COMMITS": "false"
}
}
}
}
{
"mcpServers": {
"git-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["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": "your-username",
"GIT_EMAIL": "your-email@example.com",
"GIT_SIGN_COMMITS": "false"
}
}
}
}
Terminal window
MCP_TRANSPORT_TYPE=http
MCP_HTTP_PORT=3015

This server provides a comprehensive feature set:

  • Declarative Tools: Define agent capabilities in single, self-contained files. The framework handles registration, validation, and execution.
  • Robust Error Handling: A unified McpError system ensures consistent, structured error responses.
  • Pluggable Authentication: Secure your server with zero-fuss support for none, jwt, or oauth modes.
  • Abstracted Storage: Swap storage backends (in-memory, filesystem, Supabase, Cloudflare KV/R2) without changing business logic.
  • Full-Stack Observability: Deep insights with structured logging (Pino) and optional, auto-instrumented OpenTelemetry for traces and metrics.
  • Dependency Injection: Built with tsyringe for a clean, decoupled, and testable architecture.
  • Edge-Ready Architecture: Built on an edge-compatible framework that runs seamlessly on local machines or Cloudflare Workers. Note: Current git operations use the CLI provider which requires local git installation. Edge deployment support is planned through the isomorphic-git provider integration.

Plus, specialized features for Git integration:

  • Cross-Runtime Compatibility: Works seamlessly with both Bun and Node.js runtimes. Automatically detects the runtime and uses optimal process spawning (Bun.spawn in Bun, child_process.spawn in Node.js).
  • Provider-Based Architecture: Pluggable git provider system with current CLI implementation and planned isomorphic-git provider for edge deployment.
  • Optimized Git Execution: Direct git CLI interaction with cross-runtime support for high-performance process management, streaming I/O, and timeout handling (current CLI provider).
  • Comprehensive Coverage: 27 tools covering all essential Git operations from init to push.
  • Working Directory Management: Session-specific directory context for multi-repo workflows.
  • Configurable Git Identity: Override author/committer information via environment variables with automatic fallback to global git config.
  • Safety Features: Explicit confirmations for destructive operations like git clean and git reset --hard.
  • Commit Signing: Optional GPG/SSH signing support for all commit-creating operations (commits, merges, rebases, cherry-picks, and tags).

Note: Development uses Bun for the best experience, but the published package works with both Bun (bunx) and Node.js (npx).

  1. Clone the repository:
Terminal window
git clone https://github.com/dadavidtseng/mcp-server-git.git
  1. Navigate into the directory:
Terminal window
cd mcp-server-git
  1. Install dependencies:

With Bun (recommended for development):

Terminal window
bun install

With Node.js:

Terminal window
npm install

All configuration is centralized and validated at startup in src/config/index.ts. Key environment variables in your .env file include:

VariableDescriptionDefault
MCP_TRANSPORT_TYPEThe transport to use: stdio or http.stdio
MCP_SESSION_MODESession mode for HTTP transport: stateless, stateful, or auto.auto
MCP_RESPONSE_FORMATResponse format: json (LLM-optimized), markdown (human-readable), or auto.json
MCP_RESPONSE_VERBOSITYResponse detail level: minimal, standard, or full.standard
MCP_HTTP_PORTThe port for the HTTP server.3015
MCP_HTTP_HOSTThe hostname for the HTTP server.127.0.0.1
MCP_HTTP_ENDPOINT_PATHThe endpoint path for MCP requests./mcp
MCP_AUTH_MODEAuthentication mode: none, jwt, or oauth.none
STORAGE_PROVIDER_TYPEStorage backend: in-memory, filesystem, supabase, cloudflare-kv, r2.in-memory
OTEL_ENABLEDSet to true to enable OpenTelemetry.false
MCP_LOG_LEVELThe minimum level for logging (debug, info, warn, error).info
GIT_SIGN_COMMITSSet to "true" to enable GPG/SSH signing for all commits, merges, rebases, cherry-picks, and tags. Requires GPG/SSH configuration.false
GIT_AUTHOR_NAMEGit author name. Aliases: GIT_USERNAME, GIT_USER. Falls back to global git config if not set.(none)
GIT_AUTHOR_EMAILGit author email. Aliases: GIT_EMAIL, GIT_USER_EMAIL. Falls back to global git config if not set.(none)
GIT_BASE_DIROptional absolute path to restrict all git operations to a specific directory tree. Provides security sandboxing for multi-tenant or shared environments.(none)
GIT_WRAPUP_INSTRUCTIONS_PATHOptional path to custom markdown file with Git workflow instructions.(none)
MCP_AUTH_SECRET_KEYRequired for jwt auth. A 32+ character secret key.(none)
OAUTH_ISSUER_URLRequired for oauth auth. URL of the OIDC provider.(none)

The easiest way to use the server is via bunx or npx (no installation required):

With Bun:

Terminal window
bunx git-mcp-server@latest

With Node.js:

Terminal window
npx git-mcp-server@latest

Both commands work identically and are configured through environment variables or your MCP client configuration.

  • Build and run the production version:

    Terminal window
    # One-time build
    bun rebuild
    # Run the built server
    bun start:http
    # or
    bun start:stdio
  • Development mode with hot reload:

    Terminal window
    bun dev:http
    # or
    bun dev:stdio
  • Run checks and tests:

    Terminal window
    bun devcheck # Lints, formats, type-checks, and more
    bun test # Runs the test suite
  1. Build the Worker bundle:
Terminal window
bun build:worker
  1. Run locally with Wrangler:
Terminal window
bun deploy:dev
  1. Deploy to Cloudflare:
Terminal window
bun deploy:prod
DirectoryPurpose & Contents
src/mcp-server/toolsYour tool definitions (*.tool.ts). This is where Git capabilities are defined.
src/mcp-server/resourcesYour resource definitions (*.resource.ts). Provides Git context data sources.
src/mcp-server/transportsImplementations for HTTP and STDIO transports, including auth middleware.
src/storageStorageService abstraction and all storage provider implementations.
src/servicesIntegrations with external services (LLMs, Speech, etc.).
src/containerDependency injection container registrations and tokens.
src/utilsCore utilities for logging, error handling, performance, and security.
src/configEnvironment variable parsing and validation with Zod.
tests/Unit and integration tests, mirroring the src/ directory structure.

This server follows MCP’s dual-output architecture for all tools (MCP Tools Specification):

Configure response format and verbosity via environment variables (see Configuration):

VariableValuesDescription
MCP_RESPONSE_FORMATjson (default), markdown, autoOutput format: JSON for LLM parsing, Markdown for human UIs
MCP_RESPONSE_VERBOSITYminimal, standard (default), fullDetail level: minimal (core only), standard (balanced), full (everything)

When you invoke a tool through your MCP client, you see a formatted summary designed for human consumption. For example, git_status might show:

Markdown Format:

# Git Status: main
## Staged (2)
- src/index.ts
- README.md
## Unstaged (1)
- package.json

JSON Format (LLM-Optimized):

{
"success": true,
"branch": "main",
"staged": ["src/index.ts", "README.md"],
"unstaged": ["package.json"],
"untracked": []
}

What the LLM Sees (Complete Structured Data)

Section titled “What the LLM Sees (Complete Structured Data)”

Behind the scenes, the LLM receives complete structured data as content blocks via the responseFormatter function. This includes:

  • All metadata (commit hashes, timestamps, authors)
  • Full file lists and change details (never truncated - LLMs need complete context)
  • Structured JSON or formatted markdown based on configuration
  • Everything needed to answer follow-up questions

Why This Matters: The LLM can answer detailed questions like “Who made the last commit?” or “What files changed in commit abc123?” because it has access to the full dataset, even if you only saw a summary.

Verbosity Levels: Control the amount of detail returned:

  • Minimal: Core data only (success status, primary identifiers)
  • Standard: Balanced output with essential context (recommended)
  • Full: Complete data including all metadata and statistics

For Developers: When creating custom tools, always include complete data in your responseFormatter. Balance human-readable summaries with comprehensive structured information. See AGENTS.md for response formatter best practices and the MCP specification for technical details.

For strict rules when using this server with an AI agent, refer to the AGENTS.md file in this repository. Key principles include:

  • Logic Throws, Handlers Catch: Never use try/catch in your tool logic. Throw an McpError instead.
  • Pass the Context: Always pass the RequestContext object through your call stack for logging and tracing.
  • Use the Barrel Exports: Register new tools and resources only in the index.ts barrel files within their respective definitions directories.
  • Declarative Tool Pattern: Each tool is defined in a single *.tool.ts file with schema, logic, and response formatting.
  • Path Sanitization: All file paths are validated and sanitized to prevent directory traversal attacks.
  • Base Directory Restriction: Optional GIT_BASE_DIR configuration to restrict all git operations to a specific directory tree, providing security sandboxing for multi-tenant or shared hosting environments.
  • Command Injection Prevention: Git commands are executed with carefully validated arguments via Bun.spawn.
  • Destructive Operation Protection: Dangerous operations require explicit confirmation flags.
  • Authentication Support: Built-in JWT and OAuth support for secure deployments.
  • Rate Limiting: Optional rate limiting via the DI-managed RateLimiter service.
  • Audit Logging: All Git operations are logged with full context for security auditing.

This server uses Vitest for testing.

  • Run all tests:

    Terminal window
    bun test
  • Run tests with coverage:

    Terminal window
    bun test:coverage
  • Run tests in watch mode:

    Terminal window
    bun test --watch

The server uses a provider-based architecture to support multiple git implementation backends:

  • ✅ CLI Provider (Current): Full-featured git operations via native git CLI

    • Complete coverage of all 27 git tools
    • Executes git commands using Bun.spawn for optimal performance
    • Streaming I/O handling for large outputs (10MB buffer limit)
    • Configurable timeouts (60s default) and automatic process cleanup
    • Requires local git installation
    • Best for local development and server deployments
  • 🚧 Isomorphic Git Provider (Planned): Pure JavaScript git implementation

    • Edge deployment compatibility (Cloudflare Workers, Vercel Edge, Deno Deploy)
    • No system dependencies required
    • Enables true serverless git operations
    • Core operations: clone, status, add, commit, push, pull, branch, checkout
    • Implementation: isomorphic-git
  • 💡 GitHub API Provider (Maybe): Cloud-native git operations via GitHub REST/GraphQL APIs

    • No local repository required
    • Direct integration with GitHub-hosted repositories
    • Ideal for GitHub-centric workflows

The provider system allows seamless switching between implementations based on deployment environment and requirements. See AGENTS.md for architectural details.

Issues and pull requests are welcome! If you plan to contribute, please run the local checks and tests before submitting your PR.

Terminal window
bun run devcheck
bun test
  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following the existing patterns
  4. Run bun devcheck to ensure code quality
  5. Run bun test to verify all tests pass
  6. Commit your changes with conventional commits
  7. Push to your fork and open a Pull Request

Yu-Wei Tseng

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.


A Git MCP server for AI agent integration

Terminal window
cd mcp-server-git
npm install
kadi install
kadi run start
FieldValue
Version0.1.0
TypeN/A
Terminal window
npm install
npm run build
kadi run start