GitHub MCP Server: Connect Claude to Your Repositories

by Sandlabs Team, Founder, Sandlabs

You open Claude to ask about a bug. Then you switch to GitHub to read the issue. Back to Claude to draft a fix. Over to GitHub to check the PR diff. Back to Claude to refine. Tab, tab, tab — all day long.

This context-switching costs more than time. Every jump between tools breaks your train of thought, forces you to re-explain context, and slows down the feedback loop that makes AI-assisted development powerful.

The GitHub MCP server eliminates this entirely. It gives Claude direct access to your repositories, pull requests, issues, and code — so you can do everything through a single conversation.

What Is a GitHub MCP Server?

A GitHub MCP server is an official Model Context Protocol connector that gives AI assistants like Claude direct, structured access to the GitHub API. Instead of copying and pasting code snippets or describing issues manually, you talk to Claude and it reads, searches, and interacts with your repositories in real time.

The server acts as a bridge. Claude sends a request ("show me open issues labelled bug"), the MCP server translates that into the right GitHub API call, and returns the structured result back to Claude. All through a standardised protocol — no custom glue code required.

GitHub's official MCP server is open source, maintained by GitHub, and supports both GitHub.com and GitHub Enterprise.

What Can the GitHub MCP Server Do?

The GitHub MCP server exposes over 30 tools to your AI assistant. Here are the ones that matter most for day-to-day development:

Repository Operations

  • Search repositories by name, language, topic, or organisation
  • Get repository details including README, file tree, and metadata
  • Read file contents from any branch or commit
  • List and manage branches including creating new ones

Pull Requests

  • Create pull requests with title, body, and target branch
  • Review PR diffs and leave comments on specific lines
  • List open PRs filtered by author, label, or review status
  • Merge pull requests with your preferred merge strategy

Issues

  • Create and update issues with labels, assignees, and milestones
  • Search issues across repositories with complex filters
  • Add comments to existing issues
  • Triage and label issues based on content

Code Search

  • Search code across your entire organisation
  • Find references to functions, classes, or variables
  • Look up file history and blame information

Actions and CI/CD

  • List workflow runs and check their status
  • View workflow logs to debug failed builds
  • Trigger workflow dispatches for manual runs

Setting Up the GitHub MCP Server: Step-by-Step

Follow these steps to connect Claude to your GitHub repositories.

Step 1: Generate a GitHub Personal Access Token

You need a token so the MCP server can authenticate with the GitHub API on your behalf.

  1. Go to github.com/settings/tokens
  2. Click Generate new token (classic) or use a Fine-grained token for tighter scoping
  3. Select the scopes you need:
    • repo — full access to private and public repositories
    • read:org — read organisation membership (if working with org repos)
    • workflow — trigger and manage GitHub Actions (optional)
  4. Copy the token immediately. You will not see it again.

For fine-grained tokens, you can restrict access to specific repositories — a much better security posture for production use.

Step 2: Install the GitHub MCP Server

The official GitHub MCP server runs as a standalone process. You do not need to install it manually if you are using Docker or npx.

Using npx (recommended for quick setup):

npx -y @modelcontextprotocol/server-github

Using Docker:

docker pull ghcr.io/github/github-mcp-server

Step 3: Configure Claude Desktop

Add the GitHub MCP server to your Claude Desktop configuration file.

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

Using Docker instead:

{
  "mcpServers": {
    "github": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

Step 4: Configure Claude Code (CLI)

If you use Claude Code, add the server to your project settings:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

Save this in .claude/settings.json in your project root or in ~/.claude/settings.json for global access.

Step 5: Verify the Connection

Restart Claude Desktop (or your Claude Code session) and ask:

"List my recent repositories on GitHub."

If the connection works, Claude will return a list of your repos. If it fails, check that your token is valid and the server process is running.

Real Use Cases for the GitHub MCP Server

Setting it up is the easy part. Here is how engineering teams actually use it.

PR Reviews With Full Context

Instead of reading a PR diff in the browser and then asking Claude about it separately, you can do this in one conversation:

"Review the open PR #47 in our api-service repo. Focus on error handling and suggest improvements."

Claude reads the diff, understands the changes in context, and gives you a structured review — complete with line-specific suggestions. No copy-pasting. No lost context.

Issue Triage at Scale

If your team has a backlog of unlabelled issues, Claude can help:

"Look at the last 20 open issues in our frontend repo. Categorise them as bug, feature request, or question. Suggest priority labels."

Claude reads each issue, analyses the content, and gives you a triage summary. What used to take 30 minutes of manual scanning takes one prompt.

Code Search Across Repositories

Finding where a function is used across a large codebase is painful in the GitHub web UI. With the MCP server:

"Search for all usages of the processPayment function across our organisation's repositories."

Claude searches, returns the results with file paths and line numbers, and can explain how each usage works.

Documentation Generation

Point Claude at a module and let it generate documentation:

"Read the files in src/lib/auth/ in our main repo and generate API documentation for each exported function."

Claude reads the source code directly, understands the types and logic, and produces documentation that actually matches the implementation.

Automated Changelog Drafting

Before a release, you can ask:

"Look at all merged PRs since the v2.3.0 tag in our backend repo. Draft a changelog grouped by feature, fix, and chore."

Claude reads the PR titles, descriptions, and labels, then produces a structured changelog ready for your release notes.

Tips and Best Practices

Scope Your Tokens Tightly

Do not use a token with full admin access for an MCP server. Create a fine-grained token with only the permissions you need, scoped to specific repositories. This limits blast radius if the token is ever exposed.

Use Environment Variables for Tokens

Never hardcode tokens in configuration files that get committed to version control. Use environment variables or a secrets manager:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Then set GITHUB_TOKEN in your shell profile or secrets manager.

Be Specific in Your Prompts

The more context you give Claude, the better the results. Instead of "review this PR", try "review PR #47 in the api-service repo, focusing on SQL injection risks in the new query builder."

Combine With Other MCP Servers

The GitHub MCP server is powerful on its own, but it gets better when combined with other connectors. Pair it with a Slack MCP server to post PR summaries to channels, or connect a database MCP server to cross-reference issues with customer support tickets.

Rate Limits

The GitHub API has rate limits (5,000 requests per hour for authenticated users). For heavy usage across large organisations, monitor your consumption and consider caching strategies. The MCP server handles pagination automatically, but a single complex query can consume multiple API calls.

Security Considerations

Connecting an AI assistant to your code repositories requires careful security practices.

Token Storage

Your GitHub token gives the MCP server (and by extension, Claude) access to your code. Treat it with the same care as any other credential:

  • Never commit tokens to version control. Add your Claude config file to .gitignore if it contains tokens.
  • Rotate tokens regularly. Set a calendar reminder to regenerate tokens every 90 days.
  • Use fine-grained tokens scoped to specific repos and permissions rather than classic tokens with broad access.

Access Control

When using the GitHub MCP server in a team setting:

  • Each developer should use their own token, not a shared one. This preserves the audit trail of who performed which actions.
  • For organisation-wide deployments, consider using a GitHub App with installation tokens instead of personal access tokens.
  • Review which repositories each token can access. If a developer only works on frontend repos, their token should not have access to infrastructure repos.

Data Exposure

Be aware that when Claude reads your code through the MCP server, the code is processed by Anthropic's API. Review your organisation's data policies and Anthropic's data usage terms. For highly sensitive codebases, consider running the MCP server through a proxy that filters or redacts sensitive content.

Frequently Asked Questions

What is the difference between the GitHub MCP server and the Git MCP server?

The GitHub MCP server connects to the GitHub API — it handles pull requests, issues, code search, Actions, and other GitHub-specific features. A git MCP server connects to local Git repositories and handles commits, diffs, branches, and history. They solve different problems and can be used together: the git MCP server for local repo operations, the GitHub MCP server for platform-level interactions.

Can I use the GitHub MCP server with GitHub Enterprise?

Yes. Set the GITHUB_HOST environment variable to your GitHub Enterprise URL in the MCP server configuration. The server supports both GitHub.com and self-hosted GitHub Enterprise instances.

Does the GitHub MCP server support write operations like creating PRs and merging?

Yes. The server supports both read and write operations. You can create pull requests, merge them, open and close issues, add comments, create branches, and trigger workflows. Make sure your token has the appropriate scopes for write operations.

How do I limit which repositories Claude can access?

Use fine-grained personal access tokens. When generating the token, select "Only select repositories" and choose the specific repos you want Claude to access. This is the simplest and most secure approach.

What Comes Next

The GitHub MCP server is one of the most practical MCP server examples available today because it sits at the center of most engineering workflows. Once your team gets comfortable with it, the natural next step is building custom MCP connectors that connect Claude to your internal tools — deployment pipelines, feature flag systems, monitoring dashboards, and proprietary APIs.

The pattern is always the same: identify the context-switch, build the bridge, and let AI work with full context instead of fragments.


Need custom MCP integrations for your team? Whether it is connecting Claude to internal tools, building a git MCP server for your proprietary workflow, or deploying MCP servers at scale, we build these systems every day. Talk to us.

More articles

Claude Cowork vs Chat: What Merges, and the Key Dates

Chat and Cowork are becoming one Claude. Team turns on by default 1 December 2026, the separate experience retires 1 February 2027, and ZDR orgs are excluded.

Read more

Can an Australian Business Claim Its ChatGPT Profile? What Is Actually Available

OpenAI launched Businesses in ChatGPT on 10 November 2026. Business Agents are US-only, and local stores and restaurants can claim US listings only. Here is what an Australian business can do today.

Read more

Let's build something great together.

Melbourne, Australia — serving founders worldwide. [email protected]