GitHub MCP Server Setup: Permissions, Tools, and a Safe Test

Connect GitHub's official MCP server with least privilege, inspect its tool surface, and run a read-before-write test without exposing a token.

Least-privilege lab GitHub MCP Read before write Permission matrix + denied-path test

The safest GitHub MCP setup starts read-only. Connect GitHub's official server, limit the credential to one disposable repository, inspect the tools, prove required reads, and deliberately prove that writes and cross-repository access fail. Enable one write permission only after that evidence exists.

ILAA rechecked the official github/github-mcp-server repository and its Codex installation guide on 27 September 2026. The documented remote endpoint is https://api.githubcopilot.com/mcp/. The guide supports OAuth or a personal access token and warns against committing credentials.

Choose the smallest authentication surface

ChoiceUse it whenStarting boundaryStop signal
Host OAuthYour host supports GitHub's remote OAuth flowOnly required organizations and repositoriesConsent requests unrelated resources
Fine-grained PATYou need explicit repository and permission selectionOne lab repository; Metadata, Contents, Issues readOnly a broad classic token is available
Official local containerRemote transport is unavailable or policy requires local executionOfficial image and a narrow tokenThe container receives unrelated environment secrets

Remote setup for Codex

[mcp_servers.github]
url = "https://api.githubcopilot.com/mcp/"
bearer_token_env_var = "GITHUB_PAT_TOKEN"

Put GITHUB_PAT_TOKEN in the secret store or environment used to launch the host, never in the configuration file or transcript.

Original asset: the read-before-write permission matrix

Create an empty private repository named mcp-permission-lab, add one README and one issue, then run these rows in order. Record the server identity, tool name, redacted arguments, result, and timestamp.

TestInitial permissionPass condition
Repository identityMetadata: readCorrect owner, visibility, and default branch
File readContents: readExact README and commit reference
Issue readIssues: readExact title and number
Blocked writeIssues: readCreate request is denied; issue count is unchanged
Cross-repository escapeToken limited to the labAnother private repository stays invisible
Scoped writeIssues: write after approvalOnly the named probe issue changes and both actions are logged

Gate: identity, file read, issue read, denied write, and cross-repository denial must score 5/5 before write access is enabled. Tool visibility is not authorization; enforce the boundary in both the MCP configuration and GitHub credential.

Troubleshooting without widening the token

SymptomCheck firstDo not do
401Expiry, environment name, endpointPaste the token into config
No toolsHost status, logs, selected toolsetsGrant every permission
Issue creation failsExpected during the read-only phaseAdd administration permission
Org repository missingOrganization approval and selected-repo accessDefault to a broad classic PAT

Bottom line: required reads should succeed, unrelated repositories should remain invisible, and writes should fail until a named permission and approval are added.

Keep reading