GitHub Repository MCP Server

Integrations

  • Allows access to GitHub repository contents as context for AI models, providing tools to fetch entire repositories, specific file contents, and repository structure with capabilities for filtering by extension and excluding specific paths.

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ツールを使用してリポジトリ構造を取得して表示します。

-
security - not tested
F
license - not found
-
quality - not tested

AI モデルがコンテキストとして GitHub リポジトリのコンテンツにアクセスできるようにし、AI インタラクションで使用するためにリポジトリ全体、特定のファイル コンテンツ、リポジトリ構造を取得する機能を備えています。

  1. Features
    1. Installation
      1. Usage
        1. Setting up GitHub Authentication
        2. Using with Cursor
        3. Available Tools
      2. Example
        ID: ncc1bjxpdm