mcp: streamable client keeps the session ID from a rejected server/discover, so the fallback initialize fails
メンテナーはふだん 1 日以内に返信
評価
この 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?
Client.Connect over StreamableClientTransport fails with mismatching session IDs against a legacy (2025-06-18) server that answers server/discover with HTTP 200, a JSON-RPC -32601 error, and an Mcp-Session-Id header.
streamableClientConn.Write stores the session ID from the rejected discover response. The fallback initialize is then sent with that ID, the server assigns a new one, and the session-ID check in streamable.go fails. Servers that reject server/discover with HTTP 400 are not affected, because checkResponse returns before the header is read.
Expected: the fallback initialize is sent without a session ID, and the session uses the ID returned with the InitializeResult. Under 2025-11-25 a session ID is assigned "on the HTTP response containing the InitializeResult", and 2026-07-28 has no sessions, so a session ID on a server/discover response should not be kept.
How to reproduce
// The server sets Mcp-Session-Id: discover-session on its -32601 reply to server/discover,
// and Mcp-Session-Id: initialize-session on its reply to initialize.
cs, err := mcp.NewClient(impl, nil).Connect(ctx, &mcp.StreamableClientTransport{Endpoint: url}, nil)
// err: mismatching session IDs "discover-session" and "initialize-session"
Where did you hit this?
An MCP gateway that uses go-sdk to list and call tools on third-party remote MCP servers.
Go MCP SDK version
v1.8.0 (also on main at 328036e)
Go version
go1.26
Proposed fix
Skip storing the session ID when the request is server/discover. I have a one-line change with a table test covering the 200/-32601 case and the existing HTTP 400 rejection shapes, and I'm happy to send it if this is assigned to me.
AI disclosure: I used Claude Code to trace the code and draft this report, and I reviewed it.
- 主要言語
- Go
- スター
- 5.3k
- フォーク
- 614
- 平均マージ
- 23時間 55分
- マージ済み PR(30日)
- 62
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/go-sdk のほかの issue
-
mcp: typed tool handlers lose wrapped JSON-RPC errors再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
modelcontextprotocol/go-sdk#1529 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
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: ClientSession.ReadResource keeps uncacheable and expired results until the session ends再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
modelcontextprotocol/go-sdk#1526 ·
メンテナーはふだん 1 日以内に返信
-
auth: OAuth client rejects protected resource metadata when the MCP server URL has a query string対応中かも @beiryu が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
modelcontextprotocol/go-sdk#1519 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`ping` and `logging/setLevel` still sent for protocol 2026-07-28対応中かも @nahapetyan-serob が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
modelcontextprotocol/go-sdk#1518 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/go-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
evener-transcript-v2-upgrade tool still scans transcript files through bufio's 4 KiB default bufferオープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
prime-radiant-inc/evener#6370 ·
メンテナーはふだん 1 日以内に返信
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ManageIQ/manageiq-pods#1476 ·
メンテナーはふだん 1 日以内に返信