Skip to main content
Glama

github-repo-mcp

GitHub 仓库 MCP

目录

✨ 主要特点

  • 💻 兼容 Cursor、Windsurf、Claude Desktop 和其他支持stdio协议的 MCP 客户端
  • 🔎 浏览任何公共 GitHub 存储库的内容
  • 📂 浏览存储库目录和子目录
  • 📝 查看代码和文本文件的内容
  • 📦通过包管理器轻松安装

入门

先决条件

安装服务器需要您的系统具备以下条件:

  • Node.js 18+
  • npm 或 yarn

步骤1.安装

您可以使用 Smithery、NPX 或 IDE 的 mcp.json 中的设置来安装和运行 GitHub Repo MCP:

MacOS
npx github-repo-mcp
Windows NPX
cmd /c npx -y github-repo-mcp
通过 .cursor/mcp.json 实现 Windows NPX
{ "mcpServers": { "github-repo-mcp": { "command": "wsl", "args": [ "bash", "-c", "cmd /c npx -y github-repo-mcp" ], "enabled": true } } }
通过 .cursor/mcp.json 的 Windows NPX(如果未设置路径)
# Find the full path to npx first which npx
{ "mcpServers": { "github-repo-mcp": { "command": "wsl", "args": [ "bash", "-c", "'/home/[username]/.nvm/versions/node/v20.18.0/bin/npx github-repo-mcp'" ], "enabled": true } } }
通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 GitHub Repo MCP:

npx -y @smithery/cli install @Ryan0204/github-repo-mcp --client claude

如果未注册,请等待几秒钟或点击刷新按钮几次。如果仍然无法注册,请确保您输入了正确的命令。

步骤2.配置

GitHub Repo MCP 服务器在访问 GitHub API 时可以使用 GitHub 令牌来获得更高的速率限制。

环境变量
多变的必需的默认描述
GITHUB_TOKEN没有任何您的 GitHub 个人访问令牌,用于更高的速率限制
设置 GitHub 令牌(可选)

虽然服务器无需身份验证即可运行,但 GitHub API 对未经身份验证的请求的速率限制要低得多。要提高速率限制:

  1. https://github.com/settings/tokens创建个人访问令牌
  2. 在 mcp.json 中将令牌设置为环境变量:
{ "mcpServers": { "github-repo-mcp": { "command": "...", "args": [ ... ], "env": { "GITHUB_TOKEN": "Your_Github_Token" } "enabled": true, } } }

功能概述

存储库浏览工具

该服务器提供了三个与 GitHub 存储库交互的主要工具:

1. getRepoAllDirectories

列出 GitHub 存储库根目录下的所有文件和目录。

2. getRepoDirectories

列出 GitHub 存储库中特定目录的内容。

  • 参数
    • repoUrl :GitHub 存储库的 URL
    • path :要获取的目录路径(例如“src”)
3. getRepoFile

从 GitHub 存储库检索并显示特定文件的内容。

  • 参数
    • repoUrl :GitHub 存储库的 URL
    • path :要获取的文件路径(例如“src/index.js”)

使用示例

以下是如何将这些工具与 AI 助手一起使用的一些示例:

  1. 浏览存储库根目录:要求您的 AI 助手“向我显示https://github.com/Ryan0204/github-repo-mcp存储库的内容”
  2. 探索特定目录:询问“ https://github.com/Ryan0204/github-repo-mcp的 src 目录中有哪些文件?”
  3. 查看文件:询问“显示https://github.com/Ryan0204/github-repo-mcp中的 README.md 文件”

限制

  • 速率限制:如果没有身份验证,GitHub API 有严格的速率限制(每小时 60 个请求)
  • 私有存储库:除非提供具有适当权限的令牌,否则只能访问公共存储库
  • 二进制文件:服务器检测常见的二进制文件扩展名,但不会显示其内容
  • 大文件:GitHub API 对可检索文件的大小有限制

故障排除

以下是一些常见问题及其解决方案:

  • 超出速率限制:按照配置部分中的说明设置 GitHub 令牌
  • 未找到命令:确保包已全局安装
  • 连接错误:检查您的互联网连接和 GitHub API 状态

如果您遇到任何问题,请检查输出中的错误消息或在 GitHub 存储库中创建问题。


尽情享受吧!☺️

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

GitHub Repo MCP 是一个开源 MCP 服务器,可让您的 AI 助手浏览 GitHub 存储库、探索目录和查看文件内容。

  1. 目录
    1. ✨ 主要特点
      1. 入门
        1. 先决条件
        2. 步骤1.安装
        3. 步骤2.配置
      2. 功能概述
        1. 存储库浏览工具
        2. 使用示例
        3. 限制
      3. 故障排除

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          Helps AI read GitHub repository structure and important files. Want to quickly understand what a repo is about? Prompt it with "read https://github.com/adhikasp/mcp-git-ingest and determine how the code technically works".
          Last updated -
          2
          60
          Python
          MIT License
        • A
          security
          F
          license
          A
          quality
          MCP Server for the GitHub API, providing features for file operations, repository management, and advanced search, with automatic branch creation and comprehensive error handling.
          Last updated -
          18
          4
          3
          TypeScript
          • Linux
          • Apple
        • -
          security
          F
          license
          -
          quality
          Provides tools for interacting with GitHub's API through the MCP protocol, allowing users to create repositories, push content, and retrieve user information.
          Last updated -
          JavaScript
        • -
          security
          A
          license
          -
          quality
          An MCP server that wraps around the GitHub CLI tool, allowing AI assistants to interact with GitHub repositories through commands for pull requests, issues, and repository operations.
          Last updated -
          123
          TypeScript
          MIT License
          • Linux
          • Apple

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ryan0204/github-repo-mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server