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 开始,阅读 extractName,它会解码 params 以获取 tools/call 和 prompts/get 的名称。更改解码结构,使其只读取名称,然后添加或运行一个回归测试,验证通过 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 分钟
- 30 天内合并 PR
- 30
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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可能重新可做 关联的 PR 已关闭且未合并。 未关闭needs investigation
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/go-sdk#745 · 13 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 18/100
modelcontextprotocol/go-sdk#1555 ·
维护者通常 1 天内回复
-
mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requests可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
modelcontextprotocol/go-sdk#1552 ·
维护者通常 1 天内回复
-
mcp: stateless subscriptions/listen stream can start with an unrequested tools/list_changed可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 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