feat(mcp): Git Operations MCP - GitHub Provider (Optional) #110

Open
opened 2026-01-06 19:19:38 +00:00 by cardosofelipe · 1 comment

Parent Issue

Part of #58 (Git Operations MCP Server)

Summary

Implement the GitHub provider using PyGithub for remote Git operations. This is a follow-up after Gitea provider is working.

Tasks

GitHubProvider Class (providers/github.py)

  • Create GitHubProvider class implementing GitProvider protocol
  • Implement API client with token authentication
  • Implement create_pull_request() method
  • Implement list_pull_requests() method
  • Implement get_pull_request() method
  • Implement merge_pull_request() method
  • Implement close_pull_request() method
  • Implement add_pr_comment() method
  • Implement add_pr_reviewer() method
  • Implement get_pr_diff() method
  • Implement list_branches() method
  • Implement create_branch() method
  • Implement delete_branch() method

GitHub-Specific Features

  • Handle GitHub's rate limiting (different limits than Gitea)
  • Add pagination support
  • Support GitHub Enterprise (custom base URL)

Provider Factory

  • Create ProviderFactory class
  • Auto-detect provider from repo URL
  • Support provider override in configuration
  • Cache provider instances per repository

Testing

  • Unit tests with mocked GitHub API
  • Test all PR operations
  • Test GitHub Enterprise support
  • Achieve >90% coverage

Acceptance Criteria

  • All GitHub API operations work correctly
  • Rate limiting handled properly
  • Provider factory auto-detects GitHub repos
  • GitHub Enterprise supported
  • All tests pass

Dependencies

  • Depends on: #108 (Gitea Provider) - patterns established

Labels

  • mcp
  • phase-2
  • backend
  • optional
## Parent Issue Part of #58 (Git Operations MCP Server) ## Summary Implement the GitHub provider using PyGithub for remote Git operations. This is a follow-up after Gitea provider is working. ## Tasks ### GitHubProvider Class (`providers/github.py`) - [ ] Create `GitHubProvider` class implementing `GitProvider` protocol - [ ] Implement API client with token authentication - [ ] Implement `create_pull_request()` method - [ ] Implement `list_pull_requests()` method - [ ] Implement `get_pull_request()` method - [ ] Implement `merge_pull_request()` method - [ ] Implement `close_pull_request()` method - [ ] Implement `add_pr_comment()` method - [ ] Implement `add_pr_reviewer()` method - [ ] Implement `get_pr_diff()` method - [ ] Implement `list_branches()` method - [ ] Implement `create_branch()` method - [ ] Implement `delete_branch()` method ### GitHub-Specific Features - [ ] Handle GitHub's rate limiting (different limits than Gitea) - [ ] Add pagination support - [ ] Support GitHub Enterprise (custom base URL) ### Provider Factory - [ ] Create `ProviderFactory` class - [ ] Auto-detect provider from repo URL - [ ] Support provider override in configuration - [ ] Cache provider instances per repository ### Testing - [ ] Unit tests with mocked GitHub API - [ ] Test all PR operations - [ ] Test GitHub Enterprise support - [ ] Achieve >90% coverage ## Acceptance Criteria - [ ] All GitHub API operations work correctly - [ ] Rate limiting handled properly - [ ] Provider factory auto-detects GitHub repos - [ ] GitHub Enterprise supported - [ ] All tests pass ## Dependencies - Depends on: #108 (Gitea Provider) - patterns established ## Labels - mcp - phase-2 - backend - optional
Author
Owner

Implementation Complete

The GitHub provider has been implemented with full feature parity to the Gitea provider:

Features Implemented

PR Operations:

  • Create PR with draft support
  • Get PR details
  • List PRs with state filtering
  • Merge PR (merge, squash, rebase strategies)
  • Update PR (title, body, state, labels, assignees)
  • Close PR without merging

Branch Operations:

  • Get branch info via API
  • Delete remote branch

Collaboration:

  • Add/remove labels
  • Add comments
  • List comments
  • Request reviewers

Error Handling:

  • Authentication errors (401)
  • Permission errors (403)
  • Rate limit detection
  • API errors with messages

Server Integration

  • Auto-detection of GitHub URLs (github.com or Enterprise)
  • Automatic token selection for clone/push based on repo URL
  • Health check includes GitHub connectivity status
  • GitHub provider initialized when GIT_OPS_GITHUB_TOKEN is set

Tests

39 comprehensive tests covering:

  • Connection and authentication
  • All PR operations
  • Branch operations
  • Label and comment operations
  • Error handling scenarios
  • PR data parsing

Commit: 1779239

Ready for code review.

## Implementation Complete The GitHub provider has been implemented with full feature parity to the Gitea provider: ### Features Implemented **PR Operations:** - Create PR with draft support - Get PR details - List PRs with state filtering - Merge PR (merge, squash, rebase strategies) - Update PR (title, body, state, labels, assignees) - Close PR without merging **Branch Operations:** - Get branch info via API - Delete remote branch **Collaboration:** - Add/remove labels - Add comments - List comments - Request reviewers **Error Handling:** - Authentication errors (401) - Permission errors (403) - Rate limit detection - API errors with messages ### Server Integration - Auto-detection of GitHub URLs (github.com or Enterprise) - Automatic token selection for clone/push based on repo URL - Health check includes GitHub connectivity status - GitHub provider initialized when `GIT_OPS_GITHUB_TOKEN` is set ### Tests 39 comprehensive tests covering: - Connection and authentication - All PR operations - Branch operations - Label and comment operations - Error handling scenarios - PR data parsing **Commit:** 1779239 Ready for code review.
Sign in to join this conversation.