# GitHub MCP server security: what it can access

> What the GitHub MCP server can read, write and delete, how its token scopes work, and how to limit it in Claude Code and Codex with read-only mode.

The GitHub MCP server is GitHub’s official server, and it acts with whatever your OAuth login or personal access token (PAT) allows. It runs as a remote service at `https://api.githubcopilot.com/mcp/` or as a local Docker or binary process. Its tools include `delete_file`, `delete_repository` and `merge_pull_request`, so start with read-only mode and a short toolset list before an AI agent uses it.

## Who maintains it and how it connects

The repository is [github/github-mcp-server](https://github.com/github/github-mcp-server), described as GitHub’s official MCP server. The remote server uses OAuth or a PAT sent as `Authorization: Bearer`. The local server opens a browser login on first use and keeps the token in memory only. If you set `GITHUB_PERSONAL_ACCESS_TOKEN`, it takes precedence over OAuth.

GitHub documents the scopes `repo`, `read:org`, `read:packages`, `gist`, `notifications`, `security_events`, `read:project`, `admin:org` and `read:enterprise`. Each tool lists its own OAuth challenge scopes, mostly `repo`, with `workflow`, `security_events` or `delete_repo` on some.

## What the tools can read, write and delete

| Group | Example tools |
| --- | --- |
| Read | `get_file_contents`, `issue_read` |
| Write | `create_or_update_file`, `push_files`, `create_branch`, `issue_write`, `update_pull_request`, `pull_request_review_write`, `merge_pull_request`, `fork_repository` |
| Delete | `delete_file`, `delete_repository` |
| Run workflows | `actions_run_trigger` |

The default toolsets are `context`, `repos`, `issues`, `pull_requests` and `users`. Others, such as `actions`, `gists`, `projects`, `dependabot` and `code_security`, are opt in.

## Risks

Issues, pull request bodies, comments and commit messages are written by other people, and the model reads them through the tools. Text in one of them can try to steer the agent. The token decides what that steering can do. A classic PAT with `repo` can push and merge in every repository you can reach.

GitHub offers lockdown mode, which limits content from authors without push access. Its docs call it “a best-effort content filter” and say it is not an authorization boundary.

## Limit it on the server side

| Control | Local | Remote |
| --- | --- | --- |
| Read-only | `--read-only` or `GITHUB_READ_ONLY` | `X-MCP-Readonly` header or the `/readonly` URL path |
| Toolsets | `--toolsets` or `GITHUB_TOOLSETS` | `X-MCP-Toolsets` header or `/x/{toolset}` path |
| Remove tools | `--exclude-tools` or `GITHUB_EXCLUDE_TOOLS` | `X-MCP-Exclude-Tools` header |
| Lockdown | `--lockdown-mode` or `GITHUB_LOCKDOWN_MODE` | `X-MCP-Lockdown` header |

GitHub says read-only mode takes precedence over other configuration. The docs show a remote read-only example at `https://api.githubcopilot.com/mcp/x/all/readonly`.

## Limit it in Claude Code

GitHub’s Claude install guide adds the remote server with `claude mcp add-json github '{"type":"http","url":"https://api.githubcopilot.com/mcp","headers":{"Authorization":"Bearer YOUR_GITHUB_PAT"}}'`. Then deny the dangerous tools by name in settings.

```json
{
  "permissions": {
    "deny": [
      "mcp__github__delete_file",
      "mcp__github__delete_repository",
      "mcp__github__merge_pull_request"
    ],
    "ask": ["mcp__github__create_or_update_file", "mcp__github__push_files"]
  }
}
```

The `github` part is the name you gave the server. Use `--scope user` for all projects or keep the default local scope for one.

## Limit it in Codex

GitHub’s Codex guide gives this form.

```toml
[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"
bearer_token_env_var = "GITHUB_PAT_TOKEN"
disabled_tools = ["delete_file", "delete_repository", "merge_pull_request"]
```

You can also run `codex mcp add github --url https://api.githubcopilot.com/mcp/ --bearer-token-env-var GITHUB_PAT_TOKEN`. Keep the token in the environment variable and out of the file.

## Checklist

1. Use a fine-grained or narrowly scoped token for one set of repositories.
2. Connect through the read-only path first.
3. Enable only the toolsets the task needs.
4. Deny `delete_*` and merge tools by name.
5. Protect `main` at GitHub with required reviews, because the server only holds the rights of your token. See [Git protection](https://www.excellent.so/docs/git) and [after a force push](https://www.excellent.so/guides/ai-agent-force-pushed-main).
6. Read the [MCP security hub](https://www.excellent.so/guides/mcp-server-security) for the rest.

Checked against the vendor documentation on November 25, 2026. [GitHub MCP server](https://github.com/github/github-mcp-server) · [Server configuration](https://github.com/github/github-mcp-server/blob/main/docs/server-configuration.md) · [Claude Code permissions](https://code.claude.com/docs/en/permissions) · [Codex MCP](https://developers.openai.com/codex/mcp)

## What Excellent covers

Excellent does not inspect MCP servers themselves. Its free scan reads supported logs on the Mac and reports findings for review. It reads the session logs of Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code, so it can show what an agent did after it called a tool. It does not read Cursor’s, OpenClaw’s or Claude Cowork’s logs. For a local report without installing an app, [run the free scan](https://www.excellent.so/scan). Its script uses Python 3.9 or later when your Mac has it and the shell when it doesn’t, reads the logs locally and makes no network requests. [See a sample report](https://www.excellent.so/r/sample).

Excellent Pro adds checks before supported actions. Claude Code can display an ask prompt. With Codex, an Excellent “ask” refuses the action and tells the agent to ask you. Commands sent into an already running Codex shell fall outside that check. [Agent coverage](https://www.excellent.so/agents) · [Pricing](https://www.excellent.so/pricing). Pro is US-only for now.

Source: https://www.excellent.so/guides/github-mcp-server
