You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, GitHub App installation tokens, and server-to-server tokens don't support scope detection and show all tools.
6
+
7
+
## How It Works
8
+
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.
10
+
11
+
**Example:** If your token only has `repo` and `gist` scopes, you won't see tools that require `admin:org`, `project`, or `notifications` scopes.
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
+
|**GitHub App** (`ghs_`) | No filtering—all tools shown, permissions based on app installation |
21
+
|**Server-to-server**| No filtering—all tools shown, permissions based on app/token configuration |
22
+
23
+
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.
24
+
25
+
## OAuth Scope Challenges (Remote Server)
26
+
27
+
When using the [remote MCP server](./remote-server.md) with OAuth authentication, the server uses a different approach called **scope challenges**. Instead of hiding tools upfront, all tools are available, and the server requests additional scopes on-demand when you try to use a tool that requires them.
28
+
29
+
**How it works:**
30
+
1. You attempt to use a tool (e.g., creating an issue)
31
+
2. If your current OAuth token lacks the required scope, the server returns an OAuth scope challenge
32
+
3. Your MCP client prompts you to authorize the additional scope
33
+
4. After authorization, the operation completes successfully
34
+
35
+
This provides a smoother user experience for OAuth users since you only grant permissions as needed, rather than requesting all scopes upfront.
-`repo` → includes `public_repo`, `security_events`
56
+
-`admin:org` → includes `write:org` → includes `read:org`
57
+
-`project` → includes `read:project`
58
+
59
+
This means if your token has `repo`, tools requiring `security_events` will also be available.
60
+
61
+
Each tool in the [README](../README.md#tools) lists its required and accepted OAuth scopes.
62
+
63
+
## Public Repository Access
64
+
65
+
Read-only tools that only require `repo` or `public_repo` scopes are **always visible**, even if your token doesn't have these scopes. This is because these tools work on public repositories without authentication.
66
+
67
+
For example, `get_file_contents` is always available—you can read files from any public repository regardless of your token's scopes. However, write operations like `create_or_update_file` will be hidden if your token lacks `repo` scope.
68
+
69
+
> **Note:** The GitHub API doesn't return `public_repo` in the `X-OAuth-Scopes` header—it's implicit. The server handles this by not filtering read-only repository tools.
70
+
71
+
## Graceful Degradation
72
+
73
+
If the server cannot fetch your token's scopes (e.g., network issues, rate limiting), it logs a warning and continues **without filtering**. This ensures the server remains usable even when scope detection fails.
74
+
75
+
```
76
+
WARN: failed to fetch token scopes, continuing without scope filtering
77
+
```
78
+
79
+
## Classic vs Fine-Grained Personal Access Tokens
80
+
81
+
**Classic PATs** (`ghp_` prefix) support OAuth scopes and return them in the `X-OAuth-Scopes` header. Scope filtering works fully with these tokens.
82
+
83
+
**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.
84
+
85
+
## GitHub App and Server-to-Server Tokens
86
+
87
+
**GitHub App installation tokens** (`ghs_` prefix) and other server-to-server tokens use a permission model based on the app's installation permissions rather than OAuth scopes. These tokens don't return the `X-OAuth-Scopes` header, so scope filtering is skipped. The GitHub API enforces permissions based on the app's configuration.
88
+
89
+
## Troubleshooting
90
+
91
+
| Problem | Cause | Solution |
92
+
|---------|-------|----------|
93
+
| Missing expected tools | Token lacks required scope |[Edit your PAT's scopes](https://github.com/settings/tokens) in GitHub settings |
94
+
| All tools visible despite limited PAT | Scope detection failed | Check logs for warnings about scope fetching |
95
+
| "Insufficient permissions" errors | Tool visible but scope insufficient | This shouldn't happen with scope filtering; report as bug |
96
+
97
+
> **Tip:** You can adjust the scopes of an existing classic PAT at any time via [GitHub's token settings](https://github.com/settings/tokens). After updating scopes, restart the MCP server to pick up the changes.
> **Default behavior:** If you don't specify any configuration, the server uses the **default toolsets**: `context`, `issues`, `pull_requests`, `repos`, `users`.
17
18
@@ -330,6 +331,20 @@ Lockdown mode ensures the server only surfaces content in public repositories fr
330
331
331
332
---
332
333
334
+
### Scope Filtering
335
+
336
+
**Automatic feature:** The server handles OAuth scopes differently depending on authentication type:
337
+
338
+
-**Classic PATs** (`ghp_` prefix): Tools are filtered at startup based on token scopes—you only see tools you have permission to use
339
+
-**OAuth** (remote server): Uses scope challenges—when a tool needs a scope you haven't granted, you're prompted to authorize it
340
+
-**Other tokens**: No filtering—all tools shown, API enforces permissions
341
+
342
+
This happens transparently—no configuration needed. If scope detection fails for a classic PAT (e.g., network issues), the server logs a warning and continues with all tools available.
343
+
344
+
See [Scope Filtering](./scope-filtering.md) for details on how filtering works with different token types.
0 commit comments