Skip to main content
Glama
LeonidYasin

MCP GitHub Server

by LeonidYasin

MCP GitHub Server

Erweiterbarer MCP HTTP-Server für die GitHub API mit modularer Architektur und automatischer Erkennung von Tools.

Funktionen

Der Server bietet 19 Tools für die Arbeit mit GitHub:

📁 Dateiverwaltung (4)

Tool

Beschreibung

get_file_contents

Lesen des Dateiinhalts aus dem Repository

create_or_update_file

Erstellen und Aktualisieren von Textdateien

create_or_update_binary_file

Erstellen und Aktualisieren von Binärdateien (base64)

delete_file

Löschen von Dateien (SHA wird automatisch abgerufen)

📝 Commits (2)

Tool

Beschreibung

list_commits

Liste der letzten Commits

get_commit_status

Status der Checks für einen Commit

⚙️ Workflow (7)

Tool

Beschreibung

get_latest_workflow_error

Fehler des letzten Builds

get_workflow_run_logs

Logs eines bestimmten Workflow-Laufs

get_full_workflow_logs

Vollständige Logs aller Jobs eines Laufs

get_workflow_by_file

Workflow-Läufe nach YAML-Dateinamen

list_workflow_runs

Liste der Läufe mit run_id und Status

get_latest_run_id

run_id des letzten Laufs

get_workflow_run_steps

Liste aller Schritte in einem Lauf mit deren Status

🏗️ Build und Debugging (6)

Tool

Beschreibung

watch_build

Überwachung des Builds

auto_fix_build

Automatische Korrektur von Build-Fehlern (Android/iOS)

get_android_build_error

Detaillierter Fehler des Android-Builds

get_ios_build_error

Detaillierter Fehler des iOS-Builds

get_run_logs_by_step

Logs eines bestimmten Schritts nach Name

create_or_update_file_with_sha

Erstellen/Aktualisieren mit automatischem Abruf der SHA

Related MCP server: git-mcp

Installation

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

Start

python -m mcp_server.server

Der Server läuft auf http://0.0.0.0:3001, der MCP-Endpunkt ist POST /mcp.

Das GitHub-Token wird über den Header Authorization: Bearer <token> übergeben.

Verbindung zu DeepSeek++

In den Einstellungen des DeepSeek++-Plugins:

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

  • Typ: HTTP

  • Header: Authorization: Bearer <ваш_github_token>

Projektstruktur

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    # вспомогательные функции для сборки

So fügen Sie ein neues Tool hinzu

Schritt 1: Erstellen Sie eine Datei in mcp_server/tools/github/

Beispiel: 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}'"
        }]
    }

Schritt 2: Exportieren Sie das Tool

Fügen Sie in mcp_server/tools/github/__init__.py eine Zeile hinzu:

from mcp_server.tools.github.create_branch import create_branch

Schritt 3: Starten Sie den Server neu

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

Das Tool erscheint automatisch in der Liste. Keine weitere Konfiguration ist erforderlich.

So funktioniert die automatische Erkennung

ToolRegistry (in mcp_server/core/registry.py) führt beim Start Folgendes aus:

  1. Scannt mcp_server/tools/

  2. Findet alle Unterpakete (Verzeichnisse mit __init__.py)

  3. Importiert sie und sucht nach Funktionen mit dem Dekorator @mcp_tool

  4. Registriert die gefundenen Tools

Regeln für die Erstellung von Tools

  1. Die Funktion muss synchron sein und client: GitHubClient als erstes Argument akzeptieren

  2. Der Dekorator @mcp_tool definiert:

    • name — Name des Tools (wie es aufgerufen wird)

    • description — Beschreibung für den KI-Assistenten

    • parameters — Wörterbuch der Parameter im JSON-Schema-Format

    • required — Liste der erforderlichen Parameter

  3. Es muss ein dict zurückgegeben werden mit dem Schlüssel content — einer Liste von Objekten {"type": "text", "text": "..."}

  4. Für Anfragen an die GitHub API verwenden Sie client._request(method, path, ...)

Vorlage zum Kopieren

"""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": "Результат работы"}]
    }

Anforderungen an das GitHub-Token

Das Token muss die folgenden Berechtigungen (Scopes) haben:

  • repo (oder Contents: Read and write) — für die Arbeit mit Dateien

  • Actions: Read — zum Anzeigen von Workflows

  • Metadata: Read — für Basisinformationen (normalerweise standardmäßig)

Testen des Servers mit 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"}}}'

Versionierung

  • v0.1.0 — stdio-Transport, grundlegende modulare Architektur

  • v0.2.0 — Flask-HTTP-Transport, 10 Tools, automatische Erkennung, Anleitung für Entwickler

  • v0.3.0 — 9 neue Tools hinzugefügt: insgesamt 19, einschließlich Arbeit mit Workflows, Build und Debugging

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