Skip to main content
Glama

GitHub Repository MCP Server

GitHub 存储库 MCP 服务器

此模型上下文协议 (MCP) 服务器允许 AI 模型访问 GitHub 仓库内容作为上下文。它提供工具来获取文件内容、仓库结构以及整个仓库,以用作 AI 交互的上下文。

特征

  • 获取整个存储库内容作为上下文
  • 从存储库获取特定文件内容
  • 获取存储库结构(文件列表)
  • 按扩展名过滤文件
  • 排除特定路径
  • 限制返回的文件数量

安装

# clone the repository git clone https://github.com/shanksxz/github-mcp.git cd github-mcp # install dependencies npm install # build the project npm run build

用法

设置 GitHub 身份验证

虽然服务器无需身份验证即可处理公共仓库,但 GitHub API 对未经身份验证的请求有严格的速率限制(每小时 60 个请求)。要将此限制提高到每小时 5000 个请求,请设置GITHUB_TOKEN环境变量:

# create a file called gh.sh and add the following line: export GITHUB_TOKEN=your_github_personal_access_token # make the file executable chmod +x gh.sh # run the file ./gh.sh

您可以在GitHub 开发者设置中创建个人访问令牌。

与游标一起使用

要将此服务器与 Cursor 一起使用,请按照以下步骤操作:

  1. 打开游标设置
  2. 搜索“MCP”
  3. 点击“添加新的 MCP 服务器”
  4. 输入以下信息:
    • 名称:github-repo-context(或您想要的任何名称)
    • 类型:命令
    • 命令:/path/to/your-local-repo-setup/gh.sh
  5. 点击“保存”
  6. 单击服务器名称旁边的开关来启用服务器
  7. 您现在应该能够在项目中使用该服务器

服务器按照 MCP 协议通过 stdin/stdout 进行通信。

可用工具

该服务器提供以下工具:

  1. get-repo-context :从 GitHub 存储库获取所有文件作为上下文
    • 参数:
      • owner :GitHub 仓库所有者/组织名称
      • repo :GitHub 存储库名称
      • maxFiles (可选):要包含的最大文件数(默认值:50)
      • fileExtensions (可选):要包含的文件扩展名(例如,['js','ts','md'])
      • excludePaths (可选):要排除的路径(默认值:['node_modules','dist','build'])
  2. get-file-content :从 GitHub 存储库获取特定文件的内容
    • 参数:
      • owner :GitHub 仓库所有者/组织名称
      • repo :GitHub 存储库名称
      • path :存储库中的文件路径
  3. get-repo-structure :获取 GitHub 存储库的结构
    • 参数:
      • owner :GitHub 仓库所有者/组织名称
      • repo :GitHub 存储库名称

例子

当与支持 MCP 的 AI 模型集成时,您可以使用以下命令:

Get the structure of the repository tensorflow/tensorflow

然后,AI 将使用get-repo-structure工具来获取并显示存储库结构。

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

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

使 AI 模型能够访问 GitHub 存储库内容作为上下文,并具有获取整个存储库、特定文件内容和存储库结构以用于 AI 交互的功能。

  1. 特征
    1. 安装
      1. 用法
        1. 设置 GitHub 身份验证
        2. 与游标一起使用
        3. 可用工具
      2. 例子

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          A server that allows AI assistants to browse and read files from specified GitHub repositories, providing access to repository contents via the Model Context Protocol.
          Last updated -
          5
          JavaScript
          MIT License
          • Apple
        • A
          security
          F
          license
          A
          quality
          A Model Context Protocol server that enables AI models to interact with GitHub's API, allowing for repository creation and management with descriptions, topics, and website URLs through natural language commands.
          Last updated -
          1
          JavaScript
        • -
          security
          F
          license
          -
          quality
          A Model Context Protocol server that enables AI assistants to perform GitHub operations including repository management, file operations, issue tracking, and pull request creation.
          Last updated -
          1
          TypeScript
        • -
          security
          A
          license
          -
          quality
          Enables interaction with GitHub repositories through the GitHub API, allowing file operations, repository management, issue tracking, and code search through natural language commands.
          Last updated -
          28
          2
          TypeScript
          MIT License
          • Apple
          • Linux

        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/shanksxz/gh-mcp-server'

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