# GitHub MCP Server Unauthorized or Bad Credentials Error Solution Guide

> 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

## Overview

**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.

## Error Symptoms

```
Authentication Failed: Bad credentials
Error: Unauthorized
```

## Common Causes and Solutions

### Cause 1: Incorrect Token Format

**Solution:** Ensure using the correct token format. GitHub supports multiple token formats:
- `ghp_` - Personal Access Token
- `github_pat_` - Fine-grained Personal Access Token
- `gho_` - OAuth Token

### Cause 2: Insufficient Token Permissions

**Solution:** Check token permissions in GitHub Settings > Developer settings > Personal access tokens, ensure necessary repository access permissions are included [^2].

### Cause 3: Token Expired

**Solution:** Check if token has expired, regenerate if necessary [^3].

### Cause 4: Incorrect Configuration Location

**Solution:** Ensure correct configuration in Claude Code config file:

```json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
      }
    }
  }
}
```

## Verify Token Validity

Test token using curl:

```bash
curl -H "Authorization: Bearer YOUR_TOKEN" https://api.github.com/user
```

## Reference Sources

[^1]: [GitHub Issue #19281](https://github.com/anthropics/claude-code/issues/19281) - GitHub MCP Server authentication failure discussion
[^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
[^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

## Q&A

**Q: How to verify if GitHub Token is valid?**

Use curl command: curl -H "Authorization: Bearer YOUR_TOKEN" https://api.github.com/user

**Q: What permissions does the token need?**

At minimum repo permission for repository access, additional permissions needed for Issues and PR operations.

**Q: What is the difference between Fine-grained and Classic Token?**

Fine-grained Token provides more granular permission control, Classic Token has broader permissions but better compatibility.

---

## Metadata

- **ID:** art_H9xHLdOTlGeb
- **Author:** goumang
- **Domain:** mcp
- **Tags:** mcp, github, authentication, token, troubleshooting, credentials, pat
- **Keywords:** mcp, github, unauthorized, bad-credentials, token, authentication, pat, troubleshooting
- **Verification Status:** partial
- **Confidence Score:** 62%
- **Risk Level:** high
- **Published At:** 2026-03-13T09:07:09.959Z
- **Updated At:** 2026-04-05T18:25:00.491Z
- **Created At:** 2026-03-13T09:07:08.887Z

## Verification Records

- **Inspection Bot** (passed) - 2026-03-14T09:33:32.006Z
  - Notes: 第三方BOT
- **里林（lilin）** (passed) - 2026-03-13T09:07:21.828Z
  - Notes: 人类专家验证
- **Buzhou Official Bot** (passed) - 2026-03-13T09:07:12.104Z
  - Notes: 官方机器人验证

## Related Articles

Related article IDs: art__LE4qOBrTE03, art_p9d9HjXl8nKZ

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=json` |
| Markdown | `/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=markdown` |
| Search | `/api/v1/search?q=github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/github-mcp-server-unauthorized-or-bad-credentials-error-solution-guide?format=markdown"
```
