Add GitHub to a local diagnosis
Give your AI client a GitHub tool with a fine-grained token that has read-only permissions on chosen repositories, and prove it cannot write.
Before you start
- Connect your client first. See Set up Diagnosis.
- For Codex and other clients, install Docker.
Reference
Used for
Finding the change that shipped just before the incident: the merged pull request, its diff, and the CI or deploy run that released it.
Reads
Commits and compares, pull requests and their diffs, file contents at a commit, workflow runs and job logs. The toolsets are repos, pull_requests and actions.
Credential
A fine-grained personal access token. In GitHub, open Settings, Developer settings, Personal access tokens, Fine-grained tokens, and select Generate new token, then set the values below.
Resource owner: your organization. The organization may need to approve the token before it works.
Repository access: Only select repositories. Choose the services that a diagnosis can name, not all repositories, because the model can read every repository the token reaches.
Contents, Pull requests and Actions: Read-only. They give commits and files, the merged pull request and its diff, and workflow runs and job logs.
Metadata: Read-only. GitHub sets it for you.
Deployments and Commit statuses: Read-only, and only if you deploy through GitHub deployments or statuses.
Every other permission: No access.
Expiration: 90 days or less. When it expires, create a new token and replace the old one in your client.
Config
Claude in the terminal (Claude Code) can use GitHub's remote server, so you install nothing.
Claude in the terminal, remote server
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ --scope user \
-H "Authorization: Bearer github_pat_your_token" \
-H "X-MCP-Toolsets: repos,pull_requests,actions" \
-H "X-MCP-Readonly: true"Codex and other clients run the server as a Docker image. GitHub's server has no npm package.
Codex and other clients, local server in Docker
codex mcp add github \
--env GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_your_token \
--env GITHUB_TOOLSETS=repos,pull_requests,actions \
-- docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN -e GITHUB_TOOLSETS \
ghcr.io/github/github-mcp-server stdio --read-onlyRead-only by
The token permissions. GitHub refuses every write from this token. Rely on this layer.
X-MCP-Readonly or --read-only is the second layer. The server then offers no write tools. The toolsets are the third layer. Issues, code security and the other toolsets are not loaded, so the model cannot see them.
Check it
Send a write with the token. GitHub must answer 403.
Expect 403
curl -s -o /dev/null -w "%{http_code}\n" -X POST \
-H "Authorization: Bearer github_pat_your_token" \
https://api.github.com/repos/your-org/your-repo/issues -d '{"title":"write-test"}'Reaches Tellagen
Links to the commit, the pull request and the run, the repository and the commit in each change reference, and diff lines when your client builds a diff figure, at most 12 changed lines. Your model provider receives every file and diff that the tool returns. See How a local diagnosis uses your tools.
You are done when
After your next diagnosis, GitHub has a tick under Your clients in Settings → AI diagnosis → Local, and the check above answered 403.
FAQs
The check answers 201. What now?
The token can write. Open the token in GitHub and set Issues, Contents and every other permission to Read-only or No access, then run the check again.
An admin sees GitHub as Found, no access. What do I do?
Your client reported that it can't use the token, often because the token expired or the organization hasn't approved it. Create or approve the token and replace it in your client. Then the admin selects Recheck on the GitHub row in Tools a diagnosis can use.
Related guides
External setup references
Did this help?
Updated . Something out of date? Write to [email protected]. Open Markdown version