article
README
🚀 GitHub 仓库 MCP 服务器
GitHub Repo MCP 是一个开源的 MCP 服务器,它能让您的人工智能助手浏览 GitHub 仓库、探索目录以及查看文件内容,为您的开发工作带来便利。
🚀 快速开始
先决条件
在系统上安装服务器需要以下内容:
- Node.js 18+
- npm 或 yarn
第一步:安装
您可以使用 Smithery、NPX 或在 IDE 的 mcp.json 中设置来安装和运行 GitHub Repo MCP:
MacOS
npx github-repo-mcp
Windows NPX
cmd /c npx -y github-repo-mcp
Windows NPX 通过 mcp.json 设置
{
"mcp": {
"servers": [
{
"name": "GitHub Repo MCP",
"executable": "github-repo-mcp",
"args": []
}
]
}
}
第二步:配置
在 config.json 中添加以下内容:
{
"repositories": [
{
"url": "https://github.com/Ryan0204/github-repo-mcp",
"name": "GitHub Repo MCP"
}
]
}
✨ 主要特性
- 💻 兼容 Cursor、Windsurf、Claude Desktop 和其他支持
stdio协议的 MCP 客户端。 - 🔎 可检索任何公共 GitHub 仓库的内容。
- 📂 支持浏览仓库目录和子目录。
- 📝 能够查看代码和文本文件的内容。
- 📦 可通过包管理器轻松安装。
📚 详细文档
工具和命令
-
listRepositories()
- 功能:列出所有已配置的仓库。
listRepositories -
getRepositoryContents(String url)
- 功能:显示指定 URL 仓库的内容。
getRepositoryContents https://github.com/Ryan0204/github-repo-mcp -
getDirectoryContents(String url, String path)
- 功能:查看指定路径下的文件和子目录。
getDirectoryContents https://github.com/Ryan0204/github-repo-mcp src -
getFileContents(String url, String path)
- 功能:显示指定 URL 和路径下文件的内容。
getFileContents https://github.com/Ryan0204/github-repo-mcp README.md
🔧 问题排除
如果遇到以下情况,请按照步骤操作:
-
无法连接到 GitHub API:
- 检查 Internet 连接和 GitHub 状态。
- 尝试重新运行命令:
npm start -
找不到文件或目录:
- 确保路径正确无误。
- 查看仓库的文件结构。
-
超出速率限制:
- 使用 GitHub 账户获取令牌。
- 在
config.json中添加令牌。
通过以上步骤,您应该能够顺利地使用 GitHub Repo MCP 服务器。如果有任何其他问题,请查看输出中的错误信息或在 GitHub 仓库中创建问题。
祝您愉快!😊
微信扫一扫