本文以英文发布。
Connect Private GitHub Repos to Claude Desktop With a Token and Docker
Create a classic GitHub token with safe scopes, add the GitHub MCP server to Claude Desktop through Docker, test it, and use it for PR review, triage and changelogs.
With the right connection in place, Claude can work with your GitHub repos directly: list branches, review pull requests, read commit history. Pasting code into the chat stops being necessary. What follows covers wiring up private repos and a handful of ways to use the link right away.
What the GitHub connector does
Think of the connector as a bridge between your GitHub account and Claude. Once it's up, Claude can trigger real GitHub operations, such as listing repos, reading files, checking branches, opening pull requests and posting review comments. Your GitHub password never reaches Claude. It uses only a token you create yourself, and you decide what that token can see.
Creating the token
The setup relies on a Personal Access Token (Classic). Both token kinds were tried, and fine-grained tokens block the GitHub Search API while classic ones don't, so classic is the safe choice if you want full access.
- Open
github.comand sign in. - Click your profile photo at the top right, choose Settings, scroll to the bottom of the left-hand menu and click Developer settings. A shortcut skips this step and the next one: go straight to
https://github.com/settings/tokens, which opens the classic tokens page. - In the left menu, click Personal access tokens, then Tokens (classic). Don't pick "Fine-grained tokens" here. If you used the shortcut, you're already on this page.
- Press Generate new token and pick the classic variant. GitHub might prompt for your password or a 2FA code.
- Fill the "Note" field with something recognizable, such as
claude-mcp-access, so you'll remember later why the token exists. - Choose an expiry of 30, 60 or 90 days. Avoid "No expiration" unless you have a strong reason, because a short lifetime limits the damage if the token leaks.
- Select scopes carefully, because this is the step that matters most.
- Scroll down and click Generate token, then copy it.
On scopes: they define what Claude may do to your repos. Don't tick every box, only what the task needs, and read the scope list before clicking anything. Never enable delete_repo. It permits deleting a repository, one bad command could erase a whole project, and an AI assistant almost never has a good reason to hold it. As a rule of thumb, begin with the narrowest scope that gets the job done. If a later task needs more, you can always create a new token with wider access.
On the last step, GitHub displays the token a single time on the following screen. Copy it immediately and store it in a password manager, because you can't view it again once you leave the page.
Hooking the token up to Claude Desktop
This half connects GitHub to Claude Desktop through Docker. Work through the steps in order and don't skip any.
- Install Docker Desktop from
docker.comif you don't have it, the same way as any ordinary app. - Launch Docker Desktop and wait for "Docker is running", usually shown as a green icon in the menu bar. This is mandatory, since Claude can't reach GitHub unless Docker is running. Forgetting it is the most common mistake, so check it first if the connection fails later.
- Quit Claude Desktop fully before touching any config. On a Mac, use the Claude icon in the dock: right-click it and pick Quit. Merely closing the window leaves the app running.
- Locate the config file. Claude Desktop reads its settings from
claude_desktop_config.json, which on macOS sits at~/Library/Application Support/Claude/claude_desktop_config.json. To open that hidden folder, go to Finder, then Go, then Go to Folder, and paste the path. - Open the file in a plain text editor such as TextEdit or VS Code, using right-click and Open With. Avoid Word or anything that adds formatting. If the file is missing, create an empty one with exactly that name in exactly that folder.
- Add the GitHub MCP server block at the root of the JSON. If the file is empty, paste the whole thing. If it has content already, merge the
mcpServerskey carefully, because twomcpServerskeys in one file will break it.
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN=your_pat_here",
"ghcr.io/github/github-mcp-server"
]
}
}
}
- Find
your_pat_hereinside that block and replace it with the classic token from step 8. Leave the quotes in place and add no spaces. - Save the file under the same name, in the same place and with the same extension.
- Check the Docker icon again. Docker must be running before Claude opens.
- Start Claude Desktop. It reads the new config at launch, and the first start may take a few extra seconds while Docker pulls the GitHub MCP server image.
- Test it. When nothing happens, go through three checks in this order: Docker Desktop is running, the JSON has no typos (a missing comma is the most frequent culprit) and the token was pasted without stray spaces.
Things to try
- Pull request review. Ask Claude to look at an open PR. It reads the diff and flags bugs, unclear names and missing tests, and it can leave comments on GitHub itself so the team sees the feedback in one spot.
- Branch audits. Large teams accumulate old branches. Have Claude list every branch across your repos and point out stale ones that are safe to delete.
- Workflow automation. Claude can create a branch, push a small fix and open a pull request, which turns a five-step manual chore into one sentence.
- Issue triage. It can read open issues, rank them by priority and suggest labels, which helps on repos with a big backlog.
- Release notes. Point it at recent commits and merged PRs, and it can produce a tidy changelog for the next release.
- Cross-repo search. In a setup with many microservices, Claude can search all repos at once and find every place a function or config value appears, whichever project it lives in.
Security checklist
- Match scopes to the purpose, and never enable
delete_repo. - Give the token only the scopes it needs.
- Give it an expiry date, and replace tokens regularly.
- Keep tokens out of public chats, public repository files and shared documents.
- Keep
claude_desktop_config.jsonout of version control, because the token sits in it as plain text. - If a leak is possible, revoke the token immediately.
- Keep Docker Desktop updated, because old versions can carry security bugs.
After that, your private repos are connected, and Claude can read them, work in them and help the team ship faster without you leaving the chat.