Repository navigation
Conversation
auth.oauth 声明的 server 在 token 缺失/过期时静默跳过鉴权注入、把裸请求 发出去——用户看到的是服务端的 "missing required Authorization header", 排查方向被带偏到命令/网络,真正该做的是重新授权。改为发起请求前直接失败, 错误信息给出重新授权指引;provider 未注册同理。 failure-classifier 对 remote 鉴权 401 实测形态(missing required Authorization header / invalid_token / Authentication required)不命中 auth 正则,全部掉进默认 tool_error,UI 只能给通用提示。补三条特征,并把 auth suggestion 落到「重新授权」。
huiliyi37
added a commit
that referenced
this pull request
Oct 10, 2026
…uth 类——不再静默裸连 内容已经 sync 流程合入(dev 收编记录:未检索到),本提交为作者署名落账(提交页归属)。 Co-authored-by: Lin-Dongg <322679856+Lin-Dongg@users.noreply.github.com>
huiliyi37
pushed a commit
that referenced
this pull request
Oct 10, 2026
…osed,鉴权 401 归 auth 类——不再静默裸连
huiliyi37
added a commit
that referenced
this pull request
Oct 10, 2026
Owner
|
已通过 sync 流程合入 dev,感谢 @Lin-Dongg 的贡献 🎉 本 PR 的改动(fix(mcp): OAuth token 缺失 fail-closed,鉴权 401 归 auth 类——不再静默裸连)已经 sync 流程合入主仓(本次 sync),并已收录进 CONTRIBUTORS.md。 按仓库的双仓流程,公开仓 PR 不经 merge 按钮合入(保持 dev 主仓唯一事实源),现以 sync-merged 标记关闭。欢迎继续贡献! |
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.
Problem
auth.oauth声明的 MCP server 在 token 缺失/过期时静默裸连:_connectServer拿到loadMcpOAuthToken()的 null 后只是跳过鉴权注入,照样把没有 Authorization 头的请求发出去。用户看到的报错来自服务端,例如 GitHub MCP:
排查方向因此被带偏到命令/网络(UI 的通用提示是「本地服务先确认命令可执行/已安装,远程
服务确认 URL 与网络可达」),而真正该做的是重新授权。
同时
classifyMcpError对 remote 鉴权 401 的两种实测形态都不命中 auth 正则,全部掉进默认
tool_error:bad request: missing required Authorization header(GitHub MCP,无 Authorization 头){"error": "invalid_token", "error_description": "Authentication required"}(liblib MCP,Bearer 失效)——后者 UI 上直接显示
[tool_error]前缀,同样是误导。修复
auth.oauth就必须拿到凭据才发起连接。OAuth token for MCP server "<id>" is missing or expired — re-authorize this server (run \/mcp auth `, or reconnect from settings)`auth.provider未注册 → 同理不裸连,明确指向auth.provider配置。buildStdioChildEnv/ systemPathFallback 注释):声明过的凭据来源失效就大声失败,不静默降级。
authorization|invalid[_ -]?token|authentication required|bearer(两条实测文本均由此命中),suggestion 落到「re-authorize the server」。
未声明
auth、只用静态headers的 server 行为不变(生态中立,不越权拦截)。验证
missing required Authorization header归 auth 类(修复前实际为tool_error)invalid_token / Authentication required归 auth 类(同上)7.5s 后归入 network 类——静默裸连行为在测试中当场复现)
src/mcp/__tests__/全套件 151/151 通过(node --import tsx --test,exit 0)tsc --noEmit全绿;oxlint 0 errors(2 个既有 warning:unusedlower,非本改动引入)备注
鉴权 401 服务端形态的两条错误文本即取自该现场。
src/mcp/不在 CONTRIBUTING 的 Open Zone 明列目录,也不在 Review/Protected 清单——若维护者希望先走 issue 讨论,请告知,本 PR 可转为 issue 附件。