0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude Desktop + GitHub MCPの設定で押さえておきたい3つの選択肢

0
Posted at

背景

Claude DesktopにGitHub MCP(Model Context Protocol)を繋ぐと、プロジェクト機能の4KBファイルサイズ制限を回避してリポジトリ全体にアクセスできます。設定方法が複数あるので、それぞれの違いと、PATの権限設計についてまとめます。

1. GitHub PATはFine-grained推奨

GitHubのPersonal Access Tokenには2種類あり、Fine-grained PATの方がリポジトリ単位で権限を絞れます。

権限カテゴリ 設定値
Contents Read and write
Issues Read and write
Pull requests Read and write
Metadata Read-only(自動付与)
Workflows Read and write(GitHub Actionsを使う場合)

Classic PATを使う場合はrepo / workflow / read:org / user:emailのスコープが必要ですが、アカウント全体に権限が及ぶため、Fine-grained PATの方がセキュリティ上優れています。

2. MCPサーバーの接続方法は3通り

方法A: npx(推奨)

claude_desktop_config.jsonに以下を追記します。

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_TOKEN_HERE"
      }
    }
  }
}

方法B: Docker

Node.jsを入れたくない場合、Dockerイメージ版も使えます。

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_TOKEN_HERE"
      }
    }
  }
}

方法C: Desktop Extensions(.dxt/.mcpb)

JSON編集なしで、Extensionsギャラリーから検索→インストール→GitHub認証、の3ステップで完了します。JSONを直接触りたくない場合はこちらが早いです。

3. トークン消費の考え方

GitHubリポジトリ全体のサイズは直接的にはトークン消費に影響しません。実際に効くのは以下の2つです。

  • MCPツールの定義: 約5,000トークン(常時)
  • 実際に取得したファイル: 内容次第(例: 35KBのファイルで約8,000トークン)

必要なファイルだけを都度取得する設計なので、プロジェクト機能に全ファイルを常駐させるより効率的です。

4. ハマりやすいポイント

症状 原因 対処
Could not connect to MCP server Node.jsが入っていない node --version / npm --version で確認
ハンマーアイコンが出ない Claude Desktopの再起動が不完全 タスクトレイのアイコンも右クリックで完全終了してから再起動
ファイルが読めない トークンのスコープ不足 repoスコープ、または期限切れを確認

まとめ

npx・Docker・Desktop Extensionsの3通りから環境に合う方法を選べます。迷ったらnpx版が手軽です。Node.jsのインストールからPAT発行、動作確認までの全手順はこちらにまとめています。

Claude Desktop + GitHub MCP 完全セットアップガイド(ブログ)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?