|
| 1 | +# CLI Commands for OAuth Scope Management |
| 2 | + |
| 3 | +The GitHub MCP Server provides two CLI commands to help manage OAuth scopes for your Personal Access Token (PAT). |
| 4 | + |
| 5 | +## list-scopes |
| 6 | + |
| 7 | +Lists the OAuth scopes required by your enabled tools. |
| 8 | + |
| 9 | +### Usage |
| 10 | + |
| 11 | +```bash |
| 12 | +# List scopes for default toolsets |
| 13 | +github-mcp-server list-scopes |
| 14 | + |
| 15 | +# List scopes for specific toolsets |
| 16 | +github-mcp-server list-scopes --toolsets=repos,issues,pull_requests |
| 17 | + |
| 18 | +# List scopes for all toolsets |
| 19 | +github-mcp-server list-scopes --toolsets=all |
| 20 | + |
| 21 | +# Show only unique scopes needed (summary format) |
| 22 | +github-mcp-server list-scopes --output=summary |
| 23 | + |
| 24 | +# Get JSON output for programmatic use |
| 25 | +github-mcp-server list-scopes --output=json |
| 26 | + |
| 27 | +# Use the convenience script |
| 28 | +script/list-scopes --toolsets=all --output=summary |
| 29 | +``` |
| 30 | + |
| 31 | +### Example Output |
| 32 | + |
| 33 | +``` |
| 34 | +Required OAuth scopes for enabled tools: |
| 35 | +
|
| 36 | + read:org |
| 37 | + repo |
| 38 | +
|
| 39 | +Total: 2 unique scope(s) |
| 40 | +``` |
| 41 | + |
| 42 | +## compare-scopes |
| 43 | + |
| 44 | +Compares your PAT's granted scopes with the scopes required by enabled tools. |
| 45 | + |
| 46 | +### Usage |
| 47 | + |
| 48 | +```bash |
| 49 | +# Export your token |
| 50 | +export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_yourtoken |
| 51 | + |
| 52 | +# Compare with default toolsets |
| 53 | +github-mcp-server compare-scopes |
| 54 | + |
| 55 | +# Compare with specific toolsets |
| 56 | +github-mcp-server compare-scopes --toolsets=repos,issues,pull_requests |
| 57 | + |
| 58 | +# Provide token via flag |
| 59 | +github-mcp-server compare-scopes --token=ghp_yourtoken |
| 60 | + |
| 61 | +# Get JSON output |
| 62 | +github-mcp-server compare-scopes --output=json |
| 63 | + |
| 64 | +# Use the convenience script |
| 65 | +script/compare-scopes --toolsets=all |
| 66 | +``` |
| 67 | + |
| 68 | +### Example Output |
| 69 | + |
| 70 | +When all scopes are present: |
| 71 | +``` |
| 72 | +PAT Scope Comparison |
| 73 | +==================== |
| 74 | +
|
| 75 | +Token Scopes: |
| 76 | + • repo |
| 77 | + • read:org |
| 78 | +
|
| 79 | +Required Scopes: |
| 80 | + • read:org |
| 81 | + • repo |
| 82 | +
|
| 83 | +Comparison Result: |
| 84 | + ✓ Token has all required scopes! |
| 85 | +
|
| 86 | +Configuration: 5 toolset(s), read-only=false |
| 87 | +Toolsets: context, issues, pull_requests, repos, users |
| 88 | +``` |
| 89 | + |
| 90 | +When scopes are missing: |
| 91 | +``` |
| 92 | +PAT Scope Comparison |
| 93 | +==================== |
| 94 | +
|
| 95 | +Token Scopes: |
| 96 | + • read:org |
| 97 | +
|
| 98 | +Required Scopes: |
| 99 | + • read:org |
| 100 | + • repo |
| 101 | +
|
| 102 | +Comparison Result: |
| 103 | + ✗ Token is missing required scopes |
| 104 | +
|
| 105 | +Missing Scopes (need to add): |
| 106 | + ✗ repo |
| 107 | +
|
| 108 | +Configuration: 5 toolset(s), read-only=false |
| 109 | +Toolsets: context, issues, pull_requests, repos, users |
| 110 | +``` |
| 111 | + |
| 112 | +## Workflow: Setting Up a New Token |
| 113 | + |
| 114 | +Use these commands together to set up a new PAT: |
| 115 | + |
| 116 | +1. **Determine required scopes** |
| 117 | + ```bash |
| 118 | + script/list-scopes --toolsets=repos,issues,pull_requests --output=summary |
| 119 | + ``` |
| 120 | + |
| 121 | +2. **Create PAT on GitHub** with the listed scopes |
| 122 | + |
| 123 | +3. **Verify the token** |
| 124 | + ```bash |
| 125 | + export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_newtoken |
| 126 | + script/compare-scopes --toolsets=repos,issues,pull_requests |
| 127 | + ``` |
| 128 | + |
| 129 | +4. **If scopes are missing**, update your PAT on GitHub and verify again |
| 130 | + |
| 131 | +## Features |
| 132 | + |
| 133 | +### Scope Hierarchy Support |
| 134 | + |
| 135 | +Both commands understand GitHub's OAuth scope hierarchy: |
| 136 | +- `repo` grants `public_repo` and `security_events` |
| 137 | +- `admin:org` grants `write:org` and `read:org` |
| 138 | +- `write:org` grants `read:org` |
| 139 | +- `project` grants `read:project` |
| 140 | +- `write:packages` grants `read:packages` |
| 141 | +- `user` grants `read:user` and `user:email` |
| 142 | + |
| 143 | +### GitHub Enterprise Support |
| 144 | + |
| 145 | +Both commands support GitHub Enterprise Server: |
| 146 | + |
| 147 | +```bash |
| 148 | +# For GitHub Enterprise Server |
| 149 | +github-mcp-server list-scopes --gh-host=github.enterprise.com |
| 150 | +github-mcp-server compare-scopes --gh-host=github.enterprise.com |
| 151 | +``` |
| 152 | + |
| 153 | +### Fine-Grained PATs |
| 154 | + |
| 155 | +Fine-grained Personal Access Tokens use a different permission model and don't return OAuth scopes. The `compare-scopes` command will detect this: |
| 156 | + |
| 157 | +``` |
| 158 | +Token Scopes: |
| 159 | + (no scopes - might be a fine-grained PAT) |
| 160 | +``` |
| 161 | + |
| 162 | +Fine-grained PATs cannot be validated with these commands. Use classic PATs (starting with `ghp_`) for OAuth scope validation. |
| 163 | + |
| 164 | +## Additional Options |
| 165 | + |
| 166 | +Both commands support the same configuration flags as the `stdio` command: |
| 167 | + |
| 168 | +- `--toolsets`: Specify which toolsets to include |
| 169 | +- `--tools`: Specify individual tools to include |
| 170 | +- `--read-only`: Restrict to read-only operations (reduces required scopes) |
| 171 | +- `--gh-host`: Use GitHub Enterprise Server |
| 172 | + |
| 173 | +For complete documentation: |
| 174 | +- `list-scopes`: See command help with `github-mcp-server list-scopes --help` |
| 175 | +- `compare-scopes`: See [docs/compare-scopes.md](docs/compare-scopes.md) for detailed guide |
0 commit comments