MCP GitHub Repository Server

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.

Integrations

  • Provides access to GitHub repository contents, allowing browsing and reading files from specified repositories, navigating directories, and supporting branch-specific file access.

MCP GitHub 存储库服务器

一个 MCP(模型上下文协议)服务器,提供对 GitHub 仓库内容的访问。该服务器允许 AI 助手浏览和读取指定 GitHub 仓库中的文件。

演示

特征

资源

  • 通过 URI 访问 GitHub 存储库中的任何文件
  • 列出存储库内容并导航目录
  • 支持特定分支的文件访问
  • 文件内容以纯文本形式提供

资源 URI

  • 基本 URL 格式: https://api.github.com/repos/{owner}/{repo}/contents/{path}
  • 支持文件和目录
  • 文件以text/plain MIME 类型提供
  • 目录采用application/x-directory MIME 类型

配置

服务器需要以下环境变量:

GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token GITHUB_OWNER=repository_owner GITHUB_REPO=repository_name GITHUB_BRANCH=branch_name # Optional

发展

安装依赖项:

npm install

构建服务器:

npm run build

对于使用自动重建的开发:

npm run watch

安装

要与 Claude Desktop 一起使用,请添加服务器配置:

配置位置

  • MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json
{ "mcpServers": { "mcp-server-github-repo": { "command": "/path/to/mcp-server-github-repo/build/index.js" } } }

API 实现

该服务器实现了三个主要的 MCP 端点:

  1. ListResources列出存储库中的文件和目录
  2. ReadResource检索特定文件的内容

验证

服务器使用 GitHub 个人访问令牌进行身份验证。请确保您的令牌具有访问存储库内容的适当权限。

错误处理

服务器包括以下错误处理:

  • 缺少环境变量
  • GitHub API 错误
  • 无效路径(例如,尝试将目录读取为文件)
  • 身份验证失败

调试

由于 MCP 服务器通过 stdio 进行通信,调试起来可能比较困难。请使用 MCP Inspector 进行调试:

npm run inspector

这将提供一个 URL 来访问浏览器中的调试工具。

安全说明

  • 确保您的 GitHub 个人访问令牌安全
  • 考虑使用具有最低所需权限的令牌
  • 访问大型存储库时请注意存储库大小限制

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

允许 AI 助手浏览和读取指定 GitHub 存储库中的文件的服务器,通过模型上下文协议提供对存储库内容的访问。

  1. Demo
    1. Features
      1. Resources
      2. Resource URIs
    2. Configuration
      1. Development
        1. Installation
          1. Config Location
        2. API Implementation
          1. Authentication
          2. Error Handling
        3. Debugging
          1. Security Notes
            1. License
              ID: pq7phnbp3f