auth: RequireBearerToken omits error="invalid_token" when a presented token is rejected
メンテナーはふだん 1 日以内に返信
@xianshujun がすでに取り組んでいます。
2026年11月5日 から。
評価
この issue はまだ評価されていません。
説明
Checklist
- I searched the existing issues, and this has not been reported before.
- This is a real problem that I ran into myself, using the latest release of the SDK.
- I ran into it in a production system, not in a toy example, a benchmark, or an automated or AI-driven scan of the code.
- I (a human) examined the relevant SDK code, and wrote or reviewed every line of this report. It is not unreviewed AI output.
- This report is brief and concise, and sticks to the facts needed to understand the problem.
What happened?
#1134 asked for both RFC 6750 §3.1 error codes in the WWW-Authenticate challenge: insufficient_scope on the 403, and invalid_token on the 401 for a rejected token. #1421 added only insufficient_scope, and #1135, which added both, was closed as a duplicate of #1134 (comment), so the invalid_token half was dropped.
On main, a presented token that the verifier rejects with ErrInvalidToken, or that has expired, still gets a 401 whose challenge is the same as for a request with no credentials:
WWW-Authenticate: Bearer resource_metadata="...", scope="..."
RFC 6750 §3.1 says this challenge should carry error="invalid_token", while §3 says a request with no credentials should carry no error code. With one header for both, a client cannot tell a rejected token from missing credentials.
How to reproduce
- Wrap a handler with
RequireBearerToken(verifier, &RequireBearerTokenOptions{ResourceMetadataURL: "https://example.com/.well-known/oauth-protected-resource", Scopes: []string{"read"}}), whereverifierreturnsErrInvalidToken. - Send a request with
Authorization: Bearer some-token. - The response is 401 with
WWW-Authenticate: Bearer resource_metadata="...", scope="read", the same header a request without anAuthorizationheader gets.
Expected: the challenge for the rejected token also carries error="invalid_token". The challenge for the request without credentials stays as it is.
Where did you hit this?
ThunderID's MCP server (https://github.com/thunder-id/thunderid) protects its /mcp endpoint with RequireBearerToken. We track the endpoint's RFC 6750 conformance in thunder-id/thunderid#4509.
Go MCP SDK version
v1.8.0. Also checked main at f91620f.
Go version
1.27.2
Logs
N/A
- 主要言語
- Go
- スター
- 5.3k
- フォーク
- 607
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 82
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/go-sdk のほかの issue
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensions再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンneeds investigation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/go-sdk#745 · コメント 13 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
mcp: whether MaxLineLength rejects a message depends on how the stream is read対応中かも @Tangerg が今日担当しました。 オープン
modelcontextprotocol/go-sdk#1509 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
modelcontextprotocol/go-sdk#1506 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
mcp: closing a session right after a cancelled call drops notifications/cancelled, so the server handler keeps running対応中かも @vshalpnjabi が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
modelcontextprotocol/go-sdk#1505 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
mcp: a canceled write on IOTransport/StdioTransport cannot leave the write queue対応中かも @Tangerg が 1 日前に担当しました。 オープン
modelcontextprotocol/go-sdk#1498 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/go-sdk の issue をすべて見る
似ている issue
-
enhancement needs:sonnet ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/TypeScript#65370 ·
メンテナーはふだん 1 日以内に返信
-
docs: data-ownership invites vendors to build add-ons around the OS対応中かも @brandli が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
gentian-org/gentian-os#894 ·
メンテナーはふだん 1 日以内に返信
-
bug tech debt testing
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws/amazon-vpc-cni-k8s#3976 ·
メンテナーはふだん 1 日以内に返信
-
bug raised-by:desk
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
medici-finance/assay#5678 ·
メンテナーはふだん 1 日以内に返信