---
title: How to connect GitHub MCP to Claude Code
description: Run claude mcp add with https://api.githubcopilot.com/mcp/ and a fine-grained token. Read-only mode, toolsets, permission rules and team setup.
canonical: https://mcp1.com/blog/github-mcp-claude-code
last-updated: 2026-11-22
---

# How to connect GitHub MCP to Claude Code

Run claude mcp add with https://api.githubcopilot.com/mcp/ and a fine-grained token. Read-only mode, toolsets, permission rules and team setup.

![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite

 Terminal

$ claude mcp add --transport http github api.githubcopilot.com/mcp/

githubConnected

 Terminal

$ claude mcp add --transport http github api.githubcopilot.com/mcp/

githubConnected

To connect GitHub to Claude Code, create a fine-grained personal access token and run `claude mcp add` with GitHub’s hosted server, `https://api.githubcopilot.com/mcp/`, sending the token as a bearer header. Claude Code can then read code, issues, pull requests and Actions logs with your access. Add `X-MCP-Readonly` to keep it from writing.

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

GitHub hosts the server, so there is nothing to install. It is free on every GitHub plan and doesn’t need a Copilot subscription.

1. 1Create a fine-grained token at `github.com/settings/personal-access-tokens`. Pick the repositories it may reach, and grant read access to Contents, Issues, Pull requests and Metadata. Add Actions if you want build logs. Grant write only where you want the agent to write.
2. 2Export it in your shell as `GITHUB_PAT`, then add the server:  
Terminal  
```  
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \  
  --header "Authorization: Bearer $GITHUB_PAT"  
```
3. 3Start `claude` and run `/mcp`. `github` should show as connected with its tool count. A 401 there means the token is wrong or expired.

Then make a call that changes nothing:

Prompt

```
Use the GitHub tools to list the open pull requests in this repository
that are waiting on my review. Don't change anything.
```

Why a token and not OAuth

GitHub’s hosted server supports OAuth only for apps that register their own GitHub app, and neither GitHub nor Anthropic documents a sign-in flow for Claude Code. A token is the supported path. If you want to sign in with a browser instead, the local server does it; see below.

## Which GitHub tools does Claude Code get?

The base URL loads five default toolsets: `context`, `repos`, `issues`, `pull_requests` and `users`. These are the tools you’ll use most:

ToolWhat it does

`get_file_contents`

Reads a file or directory from any repository the token reaches. Read.

`search_code`

Searches code across GitHub with qualifiers like repo: and org:. Read.

`list_commits`

Lists a branch’s commits; get\_commit returns one with its diff. Read.

`issue_read`

Fetches an issue with its comments; list\_issues and search\_issues find them. Read.

`pull_request_read`

Fetches a pull request’s diff, files, reviews or check status. Read.

`get_job_logs`

Returns logs for a failed Actions job. Read, in the actions toolset.

`issue_write`

Creates or updates an issue. Write.

`create_pull_request`

Opens a pull request from a branch. Write.

`push_files`

Commits several files to a branch in one call. Write.

`merge_pull_request`

Merges a pull request. Write.

Claude Code already has `git` and the files in your checkout, so the server earns its place on what isn’t local: other repositories, issues, review threads and CI logs.

## How do I make GitHub MCP read-only or limit toolsets?

Use `https://api.githubcopilot.com/mcp/readonly` as the URL, or send headers. `X-MCP-Readonly` drops every write tool, and `X-MCP-Toolsets` picks which toolsets load:

SettingEffect

`/readonly`

Default toolsets, read tools only.

`/x/issues/readonly`

One toolset in the path. Use the header for more than one.

`X-MCP-Toolsets`

Comma-separated toolsets, like repos,issues,actions. Unknown names are ignored.

`X-MCP-Tools`

Single tools. A misspelled name stops the server from starting.

`X-MCP-Exclude-Tools`

Tools to remove, which wins over the two above.

`X-MCP-Lockdown`

Hides public issue content from users without push access. GitHub calls it a content filter, not a security boundary.

These limits live in your config, which anyone with the file can change. A token with read-only permissions is the limit GitHub enforces. More in [how to make an MCP server read-only](https://mcp1.com/blog/read-only-mcp-server).

## How do I stop Claude Code merging or deleting on GitHub?

Add permission rules to `.claude/settings.json`. Claude Code names the tools `mcp__github__<tool>`, and allow rules accept a glob after that prefix. Allow the readers, ask before writes, and deny merges and deletes:

.claude/settings.json

```
{
  "permissions": {
    "allow": [
      "mcp__github__get_*",
      "mcp__github__list_*",
      "mcp__github__search_*",
      "mcp__github__issue_read",
      "mcp__github__pull_request_read"
    ],
    "ask": [
      "mcp__github__create_pull_request",
      "mcp__github__issue_write",
      "mcp__github__push_files"
    ],
    "deny": [
      "mcp__github__merge_pull_request",
      "mcp__github__delete_*"
    ]
  }
}
```

Tools you don’t list ask before running. See [how to stop agents from running destructive MCP tools](https://mcp1.com/blog/stop-destructive-mcp-tools) for the same idea in other clients.

## How do I share the GitHub server with my team?

Commit a `.mcp.json` at the repository root. Claude Code expands `${GITHUB_PAT}` from each person’s environment, so the file holds no secret and every teammate calls GitHub with their own token:

.mcp.json

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

Teammates approve the project server the first time Claude Code loads it. If `GITHUB_PAT` is unset, `/mcp` shows a warning and the call fails. Commit the permission rules next to it so everyone gets the same allow and deny lists.

## Can I sign in with OAuth using the local server?

Yes. GitHub’s Docker image runs the server on your machine and opens a browser sign-in, keeping the token in memory only. It needs Docker running:

Terminal

```
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
```

The local server is also the only option on GitHub Enterprise Server, which the hosted one doesn’t reach. It takes the same settings as flags or variables, like `GITHUB_TOOLSETS` and `GITHUB_READ_ONLY`.

## What if GitHub MCP doesn’t connect?

Terminal

```
claude mcp list
claude mcp get github
```

- `github` isn’t listed. It was added at local scope in another directory. Add it again here, or with `--scope user`.
- Failed to connect with a 401\. The token expired, or the header was saved with an empty variable. Remove the server and add it again with the token exported.
- Organization repositories come back empty. Your organization may need to approve fine-grained tokens, or the token needs SSO authorization. Check the token’s page in your GitHub settings.
- A tool you expect is missing. Its toolset isn’t loaded, or read-only mode removed it. Add the toolset to `X-MCP-Toolsets`.

The “MCP servers in Copilot” organization policy doesn’t apply here. It governs Copilot editors; Claude Code is bound by your organization’s token and SSO policies.

## GitHub for the whole team, without a token on every laptop

The setup above leaves a GitHub token on every laptop and keeps read-only mode in a file anyone can edit. MCP1 is a gateway that does it once. An admin installs [GitHub](https://mcp1.com/servers/github) in the workspace with a fine-grained token, and can add a second, read-only token that people on read-only access call with, so GitHub itself refuses their writes. Each person connects one URL and signs in with OAuth:

Terminal

```
claude mcp add --transport http mcp1 https://mcp1.com/mcp/<workspace>/<gateway>
```

GitHub’s tools appear as `github__<tool>` next to Linear, Sentry and the rest, rules like `github__merge_*` hold risky tools to admins, and every call is in the audit log. If you use VS Code too, see [connecting GitHub MCP to VS Code](https://mcp1.com/blog/github-mcp-vscode). The [docs](https://mcp1.com/docs) cover gateways and groups, and you can [start free](https://mcp1.com/signup).

## Common questions

### Do I need GitHub Copilot to use the GitHub MCP server?

No. GitHub says its MCP server is available to all GitHub users on any plan, even though it is hosted at api.githubcopilot.com. Only tools for paid features, like the Copilot coding agent, need a license.

### Should I use a classic or fine-grained token?

Fine-grained, which GitHub recommends. It limits the token to chosen repositories and permissions. With a classic token, the server hides tools whose scopes the token lacks.

### Is the npm package @modelcontextprotocol/server-github still the way to run it?

No. That package was deprecated in April 2025\. Use GitHub’s hosted server, or its github-mcp-server Docker image or binary to run it locally.

### Does Claude Code load every GitHub tool into context?

Not up front. Claude Code’s tool search is on by default, so it loads tool names first and fetches definitions when needed. Limiting toolsets still keeps the list easier for the model to choose from.

Give your team one URL

Create a workspace, install your servers and share a gateway with a group. Free for individuals.

[Start with MCP1](https://mcp1.com/signup)[Read the docs](https://mcp1.com/docs)

## More from the blog

[ SupportIntercomRead-onlyLinearRead-onlyNotionRead-onlyStripeRead-onlyMCP servers for support teams: what to connect firstStart with your helpdesk, Linear, Notion and Stripe, read-only first. What they answer together, which writes to hold back and a shared setup.![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite](https://mcp1.com/blog/mcp-servers-for-support-teams)[ Terminal$ claude mcp add --transport http vercel mcp.vercel.comvercelConnectedHow to connect Vercel MCP to Claude CodeRun claude mcp add with https://mcp.vercel.com, then sign in with /mcp. Project-scoped URLs, the main tools, deploy approvals and sharing with a team.![](https://avatars.githubusercontent.com/u/1297371?s=96&v=4)Eldad FuxFounder and CEO, Appwrite](https://mcp1.com/blog/vercel-mcp-claude-code)

---

This is the markdown copy of https://mcp1.com/blog/github-mcp-claude-code. Site index for agents: https://mcp1.com/llms.txt
