How to Connect Claude Code to GitHub With the Official MCP Server

David IyaDavid Iya August 31, 2026 8 min read
A single monitor in a dim home office showing a soft pull-request diff with muted green and red line markers, a mechanical keyboard and a small branch-shaped keychain resting on the desk, warm evening light
Original image, Claude Code Club

How Do You Connect Claude Code to GitHub?

Connect Claude Code to GitHub by registering GitHub's own official remote MCP server, hosted at api.githubcopilot.com/mcp, using a GitHub personal access token for authentication. Generate a fine-grained token scoped to the specific repos you're working in, then run one command to register it: claude mcp add-json github with the token passed as a Bearer header. That's the whole setup, and it works the same way whether you're building inside the Claude Code desktop app or the CLI.

Once it's connected, Claude Code can read a repository's files and structure, search and browse open issues and pull requests, check the status of CI runs, and open or update issues and PRs as part of the same conversation you're already having about a build. It's a server GitHub built and runs themselves against their own API, the same pattern as [connecting Claude Code to Linear](/blog/connect-claude-code-to-linear) or Notion, not a community package reverse-engineered against endpoints that can change without notice.

Step One: Generate a Scoped Token, Not an All-Repo One

GitHub's remote server authenticates with a personal access token rather than a full browser OAuth login, so this step happens before you touch Claude Code at all. Go to github.com/settings/personal-access-tokens/new and create a fine-grained token, not a classic one. Fine-grained tokens let you pick exactly which repositories the token can see and exactly which permissions it has inside them, instead of handing over blanket access to everything in your account.

  1. Under Repository access, select Only select repositories and pick the ones you're actually building against, not every repo in the account.
  2. Under Permissions, grant Contents (read or read/write, depending on whether you want Claude Code opening PRs), Issues, and Pull requests. Skip anything you don't have a concrete reason to hand over.
  3. Set an expiration. A token that never expires is a liability sitting in your config months after the project that needed it wrapped up.

This is the same instinct as the Linear API key's read-only option, applied one step earlier: the access decision happens when you generate the token, not as a separate setting inside Claude Code. A token scoped to two repos with read and issue access can't reach a third repo or push a commit, no matter what you ask it to do.

Step Two: Register the Server

With the token copied, register the server from a terminal window, the same one-time step whether you build inside the desktop app or the CLI day to day.

  1. Run claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer YOUR_GITHUB_PAT"}}' with your real token in place of YOUR_GITHUB_PAT.
  2. Restart Claude Code so it picks up the new server.
  3. Run claude mcp list to confirm github shows up, or claude mcp get github for the full detail.

Don't hardcode the token into a file you might commit. Store it in a .env file, add that file to .gitignore, and reference it as an environment variable when you run the command, the same habit covered in [Claude Code environment variables: how to keep your API keys safe](/blog/claude-code-environment-variables).

What This Is Actually Good For

The obvious use is starting work from the real issue instead of retyping it, the same pattern as the Linear connection, but with the added value of GitHub also being where the code and the CI results already live. Claude Code can read an issue, look at the actual file it references, check whether the last CI run on a branch is green, and open a pull request when the change is ready, all without you narrating any of that context by hand.

  • Pull an issue's full description and comments as context before you start a change, instead of summarizing it into a prompt yourself and losing detail.
  • Ask Claude Code to check whether a specific pull request's CI checks passed before you tell a client it's ready, rather than clicking through to the Actions tab yourself.
  • Have Claude Code open a pull request with a real description once a change is done, instead of you writing the PR summary from a cold start after the session ends.

It doesn't replace reviewing the diff yourself before you merge anything, that habit is covered in [how I review Claude Code's output before I ship it](/blog/review-claude-code-output-before-you-ship). What it removes is the manual copy-paste tax between where the issue, the code, and the CI status already live and the session where you're actually building.

Desktop App Users: The One Thing to Know

Slack, Notion, and Linear's hosted MCP servers all support a one-click browser OAuth login the first time you connect, no token to generate. GitHub's remote server doesn't offer that yet inside Claude Code, in the desktop app or the CLI, which is why a personal access token is the standard route here rather than a fallback for people who'd rather skip the browser flow.

If you'd rather log in with your GitHub account instead of managing a token, GitHub also ships a local version of the server that runs through Docker and supports a real OAuth browser login on first use. It's a heavier setup, since it needs Docker installed and running, so I'd only reach for it if avoiding a token specifically matters to you, most builders are fine with the scoped token above.

Skip the Old Community Package

When Not to Bother With It

Skip the setup for a throwaway script or a repo you're not going back to. It earns its place the moment there's a real, actively-updated repo on the other end, open issues, a review process, CI checks that actually gate a merge, the kind of project where you'd otherwise be tabbing over to github.com every few minutes anyway.

Free Claude Code drops, straight to your inbox

Short, practical drops on skills, MCP, agents, prompts, and more. No spam, unsubscribe anytime.

Frequently asked questions

How do I connect Claude Code to GitHub?

Generate a fine-grained GitHub personal access token scoped to the repos you need, then register GitHub's official remote MCP server with claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer YOUR_GITHUB_PAT"}}'. Restart Claude Code and run claude mcp list to confirm it's connected.

Do I need a GitHub personal access token, or can I just log in with OAuth?

You need a token for the remote server. Unlike Slack, Notion, and Linear, GitHub's remote MCP connection doesn't yet support a one-click browser OAuth login inside Claude Code. A local Docker-based version of the server does support OAuth login instead, but it's a heavier setup most builders don't need.

Can Claude Code see every repo in my GitHub account once it's connected?

Only if you scope the token that way, which you shouldn't. A fine-grained personal access token lets you pick exactly which repositories it can see and exactly which permissions it has in each one, so the real access decision happens when you generate the token, not as a separate setting afterward.

Can Claude Code open pull requests, or is it read-only?

It can do both, depending on the permissions you granted the token. With Contents and Pull requests write access, Claude Code can open and update PRs directly. Grant read-only permissions instead if you want it limited to reading issues, code, and CI status.

What if claude mcp add-json fails or returns an error?

On older Claude Code versions or on Windows, add-json can fail with an Invalid input error. Use the legacy syntax instead: claude mcp add --transport http github https://api.githubcopilot.com/mcp -H "Authorization: Bearer YOUR_GITHUB_PAT". It registers the identical server.

Last reviewed by David Iya on August 31, 2026

David Iya

Written by

David Iya

Forbes 30 Under 30 · Y Combinator

Keep reading

Ready to build it yourself?

Join Claude Code Club, the #1 community for learning claude code, for $9/month.

← Back to the blog