MCP GitHub Server
MCP GitHub Server
Servidor MCP HTTP extensible para la API de GitHub con arquitectura modular y detección automática de herramientas.
Características
El servidor proporciona 19 herramientas para trabajar con GitHub:
📁 Trabajo con archivos (4)
Herramienta | Descripción |
| Lectura del contenido de archivos del repositorio |
| Creación y actualización de archivos de texto |
| Creación y actualización de archivos binarios (base64) |
| Eliminación de archivos (obtiene el SHA automáticamente) |
📝 Commits (2)
Herramienta | Descripción |
| Lista de los últimos commits |
| Estado de las comprobaciones de un commit |
⚙️ Workflow (7)
Herramienta | Descripción |
| Error de la última compilación |
| Registros de una ejecución específica del workflow |
| Registros completos de todos los jobs de la ejecución |
| Ejecuciones del workflow por nombre del archivo YAML |
| Lista de ejecuciones con run_id y estados |
| run_id de la última ejecución |
| Lista de todos los pasos de la ejecución con sus estados |
🏗️ Compilación y depuración (6)
Herramienta | Descripción |
| Supervisión de la compilación |
| Corrección automática de errores de compilación (Android/iOS) |
| Error detallado de la compilación de Android |
| Error detallado de la compilación de iOS |
| Registros de un paso específico por nombre |
| Creación/actualización con obtención automática del SHA |
Related MCP server: git-mcp
Instalación
git clone https://github.com/LeonidYasin/mcp-server.git
cd mcp-server
pip install flask httpx python-dotenv flask-corsEjecución
python -m mcp_server.serverEl servidor se ejecuta en http://0.0.0.0:3001, el endpoint MCP es: POST /mcp.
El token de GitHub se envía mediante el encabezado Authorization: Bearer <token>.
Conexión a DeepSeek++
En la configuración del plugin DeepSeek++:
URL:
http://127.0.0.1:3001/mcpTipo: HTTP
Encabezado:
Authorization: Bearer <su_token_de_github>
Estructura del proyecto
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 # вспомогательные функции для сборкиCómo añadir una nueva herramienta
Paso 1: Cree un archivo en mcp_server/tools/github/
Ejemplo: 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}'"
}]
}Paso 2: Exporte la herramienta
En mcp_server/tools/github/__init__.py añada la línea:
from mcp_server.tools.github.create_branch import create_branchPaso 3: Reinicie el servidor
# Остановите Ctrl+C и снова запустите
python -m mcp_server.serverLa herramienta aparecerá automáticamente en la lista. No se requiere ninguna otra configuración.
Cómo funciona la auto-detección
ToolRegistry (en mcp_server/core/registry.py) al iniciarse:
Escanea
mcp_server/tools/Encuentra todos los subpaquetes (directorios con
__init__.py)Los importa y busca funciones con el decorador
@mcp_toolRegistra las herramientas encontradas
Reglas para escribir herramientas
La función debe ser síncrona y aceptar
client: GitHubClientcomo primer argumentoEl decorador
@mcp_tooldefine:name— nombre de la herramienta (cómo se invocará)description— descripción para el asistente de IAparameters— diccionario de parámetros en formato JSON Schemarequired— lista de parámetros obligatorios
Debe devolver un
dictcon la clavecontent— una lista de objetos{"type": "text", "text": "..."}Para solicitudes a la API de GitHub use
client._request(method, path, ...)
Plantilla para copiar
"""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": "Результат работы"}]
}Requisitos del token de GitHub
El token debe tener los siguientes permisos (scopes):
repo(oContents: Read and write) — para trabajar con archivosActions: Read— para ver los workflowsMetadata: Read— para información básica (normalmente por defecto)
Prueba del servidor mediante 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"}}}'Versionado
v0.1.0 — transporte stdio, arquitectura modular básica
v0.2.0 — transporte HTTP Flask, 10 herramientas, auto-detección, instrucciones para desarrolladores
v0.3.0 — Se añadieron 9 herramientas nuevas: 19 en total, incluyendo trabajo con workflows, compilación y depuración
This server cannot be deployed
Maintenance
Related MCP Connectors
Create, deploy, and operate MCP servers directly from your GitHub repositories.
GitHub MCP — wraps the GitHub public REST API (no auth required for public endpoints)
A MCP server built for developers enabling Git based project management with project and personal…
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Related MCP Servers
- -licenseNot gradedqualityAmaintenanceMCP Server for the GitHub API, enabling file operations, repository management, search functionality, and more.124,024 npm91,671MIT
- FlicenseNot gradedqualityDmaintenanceStandalone MCP server for GitHub that enables repository management, branch operations, pull request handling, and commit retrieval via tools listed in the README.1-
- AlicenseBqualityDmaintenanceMCP (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.156 npmMIT
- AlicenseNot gradedqualityBmaintenanceA 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.1MIT