Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Summary

Adds a compare-scopes command that fetches a PAT's OAuth scopes and compares them against all tool requirements, reporting missing permissions and affected tools.

Why

Users need to validate their PAT has required scopes before tools fail at runtime. This enables proactive permission checks and CI validation.

What changed

  • Added compare-scopes CLI command using existing scopes.Fetcher and inventory infrastructure
  • Created script/compare-scopes convenience wrapper with error handling
  • Command displays token scopes, required scopes, missing scopes, and lists affected tools per missing scope
  • Returns exit code 1 when scopes are missing (CI-friendly)
  • Supports GITHUB_PERSONAL_ACCESS_TOKEN env var and --gh-host flag for GHES

Usage:

GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxx script/compare-scopes

Example output:

=== PAT Scope Comparison ===

Token Scopes:
  - gist
  - read:org
  - repo

Required Scopes (by tools):
  - gist
  - notifications
  - project
  - read:org
  - repo

=== Comparison Summary ===

Missing Scopes (required by tools but not granted to token):
  - notifications
    Tools affected: dismiss_notification, list_notifications, ... and 3 more
  - project
    Tools affected: add_project_item, delete_project_item, projects_write

Warning: Some tools may not be available due to missing scopes.

MCP impact

  • No tool or API changes

Security / limits

  • No security or limits impact

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Updated (README / docs / examples)
    • Added detailed usage guide in docs/scope-filtering.md
    • Added quick reference tip in README Token Security section

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/
    • Triggering command: ./github-mcp-server ./github-mcp-server compare-scopes race -buildid QqJvTexPQ_LdGmMwQDJr/QqJvTexPQ_LdGmMwQDJr -dwarf=false -goversion go1.24.11 -c=4 -race -nolocalimports -importcfg GoFi�� x64/src/runtime/-errorsas om/stretchr/test-ifaceassert (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Create a stacked pull request on top of #1750 that adds a new helper to compare a user-provided PAT’s scopes with the scopes required by the MCP server tools.

Requirements:

curl -sI -H "Authorization: Bearer $GITHUB_PERSONAL_ACCESS_TOKEN" \
  https://api.github.com/user | grep -i x-oauth-scopes
  • Parse and display the PAT’s scopes in a readable list (one per line or comma-separated) as part of the command output.
  • Invoke the existing list-scopes.sh (which lists scopes requested by the server/tools) and print those scopes alongside the PAT scopes, clearly labeled.
  • Provide a concise comparison summary highlighting scopes that are missing from the PAT but required by tools (and optionally extra scopes on the PAT).
  • Keep the implementation consistent with the inventory architecture introduced in PR feat: Add list-scopes command using inventory architecture #1750 (e.g., follow existing patterns for commands, output helpers, wiring, tests if present).
  • Add/update documentation or README snippets for the new comparison capability, including how to provide the PAT and example command usage.
  • Ensure scripts fail with a clear error when no PAT is provided and exit non-zero on fetch/parse failures.

Deliverables:

  • Code changes implementing the comparison command/option.
  • Any new or updated tests.
  • Updated documentation/examples.

Notes:

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 8, 2026 08:37
- Add new compare-scopes subcommand to github-mcp-server CLI
- Implement PAT scope comparison logic using existing scopes.Fetcher
- Create script/compare-scopes convenience wrapper
- Display token scopes, required scopes, and missing/extra scopes
- Exit with non-zero code when scopes are missing
- Support GITHUB_PERSONAL_ACCESS_TOKEN env var and --gh-host flag

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
- Simplify missing scope detection using HasRequiredScopes
- Add comprehensive tests for scope comparison logic
- Update scope-filtering.md with detailed compare-scopes usage
- Add tip in README about compare-scopes tool
- Fix lint issues (redundant newlines in fmt.Println)

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Copilot AI changed the title [WIP] Add helper to compare PAT scopes with MCP required scopes Add compare-scopes command to validate PAT permissions against tool requirements Jan 8, 2026
Copilot AI requested a review from JoannaaKL January 8, 2026 08:54
@JoannaaKL JoannaaKL closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants