Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into any
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Bắt đầu tại mcp/streamable_headers.go và đọc extractName, hàm giải mã params để lấy tên cho tools/call và prompts/get. Thay đổi cấu trúc giải mã để chỉ đọc tên, sau đó thêm hoặc chạy kiểm thử hồi quy cho các đối số số học nằm ngoài phạm vi qua Streamable HTTP. Hoàn thành khi client có thể đặt Mcp-Name và server chấp nhận, điều phối lời gọi mà vẫn giữ nguyên các đối số.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 5.4k
- Fork
- 623
- Merge trung bình
- 22 giờ 10 phút
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/go-sdk
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/go-sdk#1557 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensionsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởneeds investigation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/go-sdk#745 · 13 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 18/100
modelcontextprotocol/go-sdk#1555 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requestsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/go-sdk#1552 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mcp: stateless subscriptions/listen stream can start with an unrequested tools/list_changedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
modelcontextprotocol/go-sdk#1551 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/go-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/dubbo-admin#1659 ·
Maintainer thường phản hồi trong vòng 8 ngày
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behindCó thể đã có người làm @arshil42 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Packaging: support mise-en-placeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100