GitHub MCP server: "Bad credentials" / 401 errors
Claude DesktopCursorVS CodeClaude Code
The error
401 Bad credentials • "GITHUB_PERSONAL_ACCESS_TOKEN not set"
Why it happens
The token is missing, expired, or lacks scopes. With Docker, the variable also has to be forwarded into the container (-e GITHUB_PERSONAL_ACCESS_TOKEN) and set in the env block.
How to fix it
- Create a token with the right access
Fine-grained or classic PAT with repo access for the repos you need. - Forward the variable into Docker
Both parts are required.{ "mcpServers": { "github": { "command": "docker", "args": ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token" } } } } - Make sure Docker is running
If Docker Desktop is stopped, the server exits with "Connection closed".