Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into any
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- go
調査の方向性
mcp/streamable_headers.go から始めて、tools/call と prompts/get の名前を取得するために params をデコードする extractName を読みます。名前だけを読み取るようにデコードの形式を変更し、Streamable HTTP 経由で範囲外の数値引数を扱う回帰テストを追加するか実行します。クライアントが Mcp-Name を設定でき、サーバーが引数を保持したまま呼び出しを受け入れてディスパッチできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Under protocol version 2026-07-28, a tools/call whose arguments contain a valid JSON number outside float64's range (for example {"n":1e1000}) fails over Streamable HTTP before it reaches the tool handler. This happens on both the client and the server side.
Cause
extractName (mcp/streamable_headers.go) gets the tool name for the Mcp-Name header by unmarshaling the whole params into CallToolParams, whose Arguments field is any. Decoding 1e1000 into any fails because the number overflows float64. The error is swallowed (return "", false), so:
- client:
ClientSession.CallToolcan't setMcp-Name, and the request is rejected:missing required Mcp-Name header for method "tools/call": rejected by transport: Bad Request; - server: the same function is used to compare the header with the body (around line 382), so a request from another client that does send the header is also rejected before dispatch.
A raw ToolHandler receives Arguments as json.RawMessage and would otherwise get these bytes unchanged. Over stdio, in memory, or under an older protocol version, the same call works.
Reproduction (v1.8.0)
s := mcp.NewServer(&mcp.Implementation{Name: "s", Version: "v0"}, nil)
s.AddTool(&mcp.Tool{Name: "echo", InputSchema: json.RawMessage(`{"type":"object"}`)},
func(_ context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return &mcp.CallToolResult{Content: []mcp.Content{&mcp.TextContent{Text: string(req.Params.Arguments)}}}, nil
})
ts := httptest.NewServer(mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server { return s },
&mcp.StreamableHTTPOptions{Stateless: true, JSONResponse: true}))
defer ts.Close()
cs, _ := mcp.NewClient(&mcp.Implementation{Name: "c", Version: "v0"}, nil).
Connect(ctx, &mcp.StreamableClientTransport{Endpoint: ts.URL}, nil)
// cs.InitializeResult().ProtocolVersion == "2026-07-28"
_, err := cs.CallTool(ctx, &mcp.CallToolParams{Name: "echo", Arguments: json.RawMessage(`{"n":1e1000}`)})
// err: calling "tools/call": sending "tools/call": missing required Mcp-Name header for method "tools/call": rejected by transport: Bad Request
With {"n":12345678901234567890} the call succeeds and the handler receives the bytes unchanged, so only out-of-range numbers are affected.
Suggested fix
extractName needs only the name, so it can decode into a struct with just that field. That avoids decoding the arguments at all, which is also cheaper for large argument payloads:
case "tools/call", "prompts/get":
var p struct{ Name string `json:"name"` }
if err := internaljson.Unmarshal(params, &p); err == nil {
return p.Name, true
}
prompts/get has the same shape (its Arguments is map[string]string, so it fails differently, on non-string values).
Found while building an MCP server on the go-sdk, where a test now pins this behavior.
- 主要言語
- Go
- スター
- 5.4k
- フォーク
- 623
- 平均マージ
- 22時間 10分
- マージ済み PR(30日)
- 30
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/go-sdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
modelcontextprotocol/go-sdk#1557 ·
メンテナーはふだん 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 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
modelcontextprotocol/go-sdk#1555 ·
メンテナーはふだん 1 日以内に返信
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requests再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
modelcontextprotocol/go-sdk#1552 ·
メンテナーはふだん 1 日以内に返信
-
mcp: stateless subscriptions/listen stream can start with an unrequested tools/list_changed再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
modelcontextprotocol/go-sdk#1551 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/go-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
apache/dubbo-admin#1659 ·
メンテナーはふだん 8 日以内に返信
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behind対応中かも @arshil42 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100