PyGithub MCP Server
PyGithub MCP サーバー
PyGithubを介してGitHub APIとやり取りするためのツールを提供するモデルコンテキストプロトコルサーバー。このサーバーにより、AIアシスタントは課題、リポジトリ、プルリクエストの管理といったGitHub操作を実行できるようになります。
特徴
モジュラーツールアーキテクチャ:
有効化/無効化できる設定可能なツールグループ
ドメイン固有の組織(問題、リポジトリなど)
ファイルまたは環境変数による柔軟な設定
モジュール設計による明確な関心の分離
一貫したパターンによる簡単な拡張
完全な GitHub の問題管理:
問題の作成と更新
問題の詳細を取得し、リポジトリの問題を一覧表示する
コメントの追加、一覧表示、更新、削除
問題ラベルを管理する
担当者とマイルストーンを管理する
スマートなパラメータ処理:
オプションパラメータのための動的なkwargsの構築
GitHubオブジェクトの適切な型変換
すべての入力パラメータの検証
無効な入力に対するエラーメッセージをクリアする
堅牢な実装:
PyGithub 経由のオブジェクト指向 GitHub API のインタラクション
一元化されたGitHubクライアント管理
適切なエラー処理とレート制限
MCPツールによるクリーンなAPI抽象化
包括的なページネーションサポート
デバッグのための詳細なログ
Related MCP server: GitHub MCP Server
ドキュメント
包括的なガイドは、docs/guides ディレクトリで入手できます。
error-handling.md: エラーの種類、処理パターン、ベストプラクティス
security.md: 認証、アクセス制御、コンテンツセキュリティ
tool-reference.md: 例を含む詳細なツールドキュメント
PyGithub MCP サーバーの使用に関する詳細については、これらのガイドを参照してください。
使用例
発行業務
問題の作成
{
"owner": "username",
"repo": "repository",
"title": "Issue Title",
"body": "Issue description",
"assignees": ["username1", "username2"],
"labels": ["bug", "help wanted"],
"milestone": 1
}問題の詳細を取得する
{
"owner": "username",
"repo": "repository",
"issue_number": 1
}問題の更新
{
"owner": "username",
"repo": "repository",
"issue_number": 1,
"title": "Updated Title",
"body": "Updated description",
"state": "closed",
"labels": ["bug", "wontfix"]
}コメント操作
コメントを追加する
{
"owner": "username",
"repo": "repository",
"issue_number": 1,
"body": "This is a comment"
}リストコメント
{
"owner": "username",
"repo": "repository",
"issue_number": 1,
"per_page": 10
}コメントの更新
{
"owner": "username",
"repo": "repository",
"issue_number": 1,
"comment_id": 123456789,
"body": "Updated comment text"
}ラベル操作
ラベルの追加
{
"owner": "username",
"repo": "repository",
"issue_number": 1,
"labels": ["enhancement", "help wanted"]
}ラベルの削除
{
"owner": "username",
"repo": "repository",
"issue_number": 1,
"label": "enhancement"
}すべての操作はオプションのパラメータをインテリジェントに処理します。
API呼び出しには提供されたパラメータのみが含まれます
プリミティブ型を GitHub オブジェクトに変換します (例: マイルストーン番号をマイルストーン オブジェクトに変換)
無効なパラメータに対して明確なエラーメッセージを表示します
該当する場合はページ区切りを自動的に処理します
インストール
仮想環境を作成してアクティブ化します。
uv venv
source .venv/bin/activate依存関係をインストールします:
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"
}
}
}
}ツールグループの構成
サーバーは、設定を通じてツールグループを個別に有効化または無効化できます。これは以下の2つの方法で設定できます。
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.json2. 環境変数
または、環境変数を使用してツール グループを構成します。
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 インスペクターを使用して開発中に MCP ツールをテストします。
source .venv/bin/activate # Ensure venv is activated
npx @modelcontextprotocol/inspector -e GITHUB_PERSONAL_ACCESS_TOKEN=your-token-here uv run pygithub-mcp-serverMCP Inspector の Web 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 testssrc/
└── 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トラブルシューティング
サーバーの起動に失敗しました:
MCP設定でvenv Pythonパスを確認する
すべての要件がvenvにインストールされていることを確認する
GITHUB_PERSONAL_ACCESS_TOKENが設定され有効であることを確認します
ビルド エラー:
uv ビルドで --no-build-isolation フラグを使用する
Python 3.10以降が使用されていることを確認する
すべての依存関係がインストールされていることを確認する
GitHub API エラー:
トークンの権限と有効性を確認する
詳細なエラートレースはpygithub_mcp_server.logで確認してください。
レート制限を超えていないことを確認する
依存関係
Python 3.10以上
MCP Python SDK
ピダンティック
パイGitHub
UV パッケージ マネージャー
ライセンス
マサチューセッツ工科大学
Available Tools
19 toolsadd_issue_commentC
Add a comment to an issue.
Args:
params: Parameters for adding a comment including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number to comment on
- body: Comment text
Returns:
Created comment details from GitHub API
Inputs: params (required).
add_issue_labelsC
Add labels to an issue.
Args:
params: Parameters for adding labels including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number
- labels: Labels to add
Returns:
Updated list of labels from GitHub API
Inputs: params (required).
create_branchC
Create a new branch in a GitHub repository.
Args:
params: Dictionary with branch parameters
- owner: Repository owner (username or organization)
- repo: Repository name
- branch: Name for new branch
- from_branch: Source branch (optional, defaults to repo default)
Returns:
MCP response with branch creation result
Inputs: params (required).
create_issueA
Create a new issue in a GitHub repository.
Args:
params_dict: Parameters for creating an issue including:
- owner: Repository owner (user or organization)
- repo: Repository name
- title: Issue title
- body: Issue description (optional)
- assignees: List of usernames to assign
- labels: List of labels to add
- milestone: Milestone number (optional)
Returns:
Created issue details from GitHub API
Inputs: params_dict (required).
create_or_update_fileA
Create or update a file in a GitHub repository.
Args:
params: Dictionary with file parameters
- owner: Repository owner (username or organization)
- repo: Repository name
- path: Path where to create/update the file
- content: Content of the file
- message: Commit message
- branch: Branch to create/update the file in
- sha: SHA of file being replaced (for updates, optional)
Returns:
MCP response with file creation/update result
Inputs: params (required).
create_repositoryB
Create a new GitHub repository.
Args:
params: Dictionary with repository creation parameters
- name: Repository name
- description: Repository description (optional)
- private: Whether the repository should be private (optional)
- auto_init: Initialize repository with README (optional)
Returns:
MCP response with created repository details
Inputs: params (required).
delete_issue_commentC
Delete an issue comment.
Args:
params: Parameters for deleting a comment including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number containing the comment
- comment_id: Comment ID to delete
Returns:
Empty response on success
Inputs: params (required).
fork_repositoryC
Fork an existing GitHub repository.
Args:
params: Dictionary with fork parameters
- owner: Repository owner (username or organization)
- repo: Repository name
- organization: Organization to fork to (optional)
Returns:
MCP response with forked repository details
Inputs: params (required).
get_file_contentsB
Get contents of a file in a GitHub repository.
Args:
params: Dictionary with file parameters
- owner: Repository owner (username or organization)
- repo: Repository name
- path: Path to file/directory
- branch: Branch to get contents from (optional)
Returns:
MCP response with file content data
Inputs: params (required).
get_issueC
Get details about a specific issue.
Args:
params: Parameters for getting an issue including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number to retrieve
Returns:
Issue details from GitHub API
Inputs: params (required).
get_repositoryB
Get details about a GitHub repository.
Args:
params: Dictionary with repository parameters
- owner: Repository owner (username or organization)
- repo: Repository name
Returns:
MCP response with repository details
Inputs: params (required).
list_commitsC
List commits in a GitHub repository.
Args:
params: Dictionary with commit parameters
- owner: Repository owner (username or organization)
- repo: Repository name
- page: Page number (optional)
- per_page: Results per page (optional)
- sha: Branch name or commit SHA (optional)
Returns:
MCP response with list of commits
Inputs: params (required).
list_issue_commentsB
List comments on an issue.
Args:
params: Parameters for listing comments including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number
- since: Filter by date (optional)
- page: Page number (optional)
- per_page: Results per page (optional)
Returns:
List of comments from GitHub API
Inputs: params (required).
list_issuesA
List issues from a GitHub repository.
Args:
params: Parameters for listing issues including:
- owner: Repository owner (user or organization)
- repo: Repository name
- state: Issue state (open, closed, all)
- labels: Filter by labels
- sort: Sort field (created, updated, comments)
- direction: Sort direction (asc, desc)
- since: Filter by date
- page: Page number for pagination
- per_page: Number of results per page (max 100)
Returns:
List of issues from GitHub API
Inputs: params (required).
push_filesA
Push multiple files to a GitHub repository in a single commit.
Args:
params: Dictionary with file parameters
- owner: Repository owner (username or organization)
- repo: Repository name
- branch: Branch to push to
- files: List of files to push, each with path and content
- message: Commit message
Returns:
MCP response with file push result
Inputs: params (required).
remove_issue_labelB
Remove a label from an issue.
Args:
params: Parameters for removing a label including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number
- label: Label to remove
Returns:
Empty response on success or error if label doesn't exist
Inputs: params (required).
search_repositoriesC
Search for GitHub repositories.
Args:
params: Dictionary with search parameters
- query: Search query
- page: Page number for pagination (optional)
- per_page: Results per page (optional)
Returns:
MCP response with matching repositories
Inputs: params (required).
update_issueB
Update an existing issue.
Args:
params: Parameters for updating an issue including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number to update
- title: New title (optional)
- body: New description (optional)
- state: New state (optional)
- labels: New labels (optional)
- assignees: New assignees (optional)
- milestone: New milestone number (optional)
Returns:
Updated issue details from GitHub API
Inputs: params (required).
update_issue_commentB
Update an issue comment.
Args:
params: Parameters for updating a comment including:
- owner: Repository owner (user or organization)
- repo: Repository name
- issue_number: Issue number containing the comment
- comment_id: Comment ID to update
- body: New comment text
Returns:
Updated comment details from GitHub API
Inputs: params (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Most tools have distinct purposes targeting specific GitHub resources and actions, like issues, files, repositories, and branches. However, there is some overlap between 'create_or_update_file' and 'push_files' as both handle file modifications, which could cause confusion. All other tools are clearly separated by their target resources.
All tool names follow a consistent snake_case pattern with clear verb_noun structures, such as 'create_issue', 'list_commits', and 'update_issue_comment'. The naming is uniform across all 19 tools, making them predictable and easy to understand for an agent.
With 19 tools, the count is slightly high but reasonable for a comprehensive GitHub API server covering issues, repositories, files, and branches. It provides extensive functionality without being overwhelming, though it borders on being heavy compared to typical well-scoped servers.
The tool set offers complete CRUD and lifecycle coverage for key GitHub domains, including issues (create, get, update, delete, comment, label), repositories (create, get, fork, search), files (create/update, get, push), and branches (create). There are no obvious gaps, enabling agents to handle common workflows effectively.
Related MCP Connectors
Access the GitHub API, enabling file operations, repository management, search functionality, and…
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Manage repositories, users, releases, and automate GitHub workflows
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables interaction with GitHub through the GitHub API, supporting file operations, repository management, advanced search, and issue tracking with comprehensive error handling and automatic branch creation.1-
- AlicenseAqualityNot gradedmaintenanceEnables AI agents to interact with GitHub repositories through the GitHub REST API for managing files, issues, and repository metadata. It supports both read operations like searching code and write operations such as creating repositories and updating issue comments.9-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with GitHub repositories, issues, pull requests, code, and more through a comprehensive set of tools.-
- AlicenseCqualityDmaintenanceEnables comprehensive interaction with the GitHub API for managing repositories, issues, pull requests, commits, and GitHub Actions workflows through natural language.20MIT