`ping` and `logging/setLevel` still sent for protocol 2026-07-28

未关闭
#1,518 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@nahapetyan-serob 已经在做这个了。

开始于 2026年11月13日。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
65/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
api, backend

调研方向

Start in the client session methods ClientSession.Ping and ClientSession.SetLoggingLevel, then read the keepalive loop and the protocol-version negotiation path. Check how other requests handle protocol metadata and how server.go rejects removed methods. Done means these calls and keepalive do not send unsupported methods for protocol 2026-07-28, and the session remains usable afterward.

由索引模型根据 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?

SEP-2575 (protocol 2026-07-28) removed ping and logging/setLevel. The SDK's own server rejects them on the new protocol (server.go, the case methodInitialize, methodPing, ..., methodSetLevel branch). On the client side, however, ClientSession.Ping and ClientSession.SetLoggingLevel still send them on a session that negotiated 2026-07-28:

  • the Mcp-Protocol-Version: 2026-07-28 header is set (the streamable transport falls back to the negotiated version);
  • unlike ListTools, CallTool, etc., neither method calls injectRequestMeta, so the body has no params._meta envelope. Ping goes out as {"jsonrpc":"2.0","id":N,"method":"ping"}.

A strict 2026-07-28 server such as python mcp 2.3.0 answers HTTP 400 / -32602 ("params._meta must be an object carrying the required 'io.modelcontextprotocol/protocolVersion' and 'io.modelcontextprotocol/clientCapabilities' envelope keys"). With the envelope present it answers HTTP 404 / -32601. In both cases streamableClientConn.Write treats the non-2xx as fatal and calls c.fail(err), so the whole session is closed. Every later request fails with client is closing: sending "ping": ... Bad Request.

Anything that pings for liveness or keepalive (for example ClientOptions.KeepAlive, or an application health check) therefore kills a healthy session against such servers.

Reproduce
See below.

Expected

On a session with ProtocolVersion >= 2026-07-28, Ping and SetLoggingLevel should not put a removed method on the wire. Returning a client-side error, for example "ping is not supported in protocol 2026-07-28", would let callers fall back. The keepalive loop should likewise not use ping on such sessions. Adding _meta alone would not fix this, because the methods no longer exist and the server answers 404, which also closes the session.

Workaround

Check sess.InitializeResult().ProtocolVersion and, on 2026-07-28 sessions, use a supported request (for example tools/list) for liveness, and skip SetLoggingLevel.

How to reproduce
1. Run a python `mcp` 2.3.0 server (for example FastMCP 4.0.11, `http_app(stateless_http=True)`).

2. Connect with go-sdk: `server/discover` succeeds and `2026-07-28` is negotiated.

3. `sess.ListTools(ctx, nil)` succeeds.

4. `sess.Ping(ctx, nil)` returns `... envelope keys: Bad Request`.

5. `sess.ListTools(ctx, nil)` now returns `connection closed: ... client is closing ...`.
Where did you hit this?

In production at work.

Go MCP SDK version

1.7

Go version

latest

Logs
No logs available.
主要语言
Go
星标
5.3k
派生
614
平均合并
23 小时 55 分钟
30 天内合并 PR
62

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/go-sdk 的其他 Issue

查看 modelcontextprotocol/go-sdk 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。