Git MCP Server

Developmentstdiov2026.1.26
代码仓库

Reference MCP server for Git repository operations. Provides tools to read, search, and manipulate Git repositories including viewing commit history, diffs, branches, file contents at specific revisions, and repository status. Enables AI agents to understand code changes and navigate version history without direct filesystem access.

连接

将此配置添加到 .claude/mcp.json

{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": [
        "mcp-server-git",
        "--repository",
        "."
      ]
    }
  }
}

工具 (4)

git_log

Show commit history for the repository with messages, authors, and dates.

{
  "type": "object",
  "required": [
    "repo_path"
  ],
  "properties": {
    "branch": {
      "type": "string",
      "description": "Branch name (default current branch)"
    },
    "max_count": {
      "type": "integer",
      "description": "Maximum number of commits to return (default 10)"
    },
    "repo_path": {
      "type": "string",
      "description": "Path to the Git repository"
    }
  }
}

git_diff

Show changes between commits, branches, or working directory.

{
  "type": "object",
  "required": [
    "repo_path"
  ],
  "properties": {
    "target": {
      "type": "string",
      "description": "Commit hash, branch name, or range (e.g. HEAD~3..HEAD)"
    },
    "repo_path": {
      "type": "string",
      "description": "Path to the Git repository"
    }
  }
}

git_status

Show the working tree status including staged, modified, and untracked files.

{
  "type": "object",
  "required": [
    "repo_path"
  ],
  "properties": {
    "repo_path": {
      "type": "string",
      "description": "Path to the Git repository"
    }
  }
}

git_show

Show the contents of a file at a specific commit or branch.

{
  "type": "object",
  "required": [
    "repo_path",
    "path"
  ],
  "properties": {
    "path": {
      "type": "string",
      "description": "File path within the repository"
    },
    "revision": {
      "type": "string",
      "description": "Commit hash or branch name"
    },
    "repo_path": {
      "type": "string",
      "description": "Path to the Git repository"
    }
  }
}

资源

此服务器未提供任何资源。

提示词

此服务器未提供任何提示词。

服务器信息

作者
Anthropic (@modelcontextprotocol)
代码仓库
https://github.com/modelcontextprotocol/servers
许可证
Apache-2.0
版本
2026.1.26
星标
86,206
最后更新
2026年1月27日