[SPIKE] Add declarative fine-grained permission (FGP) requirement subsystem#2676
Draft
SamMorrowDrums wants to merge 1 commit into
Draft
[SPIKE] Add declarative fine-grained permission (FGP) requirement subsystem#2676SamMorrowDrums wants to merge 1 commit into
SamMorrowDrums wants to merge 1 commit into
Conversation
Mirror the existing pkg/scopes subsystem with a new pkg/permissions package so this repo is the public source of truth for the fine-grained permission each MCP tool requires. - pkg/permissions: typed Permission/Level/Scope, Requirement combinators (Require/AllOf/AnyOf/And, SatisfiedBy, Permissions), and a generated catalog (catalog_generated.go) produced from the PUBLIC github/rest-api-description app-permissions schema via gen.go. - inventory.ServerTool gains RequiredPermissions + chainable WithPermissions; zero value means "no gate" (tool always shown). - pkg/github/permission_filter.go: inventory bridge helpers and a fail-open CreateToolPermissionFilter (dormant in OSS; no granted source). - Seed hand-authored requirements for a high-signal subset of tools. - generate-docs emits a "Required Permissions (fine-grained)" line and a generated table in new docs/permissions-filtering.md; README + server configuration link it. - New list-permissions CLI + script/list-permissions. Catalog data is exclusively public (names + levels as in the REST docs and the X-Accepted-GitHub-Permissions header); enterprise permissions excluded. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SPIKE / DRAFT — iterating, not final. Adds a declarative fine-grained-permission (FGP) requirement subsystem to MCP tools, mirroring the existing
pkg/scopessubsystem, so this OSS repo becomes the public source of truth for which fine-grained permission each tool needs. A separate remote server consumes this mapping to hide tools a caller's token cannot use; that runtime/grant-source piece is out of scope here — the subsystem ships dormant in OSS.Guardrail honored
Only public data is used. The catalog is generated solely from the public
github/rest-api-description(components/schemas/app-permissions). No internal sources are referenced.What's implemented
New
pkg/permissionspackage (leaf, stdlib-only — mirrorspkg/scopes)permissions.go: typedPermission,Level(Read<Write<Adminlattice),Scope(Repo/Org/Account),PermReq, andRequirement(OR-of-AND). Combinators:Require,AllOf,AnyOf,(r).And(other),SatisfiedBy,Permissions,IsZero,String. ErgonomicPermission.Read()/.Write()/.Admin()+ParseLevel. Normalizes/dedupes for deterministic output.catalog.go+catalog_generated.go:CatalogEntry(scope + valid levels) and the generatedCatalog(54 permissions; enterprise excluded).gen.go://go:build ignoregenerator reading ONLY the public spec (go generate ./pkg/permissions).map.go:ToolPermissionMap, global get/set,UniquePermissions.Wiring
inventory.ServerToolgainsRequiredPermissions permissions.Requirement+ chainableWithPermissions(r). Zero value = no gate (always shown).NewTool/NewToolFromHandlersignatures unchanged.pkg/github/permission_filter.go:GetToolPermissionMapFromInventory,SetToolPermissionMapFromInventory,UnionPermissions, andCreateToolPermissionFilter(granted)which fails open on nil granted (OSS has no granted source).Seed per-tool requirements (high-signal subset; everything else left ungated): issues, pull requests, contents (file/branch/commit/tag), actions, code scanning (
security_events), secret scanning (secret_scanning_alerts), dependabot (vulnerability_alerts).Docs & CLI
writeToolDocemits aRequired Permissions (fine-grained)line; newdocs/permissions-filtering.mdwith a generated table between<!-- START/END AUTOMATED PERMISSIONS -->; linked from README +docs/server-configuration.md.list-permissionsCLI +script/list-permissions(text/json/summary).Deviations / stubbed (spike findings)
x-github-permissionson main; it does carry the authoritative permission catalog (names + valid levels) inapp-permissions. The generator targets that. Per-tool requirements are hand-authored (as planned), since MCP tools don't record RESToperationIds and many are composite/GraphQL.suggest-permissionsauthoring assist: omitted — no reliable public per-endpoint permission data to print.GetToolPermissionMapFromInventorylives inpkg/github, notpkg/permissions— to avoid an import cycle (inventoryimportspermissionsfor the typed field, sopermissionsmust stay a leaf). This mirrors wherescope_filter.golives.Validation
go build ./...✅script/test(race) ✅script/lint(golangci-lint) — 0 issues ✅script/generate-docsproduces a clean, committed tree ✅Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com