stdio 协议的 MCP 客户端安装服务器需要在系统上满足以下条件:
您可以使用 Smithery、NPX 或在 IDE 的 mcp.json 中设置来安装和运行 GitHub Repo MCP:
npx github-repo-mcp
cmd /c npx -y github-repo-mcp
{
"mcpServers": {
"github-repo-mcp": {
"command": "wsl",
"args": [
"bash",
"-c",
"cmd /c npx -y github-repo-mcp"
],
"enabled": true
}
}
}
# 首先找到 npx 的完整路径
which npx
{
"mcpServers": {
"github-repo-mcp": {
"command": "wsl",
"args": [
"bash",
"-c",
"'/home/[用户名]/.nvm/versions/node/v20.18.0/bin/npx github-repo-mcp'"
],
"enabled": true
}
}
}
要通过 Smithery 自动为 Claude Desktop 安装 GitHub Repo MCP:
npx -y @smithery/cli install @Ryan0204/github-repo-mcp --client claude
等待几秒钟或点击刷新按钮几次,如果它没有注册。如果仍然无法注册,请确保您输入了正确的命令。
GitHub Repo MCP 服务器可以使用 GitHub 令牌以更高的速率限制访问 GitHub API。
| 变量 | 必需 | 默认值 | 描述 |
|---|---|---|---|
GITHUB_TOKEN | 否 | 无 | 您的 GitHub 个人访问令牌,用于提高速率限制 |
虽然服务器可以在没有身份验证的情况下工作,但 GitHub API 对未认证请求的速率限制较低。为了增加您的速率限制:
{
"mcpServers": {
"github-repo-mcp": {
"command": "...",
"args": [
...
],
"env": {
"GITHUB_TOKEN": "您的_Github_令牌"
},
"enabled": true,
}
}
}
该服务器提供了三种主要工具与 GitHub 存储库进行交互:
getRepoAllDirectories列出 GitHub 存储库根目录下的所有文件和目录。
repoUrl:GitHub 存储库的 URL(例如:"https://github.com/owner/repo")getRepoDirectories列出 GitHub 存储库中特定目录的内容。
repoUrl:GitHub 存储库的 URLpath:要获取的目录路径(例如:"src")getRepoFile检索并显示来自 GitHub 存储库的特定文件内容。
repoUrl:GitHub 存储库的 URLpath:要获取的文件路径(例如:"src/index.js")这里有一些如何使用这些工具与 AI 助手交互的例子:
浏览存储库根目录: 让您的 AI 助手“显示 https://github.com/Ryan0204/github-repo-mcp 存储库的内容”
探索特定目录: 询问“https://github.com/Ryan0204/github-repo-mcp 的 src 目录中有哪些文件?”
查看文件: 询问“显示 https://github.com/Ryan0204/github-repo-mcp 的 README.md 文件”
这里是一些常见问题及其解决方案:
如果您遇到任何问题,请检查输出中的错误消息或在 GitHub 存储库中创建一个问题。
祝您使用愉快! ☺️