Connect GitHub MCP with Claude Code: Step-by-Step Guide (2026)
To connect GitHub MCP with Claude Code, create a GitHub Personal Access Token (PAT), then add the server over remote HTTP with a single command: claude mcp add --transport http github https://api.githubcopilot.com/mcp/ -H "Authorization: Bearer YOUR_PAT". Run /mcp inside Claude Code to try it out. Do not use the npm package @modelcontextprotocol/server-github - it was deprecated back in 04/2025 and is the single most common cause of setup failures.
What is GitHub MCP with Claude Code (and what can it do)?
The GitHub MCP server is the bridge that lets Claude Code read and act on GitHub directly through natural language - no leaving the terminal, no manual copy-paste. MCP (Model Context Protocol) is an open standard that connects AI to external tools; if you are new to the concept, start with what MCP is and how it works.
Once connected, you can ask Claude to do things like: list your repos and open issues, create a new issue, open a pull request, review the code in a PR, search for code by description, or read a file inside a repo. Instead of opening a browser and clicking through GitHub, you type one sentence and Claude calls the GitHub API for you. That is what sets it apart from firing off individual gh commands: Claude understands the context of your whole session and picks the right tool on its own.
A real example: while fixing a bug, you can say "find the issue related to this timeout error and summarize the comments," and Claude will query GitHub, read the issue, and answer right in the terminal - no window-switching. After you patch it, you follow up with "open a PR from the current branch and reference that issue." The whole chain of actions happens in one conversation, keeping the context of the code you are working on. That is why a lot of devs wire up GitHub MCP as a default tool rather than toggling it on and off each time.
Before you start (checklist)
Before adding the server, do a quick check on the following:
- Claude Code is installed and runs in your terminal - if not, see how to install Claude Code.
- A GitHub account with access to the repos you want Claude to work on.
- Pick a connection method: Remote HTTP (recommended - fast, nothing to install) or Docker (if you want the server running locally on your machine). For most people, Remote HTTP is plenty.
- If you choose Docker: install Docker Desktop and have it open before you add the server.
This whole guide takes about 5-10 minutes if you go the Remote HTTP route.
Step 1 - Create a GitHub Personal Access Token (PAT)
GitHub MCP needs a token to call the API on your behalf. GitHub has two kinds of tokens: classic (broad scope-based permissions) and fine-grained (per-repo permissions). Use a fine-grained token because you can limit it to exactly the repos and permissions you need, which minimizes the damage if the token ever leaks:
- Go to GitHub -> your avatar -> Settings.
- Scroll to the bottom of the left menu and choose Developer settings.
- Choose Personal access tokens -> Fine-grained tokens -> Generate new token.
- Give it a name (for example
claude-code-mcp) and set a sensible expiration (30-90 days). - Under Repository access, choose Only select repositories and tick only the repos you want Claude to touch.
- Under Permissions -> Repository permissions, grant the minimum you need: Contents (read/write files), Issues, and Pull requests. If you work with an organization, add
read:org. - Click Generate token and copy the token right away.
Security warning: GitHub shows the token only once. Copy it and stash it somewhere safe (a password manager). Do NOT commit the token to a repo, and do not paste it into any git-tracked file. Only grant write access when you actually want Claude to create or edit content on its own.
Step 2 - Add the GitHub MCP server (recommended: Remote HTTP)
This is the fastest way and needs no Docker. Open a terminal, replace YOUR_PAT with the token you just created, and run:
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ -H "Authorization: Bearer YOUR_PAT"
If you prefer a JSON-style config (handy when you want it ready to copy), use this alternative:
claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer YOUR_PAT"}}'
Pick the config scope with the -s flag:
-s local(default): applies only to this machine, in the current directory.-s user: shared across all your projects - useful when you want GitHub MCP always available and the token kept out of any repo.-s project: saved to.mcp.jsonand shared with the whole team via git. Convenient for teams, but be careful: never let a real token land in this file.
For example, to share it across every project, add -s user to the end of the claude mcp add command above. The full syntax for claude mcp add is in the official Claude Code MCP documentation (updated 2026).
A note on OAuth: as of 08/2026, the OAuth flow is not yet fully supported for remote GitHub MCP on Claude Code, so using a PAT as shown above is the most reliable approach.
Step 3 (alternative) - Run GitHub MCP with Docker (local)
If you want the server running entirely on your machine (say, for full control or to run it in an isolated environment), use the official image ghcr.io/github/github-mcp-server. Make sure Docker Desktop is open, then run:
claude mcp add github -e GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_PAT -- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
When should you pick Docker over Remote HTTP? Here is a quick comparison:
| Criteria | Remote HTTP | Docker (local) |
|---|---|---|
| Extra install needed | No | Docker Desktop required |
| Setup speed | Fastest (one command) | Slower (pull the image) |
| Runs offline / isolated | No | Yes |
| Best for | Most users | Anyone who needs local control |
Do not use the deprecated npm package
This is the most common mistake. Plenty of old guides (in every language) still tell you to install
@modelcontextprotocol/server-githubvia npm. That community package was deprecated back in 04/2025 - following it leads to a server that will not connect or to cryptic errors. The correct approach in 2026 is remote HTTP or the official Docker image from the github/github-mcp-server repo (GitHub's official source, updated 2026).
Step 4 - Verify and try it out
After adding the server, confirm it shows "Connected":
claude mcp list
You should see github with a connected status. Next, open Claude Code and type:
/mcp
The /mcp command lists all the GitHub tools now available. Now try a few real prompts:
- "List my GitHub repos."
- "Create an issue in owner/repo titled: Improve the setup docs."
- "Summarize the open pull requests in this repo."
If Claude returns the right data and can create an issue, you are connected.
Troubleshooting common errors
Most GitHub MCP connection problems come down to three causes: a wrong token or missing permissions, using the old install method by mistake, or not restarting Claude Code after adding the server. If something is off, match your symptom against the table below:
| Symptom | Common cause | Fix |
|---|---|---|
| Server reports "failed to connect" | Token is wrong, expired, or missing a scope | Recreate the PAT with the right permissions (Contents/Issues/Pull requests), remove and re-add the server |
/mcp shows no tools | Claude Code not restarted, or wrong transport | Quit and reopen Claude Code; check the command uses --transport http |
| Docker error when adding the server | Docker Desktop is not open | Open Docker Desktop, wait until it is fully running, then rerun the command |
| 401 / 403 error | PAT on the wrong host or missing repo permissions | Confirm the token is for github.com; add the repo permissions to the PAT |
| Rate limit hit | Too many API calls in a short window | Wait a few minutes; batch fewer requests; an authenticated token has a higher limit than anonymous |
Token leaked into .mcp.json | Added with -s project | Revoke that token on GitHub, create a new one, re-add with -s user |
General tip: when in doubt, run claude mcp remove github and add it again from scratch - that clears up most config issues.
Security and least privilege (read-only, toolsets)
Giving an agent write access to GitHub is convenient, but there is real risk: a vague prompt could make Claude create an issue or PR you did not intend, and a leaked token with overly broad permissions would affect many repos. A few rules to stay safe:
- Grant a minimal token: select only the repos you need and only the permissions you use.
- Never commit tokens: prefer
-s userso the token stays out of any repo; if you must use-s project, pass the token via an environment variable instead of writing it in plain text. - Use read-only when you only need to read: the GitHub MCP server supports a read-only mode and lets you enable or disable individual toolsets - limit it so Claude can only read, not write, when you just want to review or look things up.
- Set a short token expiration and revoke it when you are done.
To be honest: no configuration is perfectly safe once you hand write access to an AI - keep the token scoped tightly and double-check important actions.
Next step: automate your git workflow with Claude Code
Once GitHub MCP is running, the natural next step is to let Claude handle the whole lifecycle of a change: create a branch, commit to a standard, open a PR, and review. That is the subject of automating your git workflow with Claude Code (link goes live when the article is published).
Want ready-made review + standardized PR skills? If you would rather not write each workflow yourself, the AgentKit kit for Claude Code bundles a set of skills and subagents for code review, PR creation, and git workflows (Engineer Kit $99 - the site lists no recurring fee). You can check AgentKit's pricing (20% off via link) if you want to save the time of building the process from scratch.
Frequently asked questions (FAQ)
Is GitHub MCP free?
The GitHub MCP server itself (both remote HTTP and the official Docker image) is free. You only need a GitHub account and a Personal Access Token. Actions still count toward your account's normal GitHub API rate limits.
Is Docker required?
No. The recommended method is remote HTTP - just one claude mcp add --transport http command, no Docker. Docker is only needed if you want the server running locally on your machine.
What scopes does the PAT need?
With a fine-grained token, grant at minimum Contents, Issues, and Pull requests on the specific repos you want to use. Add read:org if you work inside an organization. Do not grant more than you need.
How do I remove the GitHub MCP server?
Run claude mcp remove github. If the server was added under a different scope, specify that scope again (for example -s user) when removing it.
How is this different from the gh CLI?
gh is a command-line tool where you type each command yourself. GitHub MCP lets Claude call the GitHub API based on the context of the conversation - you make a request in natural language, Claude picks the tool and runs it, and it can chain that with other steps in the same session.
Does OAuth work yet?
As of 08/2026, OAuth is not yet fully supported for remote GitHub MCP on Claude Code, so a PAT remains the reliable, recommended way to connect.
Conclusion
In just four steps - create a PAT -> add the server over remote HTTP -> verify with claude mcp list and /mcp -> try it out - you have given Claude Code the ability to read and act on GitHub through natural language. The key points: use remote HTTP or the official Docker image, avoid the deprecated npm package, and keep your token tightly scoped and out of any repo. To understand the foundations more deeply, read what MCP is and how it works; to go further into automation, see the git workflow with Claude Code (link when live). Need the /mcp command and other slash commands? See slash commands in Claude Code.
Want Claude Code more capable right now? After wiring up GitHub MCP, you will quickly want ready-made skills for reviews, PR creation, and a standardized git workflow instead of building each one. AgentKit bundles those workflows for Claude Code.