io.github.cyanheads/git-mcp-server

平台与服务

by cyanheads

功能完善的 Git MCP server,提供原生 Git 工具能力,包括 clone、commit、worktree 等操作。

把 Git 操作直接接入 MCP 工作流,原生支持 clone、commit、worktree 等完整能力,让 AI Agent 更高效地管理代码仓库。

什么是 io.github.cyanheads/git-mcp-server

功能完善的 Git MCP server,提供原生 Git 工具能力,包括 clone、commit、worktree 等操作。

README

<div align="center"> <h1>@cyanheads/git-mcp-server</h1> <p><b>A Git MCP server for AI agents. STDIO & Streamable HTTP.</b> <div>28 Tools · 1 Resource · 1 Prompt</div> </p> </div> <div align="center">

Version MCP Spec MCP SDK License Status TypeScript Bun

</div>

Tools

28 git operations organized into seven categories:

CategoryToolsDescription
Repository Managementgit_init, git_clone, git_status, git_cleanInitialize repos, clone from remotes, check status, clean untracked files
Staging & Commitsgit_add, git_commit, git_diffStage changes, create commits, compare changes
History & Inspectiongit_log, git_show, git_blame, git_reflogView commit history, inspect objects, trace authorship, view ref logs
Analysisgit_changelog_analyzeGather git context and instructions for LLM-driven changelog analysis
Branching & Merginggit_branch, git_checkout, git_merge, git_rebase, git_cherry_pickManage branches, switch contexts, integrate changes, apply specific commits
Remote Operationsgit_remote, git_fetch, git_pull, git_pushConfigure remotes, fetch updates, synchronize repositories, 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

Resources

ResourceURIDescription
Git Working Directorygit://working-directoryThe current session working directory, set via git_set_working_dir.

Prompts

PromptDescriptionParameters
Git Wrap-upWorkflow protocol for completing git sessions: review, document, commit, and tag changes.changelogPath, skipDocumentation, createTag, updateAgentFiles.

Getting started

Runtime

Works with both Bun and Node.js. Runtime is auto-detected.

RuntimeCommandMinimum Version
Node.jsnpx @cyanheads/git-mcp-server@latest>= 20.0.0
Bunbunx @cyanheads/git-mcp-server@latest>= 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.

json
{
  "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.

FeatureDetails
Declarative toolsDefine capabilities in single, self-contained files. The framework handles registration, validation, and execution.
Error handlingUnified McpError system for consistent, structured error responses.
AuthenticationSupports none, jwt, and oauth modes.
Pluggable storageSwap backends (in-memory, filesystem, Supabase, Cloudflare KV/R2) without changing business logic.
ObservabilityStructured logging (Pino) and optional auto-instrumented OpenTelemetry for traces and metrics.
Dependency injectionBuilt with tsyringe for decoupled, testable architecture.
Cross-runtimeAuto-detects Bun or Node.js and uses the appropriate process spawning method.
Provider architecturePluggable git provider system. Current: CLI. Planned: isomorphic-git for edge deployment.
Working directory managementSession-specific directory context for multi-repo workflows.
Configurable git identityOverride author/committer info via environment variables, with fallback to global git config.
Commit signingOptional GPG/SSH signing for commits, merges, rebases, cherry-picks, and tags.
SafetyDestructive operations (git clean, git reset --hard) require explicit confirmation flags.

Security

  • All file paths are validated and sanitized to prevent directory traversal.
  • Optional GIT_BASE_DIR restricts 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 RateLimiter service.
  • All operations are logged with request context for auditing.

Configuration

All configuration is validated at startup in src/config/index.ts. Key environment variables:

VariableDescriptionDefault
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_SESSION_MODEHTTP session mode: stateless, stateful, or auto.auto
MCP_RESPONSE_FORMATResponse format: json (LLM-optimized), markdown (human-readable), or auto.json
MCP_RESPONSE_VERBOSITYDetail level: minimal, standard, or full.standard
MCP_HTTP_PORTHTTP server port.3015
MCP_HTTP_HOSTHTTP server hostname.127.0.0.1
MCP_HTTP_ENDPOINT_PATHMCP request endpoint path./mcp
MCP_AUTH_MODEAuthentication mode: none, jwt, or oauth.none
STORAGE_PROVIDER_TYPEStorage backend: in-memory, filesystem, supabase, cloudflare-kv, r2.in-memory
OTEL_ENABLEDEnable OpenTelemetry.false
MCP_LOG_LEVELMinimum log level: debug, info, warn, error.info
GIT_SIGN_COMMITSEnable GPG/SSH signing for commits, merges, rebases, cherry-picks, and tags.false
GIT_AUTHOR_NAMEGit author name. Aliases: GIT_USERNAME, GIT_USER. Falls back to global git config.(none)
GIT_AUTHOR_EMAILGit author email. Aliases: GIT_EMAIL, GIT_USER_EMAIL. Falls back to global git config.(none)
GIT_BASE_DIRAbsolute path to restrict all git operations to a specific directory tree.(none)
GIT_WRAPUP_INSTRUCTIONS_PATHPath to custom markdown file with workflow instructions.(none)
MCP_AUTH_SECRET_KEYRequired for jwt auth. 32+ character secret key.(none)
OAUTH_ISSUER_URLRequired for oauth auth. OIDC provider URL.(none)

Running the server

Via package manager (no install)

sh
npx @cyanheads/git-mcp-server@latest

Configure through environment variables or your MCP client config.

Local development

sh
# 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 test

Cloudflare Workers

sh
npm run build:worker   # Build the worker bundle
npm run deploy:dev     # Run locally with Wrangler
npm run deploy:prod    # Deploy to Cloudflare

Project structure

DirectoryPurpose
src/mcp-server/toolsTool definitions (*.tool.ts). Git capabilities live here.
src/mcp-server/resourcesResource definitions (*.resource.ts). Git context data sources.
src/mcp-server/transportsHTTP and STDIO transport implementations, including auth.
src/storageStorageService abstraction and provider implementations.
src/servicesGit service provider (CLI-based git operations).
src/containerDI container registrations and tokens.
src/utilsLogging, error handling, performance, security utilities.
src/configEnvironment variable parsing and validation (Zod).
tests/Unit and integration tests, mirroring src/ structure.

Response format

Configure output format and verbosity via MCP_RESPONSE_FORMAT and MCP_RESPONSE_VERBOSITY.

JSON format (default, optimized for LLM consumption):

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

Markdown format (human-readable):

code
# Git Status: main

## Staged (2)
- src/index.ts
- README.md

## Unstaged (1)
- package.json

The 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.

sh
bun test              # Run all tests
bun test --coverage   # With coverage
bun run devcheck      # Lint, format, typecheck, audit

Roadmap

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:

sh
npm run devcheck
npm test

License

Apache 2.0. See LICENSE.


<div align="center"> <p>Built with the <a href="https://github.com/cyanheads/mcp-ts-template">mcp-ts-template</a></p> <p> <a href="https://github.com/sponsors/cyanheads">Sponsor this project</a> · <a href="https://www.buymeacoffee.com/cyanheads">Buy me a coffee</a> </p> </div>

常见问题

io.github.cyanheads/git-mcp-server 是什么?

功能完善的 Git MCP server,提供原生 Git 工具能力,包括 clone、commit、worktree 等操作。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描109.6k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描109.6k

接口设计评审

by alirezarezvani

Universal
热门

审查 REST API 设计是否符合行业规范,自动检查命名、HTTP 方法、状态码与文档覆盖,识别破坏性变更并给出设计评分,适合评审接口方案和版本迭代前把关。

做API和架构方案时,它能帮你提前揪出接口设计问题并对齐最佳实践,评审视角系统,团队协作更省心。

平台与服务
未扫描9.0k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
82.9k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.3k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
34.5k

评论