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 installRelated MCP server: MCP Git Repo Browser
配置
将其添加到您的 MCP 设置配置文件中:
{
"mcpServers": {
"git-commands-mcp": {
"command": "git-commands-mcp"
}
}
}对于手动安装,请使用:
{
"mcpServers": {
"git-commands-mcp": {
"command": "node",
"args": ["/path/to/git-commands-mcp/src/index.js"]
}
}
}特征
该服务器提供以下工具:
基本存储库操作
git_directory_structure:返回存储库目录结构的树状表示输入:存储库 URL
输出:存储库结构的 ASCII 树表示
git_read_files:读取并返回存储库中指定文件的内容输入:存储库 URL 和文件路径列表
输出:将文件路径映射到其内容的字典
git_search_code:在存储库代码中搜索模式输入:存储库 URL、搜索模式、可选文件模式、区分大小写和上下文行
输出:包含匹配行和上下文的搜索结果的 JSON
分支机构运营
git_branch_diff:比较两个分支并显示它们之间更改的文件输入:存储库 URL、源分支、目标分支和可选的 show_patch 标志
输出:包含提交计数和差异摘要的 JSON
提交操作
git_commit_history:获取带有可选过滤的分支的提交历史记录输入:存储库 URL、分支名称、最大数量、作者过滤器、起始日期、终止日期和消息 grep
输出:包含提交详细信息的 JSON
git_commits_details:获取有关提交的详细信息,包括完整消息和差异输入:存储库 URL、分支名称、最大计数、include_diff 标志、作者过滤器、起始日期、终止日期和消息 grep
输出:包含详细提交信息的 JSON
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 的帐户也可以使用):
生成 npm Automation 令牌:
在npmjs.com上登录你的 npm 帐户
转到您的个人资料设置
选择“访问令牌”
点击“生成新令牌”
选择“自动化”令牌类型
设置适当的权限(需要对包进行“读写”)
复制生成的token
将令牌添加到您的 GitHub 存储库:
前往你的 GitHub 仓库
导航至“设置”>“机密和变量”>“操作”
点击“新建存储库秘密”
名称:
NPM_AUTOMATION_TOKEN值:粘贴您的 npm Automation 令牌
点击“添加秘密”
配置完成后,任何对主分支的推送都会触发工作流将包发布到 npm。
执照
MIT 许可证 - 有关详细信息,请参阅LICENSE文件。
链接
Available Tools
27 toolsgit_archiveC
Create a git archive (zip or tar).
Inputs: repo_path (required), output_path (required), format, prefix, +1 more.
git_attributesC
Manage git attributes for files.
Inputs: repo_path (required), action (required), pattern, attribute.
git_blameC
Get blame information for a file.
Inputs: repo_path (required), file_path (required), rev.
git_branch_diffC
Compare two branches and show files changed between them.
Inputs: repo_url (required), source_branch (required), target_branch (required), show_patch.
git_checkout_branchC
Create and/or checkout a branch.
Inputs: repo_path (required), branch_name (required), start_point, create.
git_cleanC
Perform git clean operations.
Inputs: repo_path (required), directories, force, dry_run.
git_commitC
Create a commit with the specified message.
Inputs: repo_path (required), message (required).
git_commit_historyB
Get commit history for a branch with optional filtering.
Inputs: repo_url (required), branch, max_count, author, +3 more.
git_commits_detailsC
Get detailed information about commits including full messages and diffs.
Inputs: repo_url (required), branch, max_count, include_diff, +4 more.
git_configC
Configure git settings for the repository.
Inputs: repo_path (required), key (required), value (required), scope.
git_create_tagC
Create a tag.
Inputs: repo_path (required), tag_name (required), message, annotated.
git_delete_branchC
Delete a branch from the repository.
Inputs: repo_path (required), branch_name (required), force.
git_directory_structureC
Clone a Git repository and return its directory structure in a tree format.
Inputs: repo_url (required).
git_hooksC
Manage git hooks in the repository.
Inputs: repo_path (required), action (required), hook_name, script.
git_lfsC
Manage Git LFS (Large File Storage).
Inputs: repo_path (required), action (required), patterns.
git_lfs_fetchC
Fetch LFS objects from the remote repository.
Inputs: repo_path (required), dry_run, pointers.
git_local_changesC
Get uncommitted changes in the working directory.
Inputs: repo_path (required).
git_merge_branchC
Merge a source branch into the current or target branch.
Inputs: repo_path (required), source_branch (required), target_branch, no_fast_forward.
git_pullC
Pull changes from a remote repository.
Inputs: repo_path (required), remote, branch, rebase.
git_pushC
Push changes to a remote repository.
Inputs: repo_path (required), remote, branch, force.
git_read_filesC
Read the contents of specified files in a given git repository.
Inputs: repo_url (required), file_paths (required).
git_rebaseC
Rebase the current branch onto another branch or commit.
Inputs: repo_path (required), onto (required), interactive.
git_resetC
Reset repository to specified commit or state.
Inputs: repo_path (required), mode, to.
git_revertC
Revert the current branch to a commit or state.
Inputs: repo_path (required), commit, no_commit.
git_search_codeC
Search for patterns in repository code.
Inputs: repo_url (required), pattern (required), file_patterns, case_sensitive, +1 more.
git_stashC
Create or apply a stash.
Inputs: repo_path (required), action, message, index.
git_trackC
Track (stage) specific files or all files.
Inputs: repo_path (required), files.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 27 tools
Most tools have distinct purposes targeting specific Git operations, but some overlap exists. For example, git_commit_history and git_commits_details both handle commit information retrieval, and git_clean and git_reset both involve repository state management, which could cause minor confusion. However, descriptions clarify their specific focuses, keeping ambiguity manageable.
All tool names follow a consistent snake_case pattern with a 'git_' prefix and descriptive verb_noun combinations. Examples include git_checkout_branch, git_merge_branch, and git_search_code. This uniformity makes the tool set predictable and easy to navigate for an agent.
With 27 tools, the count is excessive for a Git repository browser. Many tools cover niche or low-level operations that could be consolidated, such as git_lfs and git_lfs_fetch, or git_attributes and git_hooks. This bloated set may overwhelm agents and complicate task selection.
The tool set provides comprehensive coverage of Git operations, including cloning, branching, committing, merging, searching, and configuration. It supports full CRUD and lifecycle management for repositories, with no obvious gaps. Agents can perform end-to-end workflows without dead ends.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
A MCP server built for developers enabling Git based project management with project and personal…
A Model Context Protocol (MCP) application for automated GitHub PR analysis and issue management.…
Related MCP Servers
- AlicenseBqualityBmaintenanceA 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.14115,976 PyPI92,301MIT
- AlicenseBqualityDmaintenanceA Node.js server that allows browsing Git repositories through MCP, providing tools to view directory structures and read important files from repositories.25MIT
- AlicenseAqualityDmaintenanceA 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.286,847 npm246Apache 2.0
- AlicenseCqualityCmaintenanceNode.js server implementing Model Context Protocol for git operations, enabling AI assistants to manage git repositories through natural language commands.11MIT