MCP.so
Sign In
Back to blog

How to Install GitHub MCP in Claude Code (Remote or Local)

Oct 15, 2026MCP.so TeamMCP.so Team

How to install GitHub MCP in Claude Code: add the official remote server with a PAT or run it locally with Docker OAuth, then set toolsets and read-only.

The Short Answer

To install GitHub MCP in Claude Code, create a GitHub personal access token, then run claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header "Authorization: Bearer $GITHUB_PAT", start claude and check that github shows a checkmark in /mcp. That connects GitHub's official hosted server, so there is nothing to install or keep updated.

If you would rather not manage a token, run the server locally with Docker instead: on first use it opens a GitHub login in your browser and keeps the token in memory only. Both options use the official GitHub MCP server from github/github-mcp-server.

Remote or Local?

Remote (hosted by GitHub)Local (Docker or binary)
Endpointhttps://api.githubcopilot.com/mcp/runs on your machine over stdio
Auth in Claude CodePAT in an Authorization headerBuilt-in OAuth login or a PAT
Needs DockerNoDocker, or the release binary
UpdatesAutomaticPull the image or binary yourself
Extra toolsRemote-only toolsets such as copilot_spacesCore toolsets
Choose tools withURL path or X-MCP-* headersGITHUB_TOOLSETS, --toolsets
GitHub Enterprise ServerNot covered hereSupported via the local server

Most people should start with remote. Choose local when you want OAuth instead of a long-lived token, need GitHub Enterprise Server, or must keep traffic on your machine.

Prerequisites

  • Claude Code installed. Open it inside your project directory so the configuration is scoped clearly, as GitHub's own guide recommends.
  • A GitHub personal access token for the remote server or a PAT-based local setup. Create one at github.com/settings/personal-access-tokens/new.
  • Docker, installed and running, for the local Docker option.

Creating the token

Grant only what you need. GitHub's README lists these classic scopes as a baseline:

ScopeWhy
repoRepository, issue and pull request operations
read:orgOrganization and team access
read:packagesDocker image access

With a fine-grained token, pick the specific repositories and the permissions that match the toolsets you plan to enable. Your organization may also restrict or require approval for PATs. Use separate tokens per project, rotate them, and never commit them.

Keep the token out of your shell history by putting it in an environment variable or a gitignored .env file:

export GITHUB_PAT="your_token_here"   # placeholder, not a real token

Option 1: Remote Server (Recommended)

Step 1: Add the server

The form from the Claude Code MCP docs:

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

GitHub's Claude install guide uses add-json for Claude Code 2.1.1 and newer:

claude mcp add-json github \
  '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer '"$GITHUB_PAT"'"}}'

Both save the same thing. Your shell replaces $GITHUB_PAT with the real value before Claude Code sees it, so the token is stored in Claude Code's config, not the variable name.

Step 2: Choose a scope

ScopeFlagStored inUse when
local (default)none~/.claude.json, this project onlyone repo, just you
user--scope user~/.claude.json, all projectsyou want GitHub everywhere (most common)
project--scope project.mcp.json in the repothe whole team should get it

For project scope, never paste the token into .mcp.json. Claude Code expands environment variables in that file, so commit this instead and let each teammate set GITHUB_PAT themselves:

{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer ${GITHUB_PAT}"
      }
    }
  }
}

What about OAuth on the remote server?

GitHub's README notes that OAuth on the remote server requires each host app to have a registered GitHub App or OAuth App, and that any host supporting remote servers can use PAT authentication. GitHub's Claude guide therefore uses a PAT. If you want browser login instead of a token, the local server below has OAuth built in.

Option 2: Local Server with Docker

OAuth login (no token)

The official image ships with GitHub's OAuth app credentials, so on github.com you provide nothing. Publish a fixed callback port to loopback:

claude mcp add github -e GITHUB_OAUTH_CALLBACK_PORT=8085 -- \
  docker run -i --rm -p 127.0.0.1:8085:8085 \
  -e GITHUB_OAUTH_CALLBACK_PORT ghcr.io/github/github-mcp-server

On the first tool call the server opens GitHub's authorization page. The token is kept in memory only, so expect to sign in again after the server restarts.

With a PAT

A PAT takes precedence over OAuth:

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

Note where -e appears: once before -- (Claude Code sets the variable) and once inside the docker run command (Docker passes it into the container).

Without Docker: the release binary

Download a binary from the releases page and put it on your PATH. With an official build, OAuth needs no flags and picks a random loopback port:

claude mcp add github -- github-mcp-server stdio

Or with a PAT, as GitHub's guide shows:

claude mcp add-json github \
  '{"command":"github-mcp-server","args":["stdio"],"env":{"GITHUB_PERSONAL_ACCESS_TOKEN":"YOUR_GITHUB_PAT"}}'

Toolsets, Read-Only and Lockdown

By default the server enables the context, repos, issues, pull_requests and users toolsets. Enabling only what you need helps Claude pick the right tool and keeps context small. Other toolsets include actions, code_security, dependabot, discussions, gists, notifications, orgs, projects, labels and more; all enables everything.

SettingRemote serverLocal server
Pick toolsetsX-MCP-Toolsets: repos,issues header, or a toolset URL like https://api.githubcopilot.com/mcp/x/issuesGITHUB_TOOLSETS="repos,issues" or --toolsets
Pick single toolsX-MCP-Tools headerGITHUB_TOOLS or --tools
Read-onlyX-MCP-Readonly: true, or add /readonly to the URLGITHUB_READ_ONLY=1 or --read-only
LockdownX-MCP-Lockdown: trueGITHUB_LOCKDOWN_MODE=1 or --lockdown-mode
Early features/insiders URL or X-MCP-Insiders: trueGITHUB_INSIDERS=true or --insiders

A read-only remote setup limited to repos, issues and pull requests, as a .mcp.json entry:

{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer ${GITHUB_PAT}",
        "X-MCP-Toolsets": "repos,issues,pull_requests",
        "X-MCP-Readonly": "true"
      }
    }
  }
}

Lockdown mode hides content in public repositories from authors without push access. It is a best-effort filter against prompt injection from untrusted issues and comments, not a security boundary, but it is worth turning on when Claude reads public repos. See MCP security best practices.

Verify the Connection

claude mcp list
claude mcp get github

Inside a session, /mcp should show github with a checkmark. claude mcp add does not validate credentials, so a wrong token is accepted at add time and only fails here, with a 401 in the failure detail.

Example Prompts

  • "List the open pull requests in this repo and summarize what each one changes."
  • "Read issue 123, find the code it refers to, and propose a fix."
  • "Why did the latest GitHub Actions run on main fail? Show me the failing step."
  • "Create a branch, commit the changes we just made, and open a draft PR that links issue 123."
  • "Review PR 45 and leave comments on anything that looks risky."
  • "Are there open Dependabot or code scanning alerts in this repo?"

The last two need the actions, dependabot or code_security toolsets enabled, plus matching token permissions.

Troubleshooting

SymptomLikely causeFix
✘ with a 401 in /mcpMissing, expired or wrong tokenCreate a new PAT, then claude mcp remove github and add it again
403 errors on some repos or orgsToken lacks permissions, or org restricts PATsAdd the scopes or repositories; ask an org owner to approve the token
add-json returns Invalid input (Windows)Known quoting issueUse the claude mcp add --transport http form
PowerShell: missing required argument 'name'Argument orderPut github right after claude mcp add
Docker server fails to startDocker not running, or image not pulledStart Docker Desktop; run docker pull ghcr.io/github/github-mcp-server
Tool you expect is missingToolset not enabled, or read-only onAdd the toolset via header, URL or GITHUB_TOOLSETS
Large-output warnings on big diffsTool output too longAsk for one file at a time, or raise MAX_MCP_OUTPUT_TOKENS

Do you already use the gh CLI? Claude Code can call it through the shell, and it handles many tasks without MCP. The MCP server earns its place when you want structured tools, toolset limits, read-only mode and lockdown instead of open shell access.

Next Steps

With GitHub connected, add servers that feed it work: Playwright MCP to verify a fix in the browser before opening the PR, or Supabase MCP for database changes. Browse more developer tools in the MCP server directory, and see the Claude Code MCP guide for scopes, OAuth and managing servers.

Frequently asked questions

How do I add the GitHub MCP server to Claude Code?

Create a GitHub personal access token, then run 'claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --header' with an 'Authorization: Bearer' value containing your token. Start Claude Code and check in /mcp that github shows a checkmark.

Can I use the GitHub MCP server in Claude Code without a personal access token?

Yes, run the local server with Docker or the release binary. The official build has OAuth built in, so it opens a GitHub login in your browser on first use and keeps the token in memory only.

Which token scopes does the GitHub MCP server need?

GitHub suggests repo for repository, issue and pull request work, read:org for organization access and read:packages for images. Grant only what the toolsets you enable require, and prefer fine-grained tokens limited to specific repositories.

How do I make the GitHub MCP server read-only?

On the remote server, send the header X-MCP-Readonly with the value true or add /readonly to the URL. On the local server, set GITHUB_READ_ONLY=1 or pass --read-only.