How to Connect the GitHub MCP Server to Claude Code (Complete Setup Guide)

Last Verified: September 2026 — commands and maintenance status checked against live GitHub sources

The GitHub MCP server gives Claude Code direct access to your repositories — issues, pull requests, commits, CI status, and code search — without you copy-pasting context back and forth. GitHub maintains an official remote server, so there’s nothing to build or run locally: you authenticate once with a personal access token and Claude Code talks to it over HTTP.

Quick Start

Connect the official remote server with one command, once you have a token (see Step 1 below if you don’t have one yet):

claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer YOUR_GITHUB_PAT"

Restart Claude Code, then run /mcp to confirm it shows as connected. Total time: about 3 minutes, including creating the token.

⚡ Copy This Prompt: Let Claude Code Install and Verify It For You

Once you have a token, skip the manual steps below and hand the rest to the agent:

You have access to the `claude mcp` CLI in this project. Do the following and report back — do not tell me it's done unless step 3 actually confirms it:

1. Run `claude mcp list` to see what's already configured.
2. Add the GitHub MCP server: `claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer [MY GITHUB PAT]"` (I'll paste my actual token in place of the bracket).
3. Run `claude mcp list` again and confirm github shows as Connected.
4. Prove it works: list the open issues in this repository using the GitHub MCP tools. If step 3 or 4 fails, tell me the exact error and the most likely cause (bad token, missing scope, wrong URL) instead of reporting success.

This works because Claude Code can run its own claude mcp commands and then immediately call the newly connected server — so it proves real repo access instead of just confirming a config entry exists.

What You’ll Need

Requirement Why You Need It Time
Claude Code installed Provides the claude mcp command used to register the server 0 min
A GitHub personal access token (PAT) Authenticates every request — the remote server has no browser-based OAuth login yet ~2 min
Repo access on that token The token needs to actually see the repos you want Claude Code to work with included above

Step-by-Step Setup

Prefer to do it by hand instead of delegating to the agent? Here’s the manual version.

Step 1 — Create a GitHub personal access token

~2 min

In GitHub, go to Settings → Developer settings → Personal access tokens → Fine-grained tokens, and generate one scoped to the specific repositories you want Claude Code to access (avoid granting it every repo on your account unless you actually need that).

Step 2 — Add the remote server

~1 min

Note the trailing slash on the URL — leaving it off is a common source of connection errors:

claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer YOUR_GITHUB_PAT"

Step 3 — Or run the local Docker version instead

~2 min

If you’d rather not send requests to GitHub’s hosted endpoint, GitHub also publishes an official Docker image you can run locally:

claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_GITHUB_PAT \
  -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server

The remote version above is faster to set up and updates automatically, so it’s the better default unless you have a specific reason to self-host.

Step 4 — Restart and approve

~1 min

Run claude to start a fresh session. Newly added servers need a restart (or the /mcp panel refresh) before Claude Code can see their tools.

What Each Piece Does

Piece What It Does
Remote HTTP endpoint GitHub-hosted server at api.githubcopilot.com/mcp/ — no local process, always up to date
Authorization: Bearer header Passes your PAT with every request — this is what scopes what Claude Code can actually see and do
Fine-grained token scope Limits access to specific repos instead of your whole account — the safer default
Local Docker alternative Same tools, but self-hosted — useful if you can’t send traffic to GitHub’s hosted endpoint

Verify the Connection

claude mcp list
✔ github    Connected
! github    Needs authentication
github    Failed to connect

A “Connected” status only confirms the handshake, not that the token can actually see your repos. Confirm real access with an in-session prompt:

Using the GitHub MCP tools, list the 5 most recently updated issues in [owner/repo].

If it comes back with real issue titles instead of an auth or permissions error, the token and scope are both working.

Common Mistakes to Avoid

  • Dropping the trailing slash on the URL. /mcp without the final / is a frequent cause of connection failures on the remote endpoint.
  • Granting a classic token full account access. Use a fine-grained token scoped to only the repos Claude Code actually needs to touch.
  • Hardcoding the token directly in a committed .mcp.json. Keep it in an environment variable or add the server at user scope instead of project scope if the config would otherwise be shared.
  • Assuming “Connected” means full repo access. The handshake can succeed while the token still lacks scope for a specific repo — test with a real query, not just claude mcp list.
  • Not restarting after adding the server. Claude Code needs a fresh session or an /mcp panel refresh to pick up a newly added server.

Q&A

Can I use browser-based OAuth instead of a token?

Not yet for GitHub’s remote server — unlike some other MCP servers, it currently requires a personal access token rather than a one-click OAuth login inside Claude Code.

Should I use the remote server or the Docker version?

Remote is the better default — it’s faster to set up, needs no local process, and updates automatically. Use Docker only if you specifically can’t send traffic to GitHub’s hosted endpoint.

What can Claude Code actually do with this connected?

Read and search code, open and comment on issues and pull requests, check CI/workflow status, and browse commit history — scoped to whatever your token can access.

Why does it show “Needs authentication”?

Usually a missing, expired, or incorrectly scoped token. Regenerate it in GitHub settings and re-run the claude mcp add command with the new value.

Can I remove it later?

Yes — claude mcp remove github deletes it from the config.

Official Resources

Comments

One response to “How to Connect the GitHub MCP Server to Claude Code (Complete Setup Guide)”

  1. […] already have their own dedicated setup guides — see Playwright MCP, GitHub MCP, and Context7 […]

Leave a Reply

Your email address will not be published. Required fields are marked *