Skip to main content
Glama
nht-x
by nht-x

🚀 GitHub MCP サーバー

Model Context Protocol (MCP) による GitHub API 統合
Claude Desktop & GPT-4 との連携で、GitHub を AI アシスタントから直接操作できます。

GitHub Python License


📋 クイックスタート

1️⃣ インストール

# リポジトリをクローン
git clone https://github.com/nht-x/github-mcp.git
cd github-mcp

# Poetry で依存関係をインストール
poetry install

2️⃣ 環境設定

# .env.example をコピー
cp .env.example .env

# 暗号化キーを生成
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

# .env を編集(GitHub PAT と暗号化キーを設定)
nano .env

3️⃣ ローカルサーバー起動

# MCP サーバー起動(stdio トランスポート)
poetry run python -m github_mcp.core.server

📖 詳細は DEVELOPMENT.md を参照


Related MCP server: GitHub MCP Server

✨ 機能

利用可能なツール(3 個)

ツール

説明

パラメータ

get_repository_info

リポジトリ情報を取得

owner, repo

create_issue

Issue を作成

owner, repo, title, body

trigger_repository_dispatch

repository_dispatch イベントを発火

owner, repo, event_type, payload_json


🏗️ プロジェクト構造

github-mcp/
├── 📁 src/github_mcp/
│   ├── 📄 config.py                 # 設定管理
│   ├── 📁 api/
│   │   ├── client.py                # GitHub API クライアント
│   │   ├── exceptions.py            # API 例外定義
│   │   └── __init__.py
│   ├── 📁 core/
│   │   ├── server.py                # MCP サーバー本体
│   │   ├── cli.py                   # CLI エントリーポイント
│   │   └── __init__.py
│   ├── 📁 tools/
│   │   ├── handlers.py              # MCP ツールハンドラー
│   │   └── __init__.py
│   ├── 📁 utils/
│   │   ├── encryption.py            # トークン暗号化(Fernet)
│   │   ├── logging.py               # ログ & トークンマスキング
│   │   └── __init__.py
│   └── 📁 services/
│       └── __init__.py              # GitHub サービスラッパー
├── 📁 tests/
│   ├── unit/                        # ユニットテスト
│   └── integration/                 # 統合テスト
├── .env.example                     # 環境テンプレート
├── pyproject.toml                   # 依存関係
├── DEVELOPMENT.md                   # 開発ガイド
├── README.md                        # このファイル
└── LICENSE                          # MIT License

🔐 セキュリティ機能

PAT 管理

  • 環境変数GITHUB_PAT は環境変数から読み込み

  • 暗号化 — Fernet 対称鍵暗号化で本番環境対応

ログとマスキング

  • 自動マスキング — API キーは自動的に ***REDACTED*** に隠蔽

  • JSON ログ — 本番環境では JSON 形式で構造化ログ出力

  • テキストログ — 開発環境では読みやすいテキスト形式


📖 セットアップ詳細

環境変数(.env)

# 必須
GITHUB_PAT=ghp_...                    # GitHub Personal Access Token
ENCRYPTION_KEY=your_fernet_key        # python -c で生成

# オプション
LOG_LEVEL=INFO                        # DEBUG, INFO, WARNING, ERROR
LOG_FORMAT=text                       # text または json
MCP_SERVER_HOST=127.0.0.1
MCP_SERVER_PORT=8000

GitHub PAT スコープ

以下のスコープが必要です:

  • repo — リポジトリ読み取り・書き込み

  • workflow — GitHub Actions 操作(repository_dispatch 用)

  • issues — Issue の作成・読み取り

PAT 生成方法

  1. GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)

  2. 「Generate new token (classic)」をクリック

  3. スコープを上記から選択

  4. トークンをコピーして .env に設定


🖥️ Claude Desktop 接続

設定ファイル

Claude Desktop に以下を設定します:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

設定例

{
  "mcpServers": {
    "github": {
      "command": "poetry",
      "args": ["run", "python", "-m", "github_mcp.core.server"],
      "cwd": "/absolute/path/to/github-mcp",
      "env": {
        "GITHUB_PAT": "ghp_...",
        "ENCRYPTION_KEY": "your_fernet_key"
      }
    }
  }
}

接続確認

Claude Desktop を再起動し、以下のように聞いてください:

「GitHub でリポジトリ情報を取得してくれる?」


🤖 GPT Custom GPT 接続

OpenAI Actions 設定

  1. OpenAI ChatGPT > Custom GPT にアクセス

  2. 「Create new GPT」をクリック

  3. 以下の設定を追加:

スキーマ(OpenAPI)

openapi: 3.0.0
info:
  title: GitHub MCP API
  version: 1.0.0
servers:
  - url: http://localhost:8000
paths:
  /dispatch:
    post:
      summary: repository_dispatch をトリガー
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                owner:
                  type: string
                repo:
                  type: string
                event_type:
                  type: string
                payload_json:
                  type: string
  /issue:
    post:
      summary: Issue を作成
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                owner:
                  type: string
                repo:
                  type: string
                title:
                  type: string
                body:
                  type: string
  /repository:
    post:
      summary: リポジトリ情報を取得
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                owner:
                  type: string
                repo:
                  type: string

🧪 テスト

# すべてのテストを実行
poetry run pytest

# カバレッジ付きで実行
poetry run pytest --cov=src/github_mcp

# 特定のテストファイルのみ実行
poetry run pytest tests/unit/test_config.py -v

🛠️ 開発

詳細な開発ガイドは DEVELOPMENT.md を参照

コード品質チェック

# フォーマッティング
poetry run black src/

# リント
poetry run ruff check src/

# 型チェック
poetry run mypy src/

🚀 本番環境デプロイ

GCP Secret Manager 統合

暗号化キーやトークンを GCP Secret Manager で管理する場合:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

詳細は DEVELOPMENT.md の「本番環境設定」を参照


📝 ライセンス

MIT License — LICENSE を参照


💡 トラブルシューティング

エラー: GITHUB_PAT not configured

# .env に GITHUB_PAT が設定されているか確認
cat .env | grep GITHUB_PAT

# 環境変数で直接設定
export GITHUB_PAT=ghp_...

エラー: Failed to initialize MCP server

# 依存関係を再インストール
poetry install --no-cache

# 暗号化キーが正しい Fernet キーか確認
python -c "from cryptography.fernet import Fernet; Fernet('your_key')"

エラー: rate limit exceeded

GitHub API のレート制限に達した場合、待機してから再度実行してください。


📬 サポート

問題が発生した場合、GitHub Issues で報告してください。


Made with ❤️ by the Hermes crew

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

  • Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…

  • Git-backed platform for skills, tools, and context for AI agents

View all MCP Connectors

Latest Blog Posts

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/nht-x/github-mcp'

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