Skip to main content
Glama

Git Repo Browser MCP

MCP Git Repo 浏览器 (Node.js)

使用模型上下文协议 (MCP) 的 Git 存储库浏览器的 Node.js 实现。

安装

NPM(推荐)

npm install -g git-commands-mcp

手动安装

git clone https://github.com/bsreeram08/git-commands-mcp.git cd git-commands-mcp npm install

配置

将其添加到您的 MCP 设置配置文件中:

{ "mcpServers": { "git-commands-mcp": { "command": "git-commands-mcp" } } }

对于手动安装,请使用:

{ "mcpServers": { "git-commands-mcp": { "command": "node", "args": ["/path/to/git-commands-mcp/src/index.js"] } } }

特征

该服务器提供以下工具:

基本存储库操作

  1. git_directory_structure :返回存储库目录结构的树状表示
    • 输入:存储库 URL
    • 输出:存储库结构的 ASCII 树表示
  2. git_read_files :读取并返回存储库中指定文件的内容
    • 输入:存储库 URL 和文件路径列表
    • 输出:将文件路径映射到其内容的字典
  3. git_search_code :在存储库代码中搜索模式
    • 输入:存储库 URL、搜索模式、可选文件模式、区分大小写和上下文行
    • 输出:包含匹配行和上下文的搜索结果的 JSON

分支机构运营

  1. git_branch_diff :比较两个分支并显示它们之间更改的文件
    • 输入:存储库 URL、源分支、目标分支和可选的 show_patch 标志
    • 输出:包含提交计数和差异摘要的 JSON

提交操作

  1. git_commit_history :获取带有可选过滤的分支的提交历史记录
    • 输入:存储库 URL、分支名称、最大数量、作者过滤器、起始日期、终止日期和消息 grep
    • 输出:包含提交详细信息的 JSON
  2. git_commits_details :获取有关提交的详细信息,包括完整消息和差异
    • 输入:存储库 URL、分支名称、最大计数、include_diff 标志、作者过滤器、起始日期、终止日期和消息 grep
    • 输出:包含详细提交信息的 JSON
  3. git_local_changes :获取工作目录中未提交的更改
    • 输入:本地存储库路径
    • 输出:包含状态信息和差异的 JSON

项目结构

git-commands-mcp/ ├── src/ │ ├── index.js # Entry point │ ├── server.js # Main server implementation │ ├── handlers/ # Tool handlers │ │ └── index.js # Tool implementation functions │ └── utils/ # Utility functions │ └── git.js # Git-related helper functions ├── package.json └── readme.md

实现细节

  • 使用 Node.js 原生模块(crypto、path、os)实现核心功能
  • 利用 fs-extra 增强文件操作
  • 使用 simple-git 进行 Git 存储库操作
  • 实现干净的错误处理和资源清理
  • 根据存储库 URL 哈希创建确定性临时目录
  • 尽可能重复使用克隆的存储库以提高效率
  • 模块化代码结构,可维护性更好

要求

  • Node.js 14.x 或更高版本
  • 系统上安装的 Git

用法

如果通过 npm 全局安装:

git-commands-mcp

如果手动安装:

node src/index.js

服务器在 stdio 上运行,使其与 MCP 客户端兼容。

持续集成/持续交付

该项目使用 GitHub Actions 进行持续集成和部署:

自动 NPM 发布

该存储库配置了 GitHub Actions 工作流,当更改推送到主分支时,会自动将包发布到 npm。

设置 NPM_AUTOMATION_TOKEN

要启用自动发布,您需要添加一个 npm Automation 令牌作为 GitHub 机密(即使启用了 2FA 的帐户也可以使用):

  1. 生成 npm Automation 令牌:
    • npmjs.com上登录你的 npm 帐户
    • 转到您的个人资料设置
    • 选择“访问令牌”
    • 点击“生成新令牌”
    • 选择“自动化”令牌类型
    • 设置适当的权限(需要对包进行“读写”)
    • 复制生成的token
  2. 将令牌添加到您的 GitHub 存储库:
    • 前往你的 GitHub 仓库
    • 导航至“设置”>“机密和变量”>“操作”
    • 点击“新建存储库秘密”
    • 名称: NPM_AUTOMATION_TOKEN
    • 值:粘贴您的 npm Automation 令牌
    • 点击“添加秘密”

配置完成后,任何对主分支的推送都会触发工作流将包发布到 npm。

执照

MIT 许可证 - 有关详细信息,请参阅LICENSE文件。

链接

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Node.js 实现可以通过模型上下文协议浏览 Git 存储库,提供显示目录结构、读取文件、搜索代码、比较分支和查看提交历史记录等功能。

  1. 安装
    1. NPM(推荐)
    2. 手动安装
  2. 配置
    1. 特征
      1. 基本存储库操作
      2. 分支机构运营
      3. 提交操作
    2. 项目结构
      1. 实现细节
        1. 要求
          1. 用法
            1. 持续集成/持续交付
              1. 自动 NPM 发布
            2. 执照
              1. 链接

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  A Model Context Protocol server for Git repository interaction and automation. This server provides tools to read, search, and manipulate Git repositories via Large Language Models.
                  Last updated -
                  12
                  50,383
                  Python
                  MIT License
                • -
                  security
                  F
                  license
                  -
                  quality
                  Enables interaction with GitHub through the GitHub API, supporting file operations, repository management, advanced search, and issue tracking with comprehensive error handling and automatic branch creation.
                  Last updated -
                  9
                  1
                  TypeScript
                • A
                  security
                  A
                  license
                  A
                  quality
                  A Node.js server that allows browsing Git repositories through MCP, providing tools to view directory structures and read important files from repositories.
                  Last updated -
                  2
                  JavaScript
                  MIT License
                  • Linux
                  • Apple
                • A
                  security
                  A
                  license
                  A
                  quality
                  A Model Context Protocol server that enables Large Language Models to interact with Git repositories through a robust API, supporting operations like repository initialization, cloning, file staging, committing, and branch management.
                  Last updated -
                  21
                  482
                  65
                  TypeScript
                  Apache 2.0

                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/bsreeram08/git-commands-mcp'

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