git-mcp-server

作者 cyanheads

A Git MCP server for AI agents. STDIO & Streamable HTTP.

235
Stars
57
Forks
TypeScript
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/cyanheads/git-mcp-server

快速入门

使用 git-mcp-server 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

@cyanheads/git-mcp-server

A Git MCP server for AI agents. STDIO & Streamable HTTP.

28 Tools · 1 Resource · 1 Prompt

Version MCP Spec MCP SDK License Status TypeScript Bun


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 (list/create/delete/verify), 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, createTag.

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.

{
  "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 signingGPG/SSH signing (enabled by default) for commits, merges, rebases, cherry-picks, and tags. Silent fallback to unsigned on failure with signed/signingWarning fields in responses.
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_COMMITSGPG/SSH signing for commits, merges, rebases, cherry-picks, and tags. Falls back to unsigned on failure (see response signed/signingWarning).true
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)

npx @cyanheads/git-mcp-server@latest

Configure 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 test

Cloudflare Workers

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):

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

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:

npm run devcheck
npm test

License

Apache 2.0. See LICENSE.


常见问题

What is git-mcp-server?

git-mcp-server is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by cyanheads. A Git MCP server for AI agents. STDIO & Streamable HTTP. It has 235 GitHub stars.

Is git-mcp-server safe to use?

git-mcp-server returned warnings in SkillsLLM's automated security scan. It has no critical vulnerabilities, but review the flagged issues in the Security Report section before adding it to your workflow.

How do I install git-mcp-server?

Clone the repository with "git clone https://github.com/cyanheads/git-mcp-server" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is git-mcp-server written in?

git-mcp-server is primarily written in TypeScript. It is open-source under cyanheads on GitHub, so you can review or fork the full source.

Are there alternatives to git-mcp-server?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh git-mcp-server against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情