内容
# MCP Git Repo Browser (Node.js)
一个使用模型上下文协议(MCP)的 Git 仓库浏览器的 Node.js 实现。
<a href="https://glama.ai/mcp/servers/zmmq29sb91">
<img width="380" height="200" src="https://glama.ai/mcp/servers/zmmq29sb91/badge" alt="Git Repo Browser MCP server" />
</a>
## Configuration
将其添加到您的 MCP 设置配置文件中:
```json
{
"mcpServers": {
"mcp-git-repo-browser": {
"command": "node",
"args": ["/path/to/mcp-git-repo-browser/src/index.js"]
}
}
}
```
## Features
该服务器提供两个主要工具:
1. `git_directory_structure`: 返回仓库目录结构的树状表示
- Input: 仓库 URL
- Output: 仓库结构的 ASCII 树表示
2. `git_read_important_files`: 读取并返回仓库中指定文件的内容
- Input: 仓库 URL 和文件路径列表
- Output: 将文件路径映射到其内容的字典
## Implementation Details
- 使用 Node.js 原生模块(crypto, path, os)实现核心功能
- 利用 fs-extra 增强文件操作
- 使用 simple-git 进行 Git 仓库操作
- 实现了清晰的错误处理和资源清理
- 基于仓库 URL 哈希创建确定性的临时目录
- 尽可能重用克隆的仓库以提高效率
## Requirements
- Node.js 14.x 或更高版本
- 系统上安装 Git
## Installation
```bash
git clone <repository-url>
cd mcp-git-repo-browser
npm install
```
## Usage
启动服务器:
```bash
node src/index.js
```
该服务器在 stdio 上运行,使其与 MCP 客户端兼容。
## License
MIT 许可证 - 有关详细信息,请参见 [LICENSE](LICENSE) 文件。