|
1 | | -# OAuth Scope Filtering |
| 1 | +# PAT Scope Filtering |
2 | 2 |
|
3 | | -The GitHub MCP Server automatically filters available tools based on your Personal Access Token's (PAT) OAuth scopes. This ensures you only see tools that your token has permission to use, reducing clutter and preventing errors from attempting operations your token can't perform. |
| 3 | +The GitHub MCP Server automatically filters available tools based on your classic Personal Access Token's (PAT) OAuth scopes. This ensures you only see tools that your token has permission to use, reducing clutter and preventing errors from attempting operations your token can't perform. |
| 4 | + |
| 5 | +> **Note:** This feature applies to **classic PATs** (tokens starting with `ghp_`). Fine-grained PATs and other token types don't support scope detection. |
4 | 6 |
|
5 | 7 | ## How It Works |
6 | 8 |
|
7 | | -When the server starts, it makes a lightweight HTTP HEAD request to the GitHub API to discover your token's scopes from the `X-OAuth-Scopes` header. Tools that require scopes your token doesn't have are automatically hidden. |
| 9 | +When the server starts with a classic PAT, it makes a lightweight HTTP HEAD request to the GitHub API to discover your token's scopes from the `X-OAuth-Scopes` header. Tools that require scopes your token doesn't have are automatically hidden. |
8 | 10 |
|
9 | 11 | **Example:** If your token only has `repo` and `gist` scopes, you won't see tools that require `admin:org`, `project`, or `notifications` scopes. |
10 | 12 |
|
| 13 | +## PAT vs OAuth Authentication |
| 14 | + |
| 15 | +| Authentication | Scope Handling | |
| 16 | +|---------------|----------------| |
| 17 | +| **Classic PAT** (`ghp_`) | Filters tools at startup based on token scopes—tools requiring unavailable scopes are hidden | |
| 18 | +| **OAuth** (remote server only) | Uses OAuth scope challenges—when a tool needs a scope you haven't granted, you're prompted to authorize it | |
| 19 | +| **Fine-grained PAT** (`github_pat_`) | No filtering—all tools shown, API enforces permissions | |
| 20 | + |
| 21 | +With OAuth, the remote server can dynamically request additional scopes as needed. With PATs, scopes are fixed at token creation, so the server proactively hides tools you can't use. |
| 22 | + |
11 | 23 | ## Checking Your Token's Scopes |
12 | 24 |
|
13 | 25 | To see what scopes your token has, you can run: |
@@ -70,9 +82,11 @@ If the server cannot fetch your token's scopes (e.g., network issues, rate limit |
70 | 82 | WARN: failed to fetch token scopes, continuing without scope filtering |
71 | 83 | ``` |
72 | 84 |
|
73 | | -## Fine-Grained Personal Access Tokens |
| 85 | +## Classic vs Fine-Grained Personal Access Tokens |
| 86 | + |
| 87 | +**Classic PATs** (`ghp_` prefix) support OAuth scopes and return them in the `X-OAuth-Scopes` header. Scope filtering works fully with these tokens. |
74 | 88 |
|
75 | | -Fine-grained PATs use a different permission model and don't return OAuth scopes in the `X-OAuth-Scopes` header. When using fine-grained PATs, scope filtering will be skipped and all tools will be available. The GitHub API will still enforce permissions at the API level. |
| 89 | +**Fine-grained PATs** (`github_pat_` prefix) use a different permission model based on repository access and specific permissions rather than OAuth scopes. They don't return the `X-OAuth-Scopes` header, so scope filtering is skipped. All tools will be available, but the GitHub API will still enforce permissions at the API level—you'll get errors if you try to use tools your token doesn't have permission for. |
76 | 90 |
|
77 | 91 | ## Troubleshooting |
78 | 92 |
|
|
0 commit comments