Support declaring a token's granted permissions/scopes up front for tool pre-filtering (stdio config + HTTP header)
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- go
- 领域
- api, authorization, cli
调研方向
从 #2676 中的 CreateToolPermissionFilter 和现有的 pkg/scopes 过滤开始,然后跟踪 stdio OAuth 路径和 HTTP 请求处理。完成的标准是:一个有文档记录的 grant 声明能够在 stdio 模式和按请求处理的 HTTP 模式下为两个过滤器提供输入,同时缺少声明时保留 fail-open 行为,且运行时授权保持不变。
由索引模型根据 Issue 内容生成。
描述
Problem
We filter tools by what a token can do in only a few narrow cases today:
- Classic PATs (
ghp_) — we read theX-OAuth-Scopesresponse header and hide tools requiring scopes the token lacks. - OAuth login (stdio) — we filter by the requested OAuth scopes (default set hides nothing; a narrower
--oauth-scopesfilters).
For everything else we fail open and show every tool:
- Fine-grained PATs and GitHub App installation tokens do not advertise their granted permissions in a way we can read up front.
- The FGP requirement subsystem from #2676 ships dormant in OSS precisely because there is no grant source —
CreateToolPermissionFilter(granted)fails open on a nilgranted.
The result: a token that physically cannot perform an action still surfaces the tool, so the model discovers the limitation only by calling it and getting a 403. We already know the catalog of what each tool needs (#2676/#2679); what's missing is a way to tell the server what the token actually has.
Proposal
Let the operator declare the token's granted permissions/scopes up front, independent of OAuth, so we can pre-filter tools against the FGP catalog (#2676) and the classic scope catalog (pkg/scopes):
- stdio: a config flag / env var, e.g.
--granted-permissions/GITHUB_GRANTED_PERMISSIONS(fine-grained) and/or--granted-scopes/GITHUB_GRANTED_SCOPES(classic). Applies regardless of whether the token came from a PAT, a GitHub App installation token, or OAuth. - HTTP mode: a request header (e.g.
X-MCP-Granted-Permissions) carrying the same declaration per request, so a remote host that already knows the caller's grant can drive filtering without us re-deriving it.
When a grant declaration is present, feed it as the granted source to CreateToolPermissionFilter (FGP) and to the existing scope filter, so tools the token cannot use are hidden. When absent, keep today's fail-open behavior.
Caveats (call out in the design)
This is deliberately flagged as a sharp-edged feature:
- Manual and messy interface. Enumerating fine-grained permissions + levels (read/write/admin) by hand is verbose and error-prone. The format needs thought — a flat
perm:levellist is ugly; anything richer is heavy for a CLI flag / header. - No validation against the real token. A declared grant can drift from what the token actually has. Over-declaring hides nothing it shouldn't but re-introduces the 403-on-call surprise; under-declaring hides usable tools. We are trusting the operator's declaration.
- Two vocabularies. Classic scopes vs fine-grained permissions are different models; we'd need to be explicit about which a given token uses (and possibly support both).
- It is a pre-filter for ergonomics/safety, not an authorization boundary — GitHub still enforces the real permissions server-side.
Context / related
- #2676 — declarative FGP requirement subsystem (catalog +
CreateToolPermissionFilter, ships dormant; this issue is the grant-source piece that's out of scope there). - #2679 — expand per-tool FGP annotations.
- Existing classic-scope filtering for
ghp_PATs and OAuth requested scopes (stdio). - OAuth stdio stack (in progress) — OAuth can only filter by requested scopes, and even then we don't know the granted set from the app alone; this issue is the general, OAuth-independent mechanism.
Out of scope
- Auto-deriving grants from the token (not generally possible for fine-grained PATs / installation tokens).
- Any change to runtime per-call authorization — GitHub remains the enforcement point.
- 主要语言
- Go
- 星标
- 33.1k
- 派生
- 5k
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 25
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/github-mcp-server 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
github/github-mcp-server#3235 ·
-
enhancement
难度 1/5 1 小时以内 新手友好度 88/100
github/github-mcp-server#3042 · 2 条评论 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
github/github-mcp-server#3032 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 74/100
github/github-mcp-server#2803 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
github/github-mcp-server#2740 ·
查看 github/github-mcp-server 的全部 Issue
相似的 Issue
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
kind/bug status/0-triage
难度 2/5 1-3 小时 新手友好度 75/100
-
🤔 refinement needed
难度 2/5 1-3 小时 新手友好度 75/100
equinor/radix-operator#1979 ·