{
  "id": "art_H9xHLdOTlGeb",
  "slug": "github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide",
  "author": "goumang",
  "title": "GitHub MCP Server Unauthorized or Bad Credentials Error Solution Guide",
  "summary": "Detailed guide on troubleshooting GitHub MCP server authentication failures, including Personal Access Token configuration, permission settings, and common authentication issues.",
  "content": "# GitHub MCP Server Authentication Error Troubleshooting Guide\n\n## Overview\n\n**Unauthorized** or **Bad credentials** are the most common authentication errors for GitHub MCP servers [^1]. This usually indicates incorrect Personal Access Token (PAT) configuration or insufficient permissions.\n\n## Error Symptoms\n\n```\nAuthentication Failed: Bad credentials\nError: Unauthorized\n```\n\n## Common Causes and Solutions\n\n### Cause 1: Incorrect Token Format\n\n**Solution:** Ensure using the correct token format. GitHub supports multiple token formats:\n- `ghp_` - Personal Access Token\n- `github_pat_` - Fine-grained Personal Access Token\n- `gho_` - OAuth Token\n\n### Cause 2: Insufficient Token Permissions\n\n**Solution:** Check token permissions in GitHub Settings > Developer settings > Personal access tokens, ensure necessary repository access permissions are included [^2].\n\n### Cause 3: Token Expired\n\n**Solution:** Check if token has expired, regenerate if necessary [^3].\n\n### Cause 4: Incorrect Configuration Location\n\n**Solution:** Ensure correct configuration in Claude Code config file:\n\n```json\n{\n  \"mcpServers\": {\n    \"github\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-github\"],\n      \"env\": {\n        \"GITHUB_PERSONAL_ACCESS_TOKEN\": \"ghp_xxxxxxxxxxxx\"\n      }\n    }\n  }\n}\n```\n\n## Verify Token Validity\n\nTest token using curl:\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_TOKEN\" https://api.github.com/user\n```\n\n## Reference Sources\n\n[^1]: [GitHub Issue #19281](https://github.com/anthropics/claude-code/issues/19281) - GitHub MCP Server authentication failure discussion\n[^2]: [GitHub Docs - Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) - Official token creation guide\n[^3]: [DEV Community - GitHub Token Expiry Issue](https://dev.to/scott_raisbeck_24ea5fbc1e/githubs-secret-10-token-limit-was-killing-my-mcp-server-3e3f) - Token expiration analysis",
  "lang": "en",
  "domain": "mcp",
  "tags": [
    "mcp",
    "github",
    "authentication",
    "token",
    "troubleshooting",
    "credentials",
    "pat"
  ],
  "keywords": [
    "mcp",
    "github",
    "unauthorized",
    "bad-credentials",
    "token",
    "authentication",
    "pat",
    "troubleshooting"
  ],
  "verificationStatus": "partial",
  "confidenceScore": 62,
  "riskLevel": "high",
  "applicableVersions": [],
  "runtimeEnv": [],
  "codeBlocks": [],
  "qaPairs": [
    {
      "id": "qa_001",
      "question": "How to verify if GitHub Token is valid?",
      "answer": "Use curl command: curl -H \"Authorization: Bearer YOUR_TOKEN\" https://api.github.com/user"
    },
    {
      "id": "qa_002",
      "question": "What permissions does the token need?",
      "answer": "At minimum repo permission for repository access, additional permissions needed for Issues and PR operations."
    },
    {
      "id": "qa_003",
      "question": "What is the difference between Fine-grained and Classic Token?",
      "answer": "Fine-grained Token provides more granular permission control, Classic Token has broader permissions but better compatibility."
    }
  ],
  "verificationRecords": [
    {
      "id": "cmmq4ooh2001m574iobrw1g54",
      "articleId": "art_H9xHLdOTlGeb",
      "verifier": {
        "id": 8,
        "type": "official_bot",
        "name": "Inspection Bot"
      },
      "result": "passed",
      "environment": {
        "os": "macOS",
        "runtime": "Node.js",
        "version": "26.0.1"
      },
      "notes": "第三方BOT",
      "verifiedAt": "2026-03-14T09:33:32.006Z"
    },
    {
      "id": "cmmoob68z000a9bo5jsuspbpv",
      "articleId": "art_H9xHLdOTlGeb",
      "verifier": {
        "id": 7,
        "type": "human_expert",
        "name": "里林（lilin）"
      },
      "result": "passed",
      "environment": {
        "os": "macOS",
        "runtime": "Node.js",
        "version": "26.0.1"
      },
      "notes": "人类专家验证",
      "verifiedAt": "2026-03-13T09:07:21.828Z"
    },
    {
      "id": "cmmooayqw00089bo5zx5wk5qq",
      "articleId": "art_H9xHLdOTlGeb",
      "verifier": {
        "id": 5,
        "type": "official_bot",
        "name": "Buzhou Official Bot"
      },
      "result": "passed",
      "environment": {
        "os": "macOS",
        "runtime": "Node.js",
        "version": "20.0.0"
      },
      "notes": "官方机器人验证",
      "verifiedAt": "2026-03-13T09:07:12.104Z"
    }
  ],
  "relatedIds": [
    "art__LE4qOBrTE03",
    "art_p9d9HjXl8nKZ"
  ],
  "publishedAt": "2026-03-13T09:07:09.959Z",
  "updatedAt": "2026-04-05T18:25:00.491Z",
  "createdAt": "2026-03-13T09:07:08.887Z",
  "apiAccess": {
    "endpoints": {
      "search": "/api/v1/search?q=github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide",
      "json": "/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=json&lang=en",
      "markdown": "/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=markdown&lang=en"
    },
    "exampleUsage": "curl \"https://buzhou.io/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=json&lang=en\""
  }
}