Skip to main content
Glama
LeonidYasin

MCP GitHub Server

by LeonidYasin

MCP GitHub Server

GitHub API向けの拡張可能なMCP HTTPサーバー。モジュール式アーキテクチャとツールの自動検出を備えています。

機能

サーバーはGitHub操作用の19のツールを提供します:

📁 ファイル操作 (4)

ツール

説明

get_file_contents

リポジトリからファイルの内容を読み取ります

create_or_update_file

テキストファイルの作成・更新

create_or_update_binary_file

バイナリファイルの作成・更新(base64)

delete_file

ファイルの削除(SHAを自動取得)

📝 コミット (2)

ツール

説明

list_commits

最近のコミットの一覧

get_commit_status

コミットのチェックステータス

⚙️ ワークフロー (7)

ツール

説明

get_latest_workflow_error

最新ビルドのエラー

get_workflow_run_logs

特定のワークフロー実行のログ

get_full_workflow_logs

実行内の全ジョブの完全なログ

get_workflow_by_file

YAMLファイル名によるワークフロー実行

list_workflow_runs

run_idとステータス付きの実行一覧

get_latest_run_id

最新実行のrun_id

get_workflow_run_steps

実行内の全ステップとそのステータスの一覧

🏗️ ビルドとデバッグ (6)

ツール

説明

watch_build

ビルドの監視

auto_fix_build

ビルドエラーの自動修正(Android/iOS)

get_android_build_error

Androidビルドの詳細エラー

get_ios_build_error

iOSビルドの詳細エラー

get_run_logs_by_step

ステップ名による特定ステップのログ

create_or_update_file_with_sha

SHA自動取得による作成/更新

Related MCP server: git-mcp

インストール

git clone https://github.com/LeonidYasin/mcp-server.git
cd mcp-server
pip install flask httpx python-dotenv flask-cors

起動

python -m mcp_server.server

サーバーは http://0.0.0.0:3001 で起動し、MCPエンドポイントは POST /mcp です。

GitHubトークンは Authorization: Bearer <token> ヘッダーで渡されます。

DeepSeek++への接続

DeepSeek++プラグインの設定で:

  • URL: http://127.0.0.1:3001/mcp

  • タイプ: HTTP

  • ヘッダー: Authorization: Bearer <ваш_github_token>

プロジェクト構成

mcp-server/
├── pyproject.toml
├── README.md
└── mcp_server/
    ├── __init__.py
    ├── server.py              # Flask HTTP-сервер
    ├── core/
    │   ├── __init__.py
    │   ├── tool.py            # Tool dataclass
    │   └── registry.py        # ToolRegistry с авто-обнаружением
    └── tools/
        ├── __init__.py
        └── github/
            ├── __init__.py            # Экспорт инструментов
            ├── client.py              # GitHub API HTTP-клиент
            ├── file_ops.py            # get_file_contents, create_or_update_file, delete_file
            ├── file_sha_ops.py        # create_or_update_file_with_sha
            ├── create_update_binary.py # create_or_update_binary_file
            ├── commits.py             # list_commits, get_commit_status
            ├── workflows.py           # workflow-инструменты (4 шт)
            ├── workflow_runs.py       # list_workflow_runs, get_latest_run_id, get_workflow_run_steps, get_run_logs_by_step
            ├── build_logs.py          # watch_build
            ├── build_logs_loader.py   # auto_fix_build, get_android_build_error, get_ios_build_error
            └── build_logs_tools.py    # вспомогательные функции для сборки

新しいツールの追加方法

ステップ1: mcp_server/tools/github/ にファイルを作成します

例: mcp_server/tools/github/create_branch.py

"""MCP tool: create_branch - создаёт новую ветку."""

from mcp_server.core.registry import mcp_tool
from mcp_server.tools.github.client import GitHubClient


@mcp_tool(
    name="create_branch",
    description="Создаёт новую ветку в репозитории",
    parameters={
        "owner": {"type": "string", "description": "Владелец репозитория"},
        "repo": {"type": "string", "description": "Имя репозитория"},
        "branch": {"type": "string", "description": "Имя новой ветки"},
        "from_branch": {"type": "string", "description": "Источник (по умолчанию main)"},
    },
    required=["owner", "repo", "branch"],
)
def create_branch(client: GitHubClient, owner: str, repo: str, branch: str, from_branch: str = "main") -> dict:
    """Создать новую ветку."""
    # 1. Получаем SHA родительской ветки
    ref_resp = client._request(
        "GET", f"/repos/{owner}/{repo}/git/ref/heads/{from_branch}"
    )
    sha = ref_resp.json()["object"]["sha"]

    # 2. Создаём ветку
    client._request(
        "POST",
        f"/repos/{owner}/{repo}/git/refs",
        json={"ref": f"refs/heads/{branch}", "sha": sha},
    )

    return {
        "content": [{
            "type": "text",
            "text": f"✅ Ветка '{branch}' создана из '{from_branch}'"
        }]
    }

ステップ2: ツールをエクスポートします

mcp_server/tools/github/__init__.py に次の行を追加します:

from mcp_server.tools.github.create_branch import create_branch

ステップ3: サーバーを再起動します

# Остановите Ctrl+C и снова запустите
python -m mcp_server.server

ツールは自動的にリストに表示されます。その他の設定は必要ありません。

自動検出の仕組み

ToolRegistrymcp_server/core/registry.py 内)は起動時に:

  1. mcp_server/tools/ をスキャンします

  2. __init__.py があるすべてのサブパッケージ(ディレクトリ)を探します

  3. それらをインポートし、デコレータ @mcp_tool が付いた関数を探します

  4. 見つかったツールを登録します

ツール作成のルール

  1. 関数は同期関数である必要があります。最初の引数として client: GitHubClient を受け取ります

  2. デコレータ @mcp_tool は以下を指定します:

    • name — ツール名(呼び出し時に使われる名前)

    • description — AIアシスタント向けの説明

    • parameters — JSON Schema形式のパラメータ辞書

    • required — 必須パラメータのリスト

  3. 返り値は dict で、キー content{"type": "text", "text": "..."} オブジェクトのリストです

  4. GitHub APIへのリクエストには client._request(method, path, ...) を使用します

コピー用テンプレート

"""MCP tool: имя_инструмента - краткое описание."""

from mcp_server.core.registry import mcp_tool
from mcp_server.tools.github.client import GitHubClient


@mcp_tool(
    name="имя_инструмента",
    description="Что делает инструмент",
    parameters={
        "owner": {"type": "string", "description": "Владелец репозитория"},
        "repo": {"type": "string", "description": "Имя репозитория"},
    },
    required=["owner", "repo"],
)
def имя_инструмента(client: GitHubClient, owner: str, repo: str) -> dict:
    # Ваш код здесь
    return {
        "content": [{"type": "text", "text": "Результат работы"}]
    }

GitHubトークンの要件

トークンには以下の権限(スコープ)が必要です:

  • repo(または Contents: Read and write)— ファイル操作用

  • Actions: Read — ワークフロー閲覧用

  • Metadata: Read — 基本情報用(通常はデフォルト)

curlによるサーバーのテスト

# Проверка списка инструментов
curl -X POST http://127.0.0.1:3001/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <токен>" \
  -d '{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}'

# Чтение файла
curl -X POST http://127.0.0.1:3001/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <токен>" \
  -d '{"jsonrpc":"2.0","id":"2","method":"tools/call","params":{"name":"get_file_contents","arguments":{"owner":"LeonidYasin","repo":"mcp-server","path":"README.md"}}}'

バージョン履歴

  • v0.1.0 — stdioトランスポート、基本モジュール式アーキテクチャ

  • v0.2.0 — Flask HTTPトランスポート、10ツール、自動検出、開発者向けガイド

  • v0.3.0 — 新しいツールを9つ追加: 合計19、ワークフロー・ビルド・デバッグ関連を含む

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Standalone MCP server for GitHub that enables repository management, branch operations, pull request handling, and commit retrieval via tools listed in the README.
    1
  • A
    license
    B
    quality
    D
    maintenance
    MCP (Model Context Protocol) server for GitHub API integration. This server provides comprehensive tools for interacting with GitHub repositories, issues, pull requests, branches, and code search through a unified interface.
    15
    14
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    A lightweight MCP server that exposes GitHub operations as tools over HTTP, enabling any MCP-compatible client to interact with GitHub repositories without a built-in connector.
    1

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/LeonidYasin/mcp-server'

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