Skip to main content
Glama
GitHub Repository MCP Server

GitHub Repository MCP Server

by shanksxz

GitHub 存储库 MCP 服务器

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

特征

  • 获取整个存储库内容作为上下文

  • 从存储库获取特定文件内容

  • 获取存储库结构(文件列表)

  • 按扩展名过滤文件

  • 排除特定路径

  • 限制返回的文件数量

Related MCP server: GitHub Repo Explainer MCP

安装

# 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工具来获取并显示存储库结构。

Available Tools

3 tools
get-file-contentC

Get content of a specific file from a GitHub repository

Inputs: owner (required), repo (required), path (required).

get-repo-contextC

Get all files from a GitHub repository to use as context

Inputs: owner (required), repo (required), maxFiles, fileExtensions, +1 more.

get-repo-structureC

Get the structure of a GitHub repository

Inputs: owner (required), repo (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 3 tools

    Disambiguation2/5

    The tools have overlapping purposes that could cause confusion. get-repo-context and get-repo-structure both retrieve repository information, with get-repo-context getting all files and get-repo-structure getting the structure, making their boundaries unclear. get-file-content is more distinct but still part of the same domain.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with hyphens (get-file-content, get-repo-context, get-repo-structure). The naming is predictable and readable throughout the set.

    Tool Count2/5

    With only 3 tools, the server feels thin for a GitHub repository domain. It lacks essential operations like create, update, delete, or search, which are typical for such a purpose, making the scope incomplete and underpowered.

    Completeness2/5

    The tool surface is severely incomplete for a GitHub repository server. It only provides read-only file and structure retrieval, missing core CRUD operations (e.g., create/update files, manage issues/pull requests) and other common GitHub functionalities, leading to significant gaps that will hinder agent workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to analyze GitHub repository structures and read file contents with features like directory traversal, file type analysis, syntax highlighting, and code pattern detection. Supports both public and private repositories through GitHub API integration.
      5 npm
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to access live GitHub repository data without cloning, supporting repo summarization, file explanation, recent changes, and dependency analysis.
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to inspect local Git repositories and interact with the GitHub API for reading commits, diffs, files, issues, comments, pull requests, and project boards.
      10
      ISC