Skip to main content
Glama
AstroMined
by AstroMined

PyGithub MCP 서버

PyGithub을 통해 GitHub API와 상호작용하는 도구를 제공하는 모델 컨텍스트 프로토콜 서버입니다. 이 서버를 통해 AI 어시스턴트는 이슈, 저장소, 풀 리퀘스트 관리와 같은 GitHub 작업을 수행할 수 있습니다.

특징

  • 모듈식 도구 아키텍처:

    • 활성화/비활성화할 수 있는 구성 가능한 도구 그룹

    • 도메인별 조직(이슈, 저장소 등)

    • 파일 또는 환경 변수를 통한 유연한 구성

    • 모듈식 설계로 관심사를 명확하게 분리

    • 일관된 패턴으로 쉽게 확장 가능

  • 완벽한 GitHub 이슈 관리:

    • 문제 생성 및 업데이트

    • 문제 세부 정보를 얻고 저장소 문제를 나열합니다.

    • 댓글 추가, 나열, 업데이트 및 삭제

    • 이슈 라벨 관리

    • 담당자 및 이정표 처리

  • 스마트 매개변수 처리:

    • 선택적 매개변수에 대한 동적 kwargs 빌드

    • GitHub 객체에 대한 적절한 유형 변환

    • 모든 입력 매개변수에 대한 검증

    • 잘못된 입력에 대한 오류 메시지 지우기

  • 강력한 구현:

    • PyGithub을 통한 객체 지향 GitHub API 상호 작용

    • 중앙화된 GitHub 클라이언트 관리

    • 적절한 오류 처리 및 속도 제한

    • MCP 도구를 통한 깔끔한 API 추상화

    • 포괄적인 페이지 매김 지원

    • 디버깅을 위한 자세한 로깅

Related MCP server: GitHub Enterprise MCP Server

선적 서류 비치

포괄적인 가이드는 docs/guides 디렉토리에서 확인할 수 있습니다.

  • error-handling.md: 오류 유형, 처리 패턴 및 모범 사례

  • security.md: 인증, 액세스 제어 및 콘텐츠 보안

  • tool-reference.md: 예제를 포함한 자세한 도구 설명서

PyGithub MCP 서버 사용에 대한 자세한 내용은 이 가이드를 참조하세요.

사용 예

이슈 운영

  1. 문제 생성

지엑스피1

  1. 문제 세부 정보 가져오기

{ "owner": "username", "repo": "repository", "issue_number": 1 }
  1. 문제 업데이트

{ "owner": "username", "repo": "repository", "issue_number": 1, "title": "Updated Title", "body": "Updated description", "state": "closed", "labels": ["bug", "wontfix"] }

댓글 작업

  1. 댓글 추가

{ "owner": "username", "repo": "repository", "issue_number": 1, "body": "This is a comment" }
  1. 목록 코멘트

{ "owner": "username", "repo": "repository", "issue_number": 1, "per_page": 10 }
  1. 댓글 업데이트

{ "owner": "username", "repo": "repository", "issue_number": 1, "comment_id": 123456789, "body": "Updated comment text" }

레이블 작업

  1. 라벨 추가

{ "owner": "username", "repo": "repository", "issue_number": 1, "labels": ["enhancement", "help wanted"] }
  1. 라벨 제거

{ "owner": "username", "repo": "repository", "issue_number": 1, "label": "enhancement" }

모든 작업은 선택적 매개변수를 지능적으로 처리합니다.

  • API 호출에는 제공된 매개변수만 포함됩니다.

  • 기본 유형을 GitHub 객체로 변환합니다(예: 마일스톤 번호를 마일스톤 객체로 변환).

  • 잘못된 매개변수에 대한 명확한 오류 메시지를 제공합니다.

  • 해당되는 경우 자동으로 페이지 매김을 처리합니다.

설치

  1. 가상 환경을 만들고 활성화하세요.

uv venv source .venv/bin/activate
  1. 종속성 설치:

uv pip install -e .

구성

기본 구성

MCP 설정에 서버를 추가합니다(예: claude_desktop_config.json 또는 cline_mcp_settings.json ):

{ "mcpServers": { "github": { "command": "/path/to/repo/.venv/bin/python", "args": ["-m", "pygithub_mcp_server"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token-here" } } } }

도구 그룹 구성

서버는 구성을 통해 도구 그룹을 선택적으로 활성화하거나 비활성화할 수 있도록 지원합니다. 이는 두 가지 방법으로 구성할 수 있습니다.

1. 구성 파일

JSON 구성 파일을 만듭니다(예: pygithub_mcp_config.json ):

{ "tool_groups": { "issues": {"enabled": true}, "repositories": {"enabled": true}, "pull_requests": {"enabled": false}, "discussions": {"enabled": false}, "search": {"enabled": true} } }

그런 다음 환경에서 이 파일을 지정하세요.

export PYGITHUB_MCP_CONFIG=/path/to/pygithub_mcp_config.json

2. 환경 변수

또는 환경 변수를 사용하여 도구 그룹을 구성합니다.

export PYGITHUB_ENABLE_ISSUES=true export PYGITHUB_ENABLE_REPOSITORIES=true export PYGITHUB_ENABLE_PULL_REQUESTS=false

기본적으로 issues 도구 그룹만 활성화됩니다. 자세한 구성 옵션은 README.config.md 참조하세요.

개발

테스트

이 프로젝트에는 포괄적인 테스트 모음이 포함되어 있습니다.

# Run all tests pytest # Run tests with coverage report pytest --cov # Run specific test file pytest tests/test_operations/test_issues.py # Run tests matching a pattern pytest -k "test_create_issue"

참고: 현재 많은 테스트가 실패하여 조사 중입니다. 이는 알려진 문제이며, 현재 적극적으로 해결 중입니다.

MCP Inspector로 테스트

MCP Inspector를 사용하여 개발 중에 MCP 도구를 테스트하세요.

source .venv/bin/activate # Ensure venv is activated npx @modelcontextprotocol/inspector -e GITHUB_PERSONAL_ACCESS_TOKEN=your-token-here uv run pygithub-mcp-server

MCP Inspector의 웹 UI를 사용하여 다음을 수행할 수 있습니다.

  • 사용 가능한 도구로 실험해보세요

  • 실제 GitHub 저장소로 테스트

  • 성공 및 오류 사례 확인

  • 문서 작업 페이로드

프로젝트 구조

tests/ ├── unit/ # Fast tests without external dependencies │ ├── config/ # Configuration tests │ ├── tools/ # Tool registration tests │ └── ... # Other unit tests └── integration/ # Tests with real GitHub API ├── issues/ # Issue tools tests └── ... # Other integration tests
src/ └── pygithub_mcp_server/ ├── __init__.py ├── __main__.py ├── server.py # Server factory (create_server) ├── version.py ├── config/ # Configuration system │ ├── __init__.py │ └── settings.py # Configuration management ├── tools/ # Modular tool system │ ├── __init__.py # Tool registration framework │ └── issues/ # Issue tools │ ├── __init__.py │ └── tools.py # Issue tool implementations ├── client/ # GitHub client functionality │ ├── __init__.py │ ├── client.py # Core GitHub client │ └── rate_limit.py # Rate limit handling ├── converters/ # Data transformation │ ├── __init__.py │ ├── parameters.py # Parameter formatting │ ├── responses.py # Response formatting │ ├── common/ # Common converters │ ├── issues/ # Issue-related converters │ ├── repositories/ # Repository converters │ └── users/ # User-related converters ├── errors/ # Error handling │ ├── __init__.py │ └── exceptions.py # Custom exceptions ├── operations/ # GitHub operations │ ├── __init__.py │ └── issues.py ├── schemas/ # Data models │ ├── __init__.py │ ├── base.py │ ├── issues.py │ └── ... └── utils/ # General utilities ├── __init__.py └── environment.py # Environment utilities

문제 해결

  1. 서버가 시작되지 않습니다:

    • MCP 설정에서 venv Python 경로 확인

    • 모든 요구 사항이 venv에 설치되어 있는지 확인하세요.

    • GITHUB_PERSONAL_ACCESS_TOKEN이 설정되고 유효한지 확인하세요.

  2. 빌드 오류:

    • uv build와 함께 --no-build-isolation 플래그를 사용하세요.

    • Python 3.10+가 사용되고 있는지 확인하세요.

    • 모든 종속성이 설치되었는지 확인하세요

  3. GitHub API 오류:

    • 토큰 권한 및 유효성 확인

    • 자세한 오류 추적을 위해 pygithub_mcp_server.log를 검토하세요.

    • 요금 제한이 초과되지 않았는지 확인하세요

종속성

  • 파이썬 3.10+

  • MCP 파이썬 SDK

  • 피단틱

  • 파이기트허브

  • UV 패키지 관리자

특허

MIT

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

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