Interact with GitHub directly from Claude Code. Read issues, open PRs, review code, search repositories, and manage releases — all without leaving the terminal or switching to a browser.
The gh CLI covers most local Git operations, but GitHub's API surface is much larger. With GitHub MCP:
- Claude can search code across your entire org, not just the current repo
- Issue triage, labeling, and commenting happen inside the same session as your code changes
- PR creation and review are part of the workflow, not a separate browser task
- Repository metadata, commit history, and file contents from any branch are queryable
- Cross-repo tasks (dependency audits, org-wide searches) become single prompts
npm install -g @modelcontextprotocol/server-githubAdd to ~/.claude.json or project .claude/mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-github-pat-here"
}
}
}
}create_or_update_file— create or update a file in a repositorysearch_repositories— search GitHub for repositories by keyword or topiccreate_repository— create a new repository under your account or orgget_file_contents— read a file from any branch of any accessible repopush_files— push multiple file changes as a single commitcreate_issue— open a new issue with title, body, labels, and assigneescreate_pull_request— open a PR with title, body, base, and head branchfork_repository— fork a repo to your accountcreate_branch— create a new branch from any reflist_commits— get the commit history for a branch or file pathlist_issues/get_issue— query issues by state, label, assignee, or milestoneadd_issue_comment— add a comment to any issue or PRsearch_code— search code across GitHub using the code search syntaxsearch_issues— search issues and PRs with GitHub's full query syntax
List all open issues in this repo labeled 'bug', sorted by comment count,
and give me a priority-ordered summary of what needs fixing first.
Read the PR description for #123 and write a detailed code review comment
on the authentication changes — focus on security and edge cases.
Search for all TODO and FIXME comments across the codebase using search_code,
then create a GitHub issue for each one in the TECH project,
assigned to me with the label 'tech-debt'.
Create a release branch called release/2.4.0 from main, then open a PR
back to main with the changelog for everything merged in the last two weeks.
Search all repos in our org for package.json files that depend on
lodash version 4.17.20 or earlier and list the affected repositories.
- Go to GitHub → Settings → Developer settings → Personal access tokens
- Choose Fine-grained tokens (recommended) or Tokens (classic)
- For classic tokens, select these scopes:
repo,read:org,read:user - For fine-grained tokens, grant Contents, Issues, Pull requests, and Metadata permissions on the repos you need
- Copy the token and set it as
GITHUB_PERSONAL_ACCESS_TOKENin the config block above
Use fine-grained tokens: Scope the token to specific repositories rather than your entire account. If the token leaks, the blast radius is contained.
Rate limits: The GitHub API allows 5,000 requests per hour for authenticated requests. Org-wide code searches count against a separate search rate limit (30 requests per minute) — cache results when running bulk operations.
Combining with local git: GitHub MCP handles the remote API surface; use your local git commands for staging, committing, and pushing. The two complement each other in the same session.
Code search syntax: search_code supports GitHub's full query syntax — language:typescript repo:myorg/myrepo "TODO" works exactly as it does in the GitHub UI. Use it for targeted queries rather than fetching whole files.
PR body quality: When using create_pull_request, give Claude the diff and the issue context and ask it to draft the PR body. The result will be more useful than a template-filled placeholder.