详细介绍
MCP Git 仓库导入工具是一个基于模型上下文协议(MCP)的服务器,旨在帮助开发者读取 GitHub 仓库的结构和重要文件。该工具受 gitingest 启发,提供两个主要功能:获取仓库的目录结构和读取指定的重要文件内容。
核心功能
- github_directory_structure:返回仓库的目录结构树状表示。
- github_read_important_files:读取并返回指定文件的内容。
- 支持并行处理多个仓库,提高处理效率。
- 提供详细日志记录,增强调试能力。
安装方法
安装该工具需要 Python 3.8+ 环境,并依赖 gitpython 和 fastmcp。
# 安装依赖
pip install gitpython fastmcp
# 克隆仓库并运行
git clone https://github.com/adhikarp/mcp-git-ingest.git
cd mcp-git-ingest
python3 src/main.py配置信息
{
"mcpServers": {
"mcp-git-ingest": {
"command": "uvx",
"args": ["--from", "git+https://github.com/adhikasp/mcp-git-ingest", "mcp-git-ingest"]
}
}
}使用方法
你可以使用 mcp-client-cli 来调用本工具。以下是使用示例:
$ llm read https://github.com/adhikasp/mcp-git-ingest 并确定代码如何工作
我将帮助你了解mcp-git-ingest仓库的技术细节。首先获取目录结构,然后读取重要文件以分析代码实现。
工具调用:
github_directory_structure
参数:
repo_url: https://github.com/adhikasp/mcp-git-ingest
现在,我将读取重要文件以理解技术实现:
工具调用:
github_read_important_files
参数:
repo_url: https://github.com/adhikarp/mcp-git-ingest
file_paths: ["README.md", "pyproject.toml"]技术实现
- 使用
fastmcp创建 MCP 服务器。 - 使用
gitpython进行 Git 仓库操作。 - 关键函数包括
clone_repo、get_directory_tree、github_directory_structure和github_read_important_files。 - 支持错误处理和性能优化,如轻量级提交和垃圾回收。
MCP
Git
GitHub
仓库管理
Python