refactor(governance): consolidate ruleset tools with dynamic scope ch… · github/github-mcp-server@f340ea4 · GitHub
Skip to content

Commit f340ea4

Browse files
refactor(governance): consolidate ruleset tools with dynamic scope challenges
Rebase onto main (which now includes #3128's per-call OAuth scope checks) and redesign the ruleset tools around that API instead of the old tool-name-keyed challenge middleware that motivated splitting by level. - Collapse the 5 level-specific tools (repository_ruleset_read, organization_repository_ruleset_read, create_repository_ruleset, create_organization_repository_ruleset, create_enterprise_repository_ruleset) into 2: repository_ruleset_read and create_repository_ruleset. Both take a "level" argument (repository/organization/enterprise) and use scopes.DynamicChallenge to return the exact repo / read:org / admin:org / read:enterprise / admin:enterprise challenge for that call, using the scope hierarchy so a broader granted scope still satisfies the challenge. - A missing or unrecognized "level" (or a non-string value) returns no challenge so normal handler argument validation produces the error, instead of prompting for scopes on a malformed call. - Keep repository_ruleset_read and create_repository_ruleset as separate tools since ReadOnlyHint-based read-only filtering depends on that split. - Add enterprise-level "get" and "list" read support (list issued directly via GET /enterprises/{enterprise}/rulesets, matching the existing rule suite pattern, since go-github has no typed wrapper for it) so all three levels have symmetric read coverage. - Re-add read:enterprise/admin:enterprise to pkg/scopes as opt-in (non-default) OAuth scopes, alongside admin:org which no tool had previously requested, and register them in oauthScopeDefinitions so they are advertised in OAuth protected-resource metadata. - Fetch the "law" toolset icon into the new icons_data_uris.txt embed (required_icons.txt already listed it) and bump go-github v87 -> v89 to match main. - Update README/toolsnaps via script/generate-docs and UPDATE_TOOLSNAPS. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a1bf6c3 commit f340ea4

14 files changed

Lines changed: 906 additions & 777 deletions

README.md

Lines changed: 25 additions & 44 deletions

docs/scope-filtering.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Some scopes implicitly include others:
6363

6464
- `repo` → includes `public_repo`, `security_events`
6565
- `admin:org` → includes `write:org` → includes `read:org`
66+
- `admin:enterprise` → includes `read:enterprise`
6667
- `project` → includes `read:project`
6768

6869
This means if your token has `repo`, tools requiring `security_events` will also be available.

pkg/github/__toolsnaps__/create_enterprise_repository_ruleset.snap

Lines changed: 0 additions & 101 deletions
This file was deleted.

pkg/github/__toolsnaps__/create_organization_repository_ruleset.snap

Lines changed: 0 additions & 101 deletions
This file was deleted.

pkg/github/__toolsnaps__/create_repository_ruleset.snap

Lines changed: 26 additions & 7 deletions

0 commit comments

Comments
 (0)