Skip to main content
Glama

Git MCP

by kjozsa

Git MCP

MCP 服务器用于管理本地存储库上的 Git 操作。

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Git MCP:

npx -y @smithery/cli install @kjozsa/git-mcp --client claude

手动安装

uvx install git-mcp

配置

使用以下 JSON 配置片段添加 MCP 服务器:

{ "mcpServers": { "git-mcp": { "command": "uvx", "args": ["git-mcp"], "env": { "GIT_REPOS_PATH": "/path/to/your/git/repositories" } } } }

特点和用途

环境变量

  • GIT_REPOS_PATH :包含 Git 存储库的目录的路径(必需)

您可以在您的环境中设置此项,或者在运行服务器的目录中创建一个.env文件。

可用方法

列出存储库

列出配置路径中的所有 Git 存储库。

  • 参数:无
  • 返回:存储库名称列表
获取最后一个 git 标签

查找指定存储库中的最后一个 Git 标签。

  • 参数: repo_name (Git 存储库的名称)
  • 返回:带有version (标签名称)和date (标签创建日期)的字典
list_commits_since_last_tag

列出最后一个 Git 标签和 HEAD 之间的提交消息。

  • 参数:
    • repo_name :Git 存储库的名称
    • max_count (可选):返回的最大提交数
  • 返回:包含hashauthordatemessage字典列表
创建 git 标签

在指定的存储库中创建一个新的 git 标签。

  • 参数:
    • repo_name :git 存储库的名称
    • tag_name :要创建的标签的名称
    • message (可选):注释标签的消息(如果未提供,则创建轻量级标签)
  • 返回:包含statusversion (标签名称)、 date (标签创建日期)和type (带注释或轻量级)的字典
推送_git_标签

将现有的 git 标签推送到默认远程存储库。

  • 参数:
    • repo_name :git 存储库的名称
    • tag_name :要推送的标签名称
  • 返回:包含statusremote (远程名称)、 tag (标签名称)和message (成功消息)的字典
刷新存储库

通过检出主分支(或主分支作为后备)并从所有远程拉取来刷新存储库。

  • 参数:
    • repo_name :git 存储库的名称
  • 返回:包含statusrepositorybranchpull_results (每个远程的结果)的字典

故障排除

  • 未找到存储库:确保GIT_REPOS_PATH设置正确且存储库存在
  • 未找到标签:存储库尚无任何标签

发展

# Install dependencies uv pip install -r requirements.txt # Run in dev mode with Inspector mcp dev git_mcp/server.py

测试

该项目包括两个测试脚本:

  1. test_git_mcp.py - 直接测试底层 Git 命令功能,无需使用 MCP 服务器。
  2. test_mcp_server.py - 通过启动服务器实例并对其进行调用来测试 MCP 服务器功能。

运行测试:

# Test the Git command functionality python test_git_mcp.py # Test the MCP server (requires the git-mcp package to be installed) python test_mcp_server.py

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

MCP 服务器用于管理本地存储库上的 Git 操作,允许用户通过标准化界面列出存储库、获取和创建标签、列出提交、推送标签以及刷新存储库。

  1. 安装
    1. 通过 Smithery 安装
    2. 手动安装
  2. 配置
    1. 特点和用途
      1. 环境变量
      2. 可用方法
      3. 故障排除
    2. 发展
      1. 测试

        Related MCP Servers

        • A
          security
          F
          license
          A
          quality
          MCP Server for the GitHub API, providing features for file operations, repository management, and advanced search, with automatic branch creation and comprehensive error handling.
          Last updated -
          18
          4
          3
          TypeScript
          • Linux
          • Apple
        • A
          security
          A
          license
          A
          quality
          MCP Tool Server for Gitee, supporting the management of repository files/branches, Issues, and Pull Requests.
          Last updated -
          20
          10
          4
          TypeScript
          MIT License
        • A
          security
          F
          license
          A
          quality
          An MCP server that enables integration with GitHub Enterprise API, allowing users to access repository information, manage issues, pull requests, workflows, and other GitHub features through Cursor.
          Last updated -
          16
          33
          14
          TypeScript
          • Linux
          • Apple
        • -
          security
          A
          license
          -
          quality
          An MCP server that provides semantic search over local git repositories, enabling users to clone repositories, process branches, and search code through vectorized code chunks.
          Last updated -
          TypeScript
          MIT License
          • Apple

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/kjozsa/git-mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server