Skip to content

ClientSession.Ping omits the SEP-2575 per-request _meta envelope on 2026-07-28 sessions #1174

Closed

Description

@ta1kun

What happened

ClientSession.Ping does not inject the SEP-2575 per-request _meta envelope, so on a session that negotiated protocol revision 2026-07-28 every ping goes out malformed and a conformant server rejects it.

Observed against two independent servers:

Invalid params: the MCP-Protocol-Version header names protocol revision 2026-07-28,
but the request is missing the required per-request envelope key(s): _meta: Bad Request
missing or invalid _meta field "io.modelcontextprotocol/protocolVersion": Bad Request

The second wording is this SDK's own server-side validation (streamable.go, the metaVersion == "" branch), so a go-sdk client pinging a go-sdk server fails against itself.

Cause

Every other client method guards on usesNewProtocol() and calls injectRequestMeta:

func (cs *ClientSession) ListTools(ctx context.Context, params *ListToolsParams) (*ListToolsResult, error) {
	if cs.usesNewProtocol() {
		...
		params = injectRequestMeta(cs, params)
	}
	result, err := handleSend[*ListToolsResult](ctx, methodListTools, newClientRequest(cs, orZero[Params](params)))

Ping does not:

func (cs *ClientSession) Ping(ctx context.Context, params *PingParams) error {
	_, err := handleSend[*emptyResult](ctx, methodPing, newClientRequest(cs, orZero[Params](params)))
	return err
}

Scanning client.go v1.7.0 for methods that reach handleSend without injectRequestMeta finds four:

  • Ping
  • SetLoggingLevel
  • Subscribe
  • Unsubscribe

Why it matters

Tool calls carry the envelope and keep working, so the server is healthy the whole time — only the liveness probe fails. Any client that treats a failed ping as "upstream unreachable" will tear down and re-establish a perfectly good session on every probe interval. In our deployment one upstream accumulated ~1060 reconnects on a two-minute cycle before we traced it here.

Reproduction

Connect a client to a server that requires the new protocol (a go-sdk StreamableHTTPHandler with Stateless: true will do), then:

session, _ := client.Connect(ctx, &mcp.StreamableClientTransport{Endpoint: srv.URL}, nil)
_, err := session.ListTools(ctx, nil) // succeeds — envelope injected
err = session.Ping(ctx, nil)          // fails — envelope missing

Suggested fix

Give Ping, SetLoggingLevel, Subscribe and Unsubscribe the same usesNewProtocol() / injectRequestMeta treatment the other methods already have.

Version: v1.7.0.

Activity

  1. guglielmo-san commented on Aug 17, 2026

    @guglielmo-san
    Contributor

    Hi @ta1kun , thank you for flagging this, the new protocolVersion does not support anymore the Ping method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions