MCP GitHub Server
MCP GitHub Server
GitHub API용 확장 가능한 MCP HTTP 서버로, 모듈식 아키텍처와 자동 도구 탐지를 갖추고 있습니다.
기능
서버는 GitHub 작업을 위한 19개의 도구를 제공합니다:
📁 파일 작업 (4)
도구 | 설명 |
| 저장소에서 파일 내용 읽기 |
| 텍스트 파일 생성 및 업데이트 |
| 바이너리 파일 생성 및 업데이트 (base64) |
| 파일 삭제 (SHA 자동 획득) |
📝 커밋 (2)
도구 | 설명 |
| 최근 커밋 목록 |
| 커밋에 대한 검사 상태 |
⚙️ 워크플로우 (7)
도구 | 설명 |
| 마지막 빌드의 오류 |
| 특정 워크플로우 실행의 로그 |
| 실행의 모든 작업에 대한 전체 로그 |
| YAML 파일 이름으로 워크플로우 실행 조회 |
| run_id 및 상태가 포함된 실행 목록 |
| 마지막 실행의 run_id |
| 실행의 모든 단계와 해당 상태 목록 |
🏗️ 빌드 및 디버깅 (6)
도구 | 설명 |
| 빌드 모니터링 |
| 빌드 오류 자동 수정 (Android/iOS) |
| Android 빌드 상세 오류 |
| iOS 빌드 상세 오류 |
| 이름으로 특정 단계의 로그 |
| 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 <your_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_branch3단계: 서버 재시작
# Остановите Ctrl+C и снова запустите
python -m mcp_server.server도구가 목록에 자동으로 나타납니다. 다른 설정은 필요하지 않습니다.
자동 탐지 작동 방식
ToolRegistry(mcp_server/core/registry.py에 있음)는 시작 시:
mcp_server/tools/를 스캔합니다모든 하위 패키지(
__init__.py가 있는 디렉터리)를 찾습니다이를 가져와서
@mcp_tool데코레이터가 있는 함수를 찾습니다발견된 도구를 등록합니다
도구 작성 규칙
함수는 동기식이어야 하며 첫 번째 인수로
client: GitHubClient를 받아야 합니다@mcp_tool데코레이터는 다음을 지정합니다:name— 도구 이름(호출되는 방식)description— AI 어시스턴트를 위한 설명parameters— JSON Schema 형식의 매개변수 사전required— 필수 매개변수 목록
dict를 반환해야 하며,content키에{"type": "text", "text": "..."}객체 목록을 포함해야 합니다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 토큰 요구 사항
토큰에는 다음 권한(scopes)이 있어야 합니다:
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개, 워크플로우, 빌드 및 디버깅 작업 포함
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