← All connection guides

How to connect Claude Code to GitHub

Connect Claude Code to GitHub through the official MCP server, then verify repository reads with scoped access.

Free guide · Updated

Based on official documentation · Checked

Ask your agent

Copy the prompt and paste it into your assistant.

Quick answer

Use GitHub’s official MCP server from Claude Code to read repository information through tools. Git access to a local checkout is a different capability. This guide selects the documented local Docker server with OAuth, avoiding a personal access token pasted into a command.

Before you start

Prepare a current Claude Code installation and a running Docker engine. Choose a repository and issue intended for testing. Sign in with an account that can access the repository you want to use. Check for an existing server named github before adding another configuration.

1. Add the documented local server

GitHub documents a Docker OAuth setup with a callback bound to the local loopback interface. Ensure port 8085 is free; if it is occupied, consult the current official alternative rather than terminating an unrelated service. Run the command from your terminal, outside an active Claude conversation.

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

2. Complete authorization

Start a fresh Claude Code session and inspect the github entry in /mcp. Follow the server’s OAuth flow when requested. Review the account and permissions before granting access. Organization approval may be required for organization resources.

claude mcp list
claude mcp get github

Practice

3. Verify real repository access

  1. Ask Claude Code to use GitHub MCP to read the test repository README and summarize one known issue. Include the owner, repository and issue number explicitly.

Output: The README content and issue title match GitHub; the run shows GitHub MCP tools rather than local file reads or a shell fallback.

4. Keep the first test read-only

Do not create an issue or push a commit just to prove authentication. Restart the client and repeat a repository read. This distinguishes a durable setup from a single session with unrelated cached context.

Troubleshooting

Docker launch failure: inspect the image/startup error and callback port. Server configured but unavailable: inspect /mcp status. Repository missing: verify the authorized account and organization restrictions. A successful read of a public repository does not establish access to a private one.

Disconnect and alternatives

Remove only this test server from Claude Code, stop its own container if it remains, and revoke the applicable authorization. GitHub also documents remote HTTP with PAT authentication; its instructions and version requirements differ. Do not silently switch authentication methods or copy a token into a shared project configuration.

Sources

Read the primary material