Guidelines for handling GitHub operations with fallback strategies
when MCP tools are unavailable or failing.
Always try MCP tools first, fall back to GitHub CLI if they fail
- Structured data responses
- Better error handling
- Integrated with the system
- More reliable when MCP is down
- Direct GitHub API access
- Can handle complex queries
get_pull_request
github
get_pull_request
{
"owner": "RooCodeInc",
"repo": "Roo-Code",
"pullNumber": 123
}
]]>
gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFiles
true
get_pull_request_diff
github
get_pull_request_diff
{
"owner": "RooCodeInc",
"repo": "Roo-Code",
"pullNumber": 123
}
]]>
gh pr diff [PR_NUMBER] --repo [owner]/[repo]
.roo/temp/pr-[PR_NUMBER]/pr.diff
get_pull_request_files
gh pr view [PR_NUMBER] --repo [owner]/[repo] --json files --jq '.files[].path'
Lists all files changed in the PR
get_pull_request_comments
gh pr view [PR_NUMBER] --repo [owner]/[repo] --json comments --jq '.comments'
get_pull_request_reviews
gh pr view [PR_NUMBER] --repo [owner]/[repo] --json reviews --jq '.reviews'
gh pr checkout [PR_NUMBER] --repo [owner]/[repo]
No MCP equivalent - always use CLI
add_issue_comment
PRs use same comment system as issues
gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body-file [file_path]
gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body "[comment_text]"
1. create_pending_pull_request_review
2. add_pull_request_review_comment_to_pending_review (multiple times)
3. submit_pending_pull_request_review
gh pr review [PR_NUMBER] --repo [owner]/[repo] --comment --body-file [review_file]
Error message contains "MCP server" or "github server not found"
Immediately switch to CLI commands for all operations
Error contains "rate limit" or status code 403
1. Wait briefly (30 seconds)
2. Retry with CLI using --limit flag
3. Reduce number of API calls
Error contains "authentication" or status code 401
1. Inform user about auth issue
2. Suggest checking gh auth status
3. Continue with available data
Error contains "not found" or status code 404
1. Verify PR number and repository
2. Ask user to confirm details
3. Check if PR is from a fork
Always save API responses to temp files
Preserve data in case of failures
Use jq or built-in JSON parsing
gh pr view --json files --jq '.files[].path'
For PRs with many files, process in batches
More than 50 files
gh pr view [number] --json [fields]
number, title, author, state, body, url,
headRefName, baseRefName, files, additions,
deletions, changedFiles, comments, reviews
gh pr checkout [number]
gh pr diff [number]
gh pr comment [number] --body "[text]"
gh pr review [number] --comment --body "[text]"
gh issue view [number] --json [fields]
number, title, body, author, state,
labels, assignees, milestone
Always specify --repo to avoid ambiguity
Use --json for structured data
Save command outputs to temp files
Check gh auth status before operations
Handle both personal repos and org repos