mcp: batch without MCP-Protocol-Version is accepted when SupportedProtocolVersions excludes 2025-03-26
维护者通常 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?
With ServerOptions.SupportedProtocolVersions limited to versions without JSON-RPC batching (2025-06-18 and later), the Streamable HTTP handler still accepts a batch sent without the MCP-Protocol-Version header and runs every call in it. The same batch with MCP-Protocol-Version: 2025-03-26 is rejected as an unsupported version.
servePOST falls back to 2025-03-26 when the header is missing, and the batch check compares only that fallback with 2025-06-18. It does not consider which versions the server supports.
Expected: 400 for the header-less batch when no supported version allows batching, as with the explicit 2025-03-26 header. Single messages without the header (such as initialize) should keep working.
I have a fix with a regression test and would like to send it as a PR if this is assigned to me.
I used Claude Code (AI) to investigate this and draft the report; I reviewed it.
How to reproduce
package main
import (
"log"
"net/http"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
func main() {
server := mcp.NewServer(&mcp.Implementation{Name: "repro", Version: "v0.0.1"}, &mcp.ServerOptions{
SupportedProtocolVersions: []string{"2026-07-28", "2025-11-25", "2025-06-18"},
})
handler := mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server { return server },
&mcp.StreamableHTTPOptions{Stateless: true, JSONResponse: true})
log.Fatal(http.ListenAndServe("127.0.0.1:8080", handler))
}
// BODY='[{"jsonrpc":"2.0","id":1,"method":"ping"},{"jsonrpc":"2.0","id":2,"method":"ping"}]'
// curl -s http://127.0.0.1:8080 -H 'Content-Type: application/json' \
// -H 'Accept: application/json, text/event-stream' -d "$BODY"
//
// No header: 200 [{"jsonrpc":"2.0","id":2,"result":{}},{"jsonrpc":"2.0","id":1,"result":{}}]
// MCP-Protocol-Version: 2025-03-26: 400 Bad Request: Unsupported protocol version (supported versions: 2026-07-28,2025-11-25,2025-06-18)
// MCP-Protocol-Version: 2025-06-18: 400 JSON-RPC batching is not supported in 2025-06-18 and later
Where did you hit this?
A public read-only documentation MCP server (stateless Streamable HTTP, JSON responses) where we wanted to stop accepting legacy JSON-RPC batches.
Go MCP SDK version
v1.8.0 (also reproduced on main at 0e849cb)
Go version
go version go1.27.1 darwin/arm64
Logs
No response
- 主要语言
- 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 天内回复
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into any可能重新可做 @beiryu 于 10 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/go-sdk#1534 · 1 条评论 ·
维护者通常 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 天内回复
查看 modelcontextprotocol/go-sdk 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 70/100
compiler-explorer/compiler-explorer#9738 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
evilmartians/lefthook#1674 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复