FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(scopes): allow public_repo scope for public repository write tools by CAOShurong · Pull Request #3150 · github/github-mcp-server · GitHub

fix(scopes): allow public_repo scope for public repository write tools - #3150

Open
CAOShurong wants to merge 1 commit into
github:mainfrom
CAOShurong:codex/3136-public-repo-scope
Open

fix(scopes): allow public_repo scope for public repository write tools#3150
CAOShurong wants to merge 1 commit into
github:mainfrom
CAOShurong:codex/3136-public-repo-scope

Conversation

Copy link
Copy Markdown

Summary

Fixes #3136 by lowering the required OAuth scope from repo to public_repo for the six repository write tools the issue identifies as public-repo-safe:

  • add_issue_comment
  • issue_write
  • create_branch
  • push_files
  • create_pull_request
  • fork_repository

An OAuth deployment that only needs to contribute to public repositories can now request least-privilege public_repo instead of the broad repo scope (which also grants private-repository access).

Why this is safe

  • NewTool derives AcceptedScopes through the existing hierarchy (ExpandScopes: repo is a parent of public_repo), so a full repo token still satisfies every one of these tools — no regression for existing deployments.
  • No API handler changes; GitHub continues to enforce actual per-repository permissions at the API layer. This only stops the scope filter from hiding tools that public-only tokens could legitimately use.

Testing

  • New focused coverage in pkg/github/public_repo_scope_test.go:
    • TestPublicRepoWriteToolsDeclareLeastPrivilegeScopes asserts each tool advertises required: [public_repo] and accepted: [public_repo, repo].
    • TestPublicRepoWriteToolsVisibleToPublicRepoToken asserts the PAT tool filter (CreateToolScopeFilter) shows every tool to a public_repo-only token and keeps it visible for a full repo token.
  • go build ./..., go vet ./pkg/github/ ./pkg/scopes/, gofmt clean on changed files.
  • Full go test ./pkg/github/ -count=1: no new failures vs a stash-baseline run on clean main (the 6 pre-existing environment-dependent failures reproduce identically on both).

Several repository write tools declared the broad `repo` scope, which hid
them from tokens limited to `public_repo` and forced public-only OAuth
deployments to request private-repository access.

Lower the required scope to public_repo for tools that only operate on
repositories the token can already reach:

- add_issue_comment
- issue_write
- create_branch
- push_files
- create_pull_request
- fork_repository

Because RequiredScopes are expanded through the scope hierarchy, a full
repo token remains accepted for every tool. GitHub continues to enforce
actual per-repository permissions at the API layer.

Fixes github#3136
CAOShurong requested a review from a team as a code owner August 24, 2026 12:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Allow public_repo scope for public repository write tools

2 participants


Back | FazBrowse Home | New Git URL