Skip to content

mcp: fail Ping fast on 2026-07-28 sessions - #1378

Merged
guglielmo-san merged 7 commits into
modelcontextprotocol:mainfrom
azilber:fix/ping-fail-fast-new-protocol
Oct 15, 2026
Merged

guglielmo-san merged 7 commits into
modelcontextprotocol:mainfrom
azilber:fix/ping-fail-fast-new-protocol

Conversation

@azilber

@azilber azilber commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Updates #1377. Follow-up to #1249 / #1174 / #1130, which closed the missing-_meta reports as by design because the 2026-07-28 protocol schema removes ping.

This change completes that ruling on the client side: on sessions negotiated at 2026-07-28, Ping now returns a *jsonrpc.Error with CodeMethodNotFound without a round trip, instead of sending the removed method and surfacing whatever the server does with it.

  • Corrected (per review): on lenient servers a params-less ping currently succeeds (it takes the legacy path and skips the removed-method branch), so this is a behavior change for that case — as any fix in this area must be, since injecting _meta would equally convert the ping into a new-protocol request that hits the removed-method branch. On strict transports both forms fail today: meta-less with -32020 header-mismatch, meta-injected with MethodNotFound (live evidence: mcp.svelte.dev).
  • The error message mirrors the server's own phrasing for removed methods and names the capability list requests that do verify liveness (tools/list, resources/list, prompts/list).
  • The cmd test's readiness check now relies on the connect itself (handshake or discovery round trip), since ping is unavailable on those sessions.
  • Verified by TestClientPingRemovedOnNewProtocol, which uses a plain Connect (in-memory transports negotiate 2026-07-28 via server/discover) and asserts the typed error, its code, and that no ping request is sent.

azilber and others added 2 commits October 12, 2026 12:35
Follow-up to modelcontextprotocol#1249, modelcontextprotocol#1174, and modelcontextprotocol#1130: ping was removed from the
2026-07-28 protocol schema, so a ping sent on a session negotiated at
2026-07-28 can never succeed. Today the client sends the removed method
anyway and surfaces the server's rejection - either MethodNotFound at
dispatch, or -32020 CodeHeaderMismatch at transports that validate
header/meta consistency for a meta-less request (observed against
mcp.svelte.dev).

Ping now returns a descriptive local error on 2026-07-28 sessions
without a round trip, pointing at the capability list requests that do
verify liveness. No working behavior is lost: every such ping fails
today. The cmd test's readiness check now relies on the connect itself,
since ping is unavailable on those sessions.

Verified by TestClientPingRemovedOnNewProtocol, which simulates a
2026-07-28 session and asserts no ping request is sent.

Signed-off-by: Alexey Zilber <AlexeyZilber@gmail.com>
@guglielmo-san

Copy link
Copy Markdown
Contributor

@azilber thank you for reporting this. Contrary to what I said in previous issues that were opened relatively to this case, I might see now the advantage of injecting the _meta also for Ping method. This would allow to have the same failure for both stdio and streamable.
What do you think?

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azilber, two lines in the body do not match what I see in memory: "every 2026-07-28 ping fails today" and "cannot be reproduced against the SDK's own server". A default Client.Connect over NewInMemoryTransports negotiates 2026-07-28, and Ping succeeds on main. Ping sends params=null, so handle sees a legacy request and skips its removed-method branch. tools/list on the same session carries the envelope. From a scratch test outside the diff, with a receiving middleware on the server:

$ go test ./mcp/ -run TestZZProbePing -count=1 -v      # go1.27.1
== main @ 8c761a2
    usesNew=true
    server got ping params=null
    ping err=<nil>
    server got tools/list params={"_meta":{...,"io.modelcontextprotocol/protocolVersion":"2026-07-28"}}
== PR @ 0b57f53
    usesNew=true
    ping err=mcp: ping is not supported on 2026-07-28 sessions (the method was removed); verify liveness with tools/list, resources/list, or prompts/list
    server got tools/list params={"_meta":{...,"io.modelcontextprotocol/protocolVersion":"2026-07-28"}}
$ go test ./... -count=1      # probe file removed
main @ 8c761a2: ok  	github.com/modelcontextprotocol/go-sdk/mcp	32.965s
PR @ 0b57f53:   ok  	github.com/modelcontextprotocol/go-sdk/mcp	33.261s

blocking, if you keep this direction: return a *jsonrpc.Error with CodeMethodNotFound, not a fmt.Errorf. docs/protocol.md promises that code. The server also sends it for a ping that carries the new-protocol meta, so callers match one error with errors.As.

non-blocking: plain Connect already lands on 2026-07-28, and the cmd_test.go change relies on that too. TestClientPingRemovedOnNewProtocol can drop the cs.state write and its comment about the 2025-11-25 cap.

non-blocking: the Ping note in internal/docs/protocol.src.md still says the server answers MethodNotFound. With this change the client answers first, and docs/protocol.md regenerates from that source.

@guglielmo-san, the ping that works in memory today is the missing-envelope behavior from #1249, which you closed as by design. This PR turns it into a local error. Is that the direction you want for #1377?

@azilber

azilber commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks both — and thanks for the correction, @chrikrah: you're right that today's in-memory ping succeeds (params=null takes the legacy path and skips the removed-method branch), so "no working behavior is lost" in my description was wrong for lenient servers. Both directions under discussion end that success: injecting _meta converts the ping into a new-protocol request, which then hits the removed-method branch too (I prototyped that first — it's what flipped cmd_test from pong to MethodNotFound).

On @guglielmo-san's question — I'd still lean fail-fast, for one main reason: injecting the SEP-2575 _meta stamps the request as following 2026-07-28, for a method 2026-07-28 deleted. Both approaches reach the same terminal state on spec-correct servers (live check against mcp.svelte.dev: with _meta injected, the -32020 goes away and the MethodNotFound remains — the server has no ping), but fail-fast gets there without the round trip and lets the error name the liveness alternatives. Per the blocking note I'll return *jsonrpc.Error with CodeMethodNotFound rather than fmt.Errorf, matching docs/protocol.md.

That said, the consistency argument for _meta (no client-side special casing; servers decide) is a real one, and the direction is squarely a #1377 call — happy to revise to whichever the WG prefers; the diff is ~10 lines either way. If fail-fast stands I'll also apply the non-blocking nits (drop the state write, fix the comment wording).

azilber and others added 2 commits October 13, 2026 11:51
Ping's removed-method guard now returns *jsonrpc.Error with
CodeMethodNotFound, matching the documented error contract and the
server's own phrasing for removed methods. The test drops its manual
state write: a plain Connect over in-memory transports negotiates
2026-07-28 via server/discover, and asserts the typed error and that no
ping request is sent. The doc comment now describes the lenient-server
behavior (params-less pings currently succeed via the legacy path).

Signed-off-by: Alexey Zilber <AlexeyZilber@gmail.com>
Comment thread mcp/client.go Outdated
if cs.usesNewProtocol() {
return &jsonrpc.Error{
Code: jsonrpc.CodeMethodNotFound,
Message: fmt.Sprintf("%q is not supported in the new protocol; verify liveness with tools/list, resources/list, or prompts/list",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would remove the "verify liveness" part, both in the error and in the comment above

@guglielmo-san

Copy link
Copy Markdown
Contributor

@azilber ok lets proceed with the fail fast

Per review: the error and doc comment now match the server's phrasing
exactly; naming replacement liveness checks belongs to callers, not the
SDK.

Signed-off-by: Alexey Zilber <AlexeyZilber@gmail.com>
@azilber

azilber commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Done — proceeding with the fail-fast per your ruling, and the "verify liveness" hint is removed from both the error message and the doc comment (67f44db); the message now matches the server's phrasing exactly. Naming replacement liveness checks is left to callers — in our CLI that mapping (ping → first declared capability list) lives client-side anyway.

Happy to make any further adjustments; otherwise this is ready for another look whenever convenient.

Comment thread mcp/client.go Outdated
Comment on lines +1265 to +1270
//
// On sessions negotiated at protocol version 2026-07-28 or later, Ping
// returns a [jsonrpc.Error] with code [jsonrpc.CodeMethodNotFound] without a
// round trip: the 2026-07-28 protocol schema removes the ping method. (A
// ping sent without per-request _meta is additionally rejected by transports
// that validate header/meta consistency, with -32020.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//
// On sessions negotiated at protocol version 2026-07-28 or later, Ping
// returns a [jsonrpc.Error] with code [jsonrpc.CodeMethodNotFound] without a
// round trip: the 2026-07-28 protocol schema removes the ping method. (A
// ping sent without per-request _meta is additionally rejected by transports
// that validate header/meta consistency, with -32020.)
//
// On sessions negotiated at protocol version 2026-07-28 or later, Ping
// returns a [jsonrpc.Error] with code [jsonrpc.CodeMethodNotFound] without a
// round trip: the 2026-07-28 protocol schema removes the ping method.

@guglielmo-san

Copy link
Copy Markdown
Contributor

Let's also update the internal/docs/protocol.src.md as still says "the server returns MethodNotFound (-32601) for ping"

Per review: the doc comment drops the _meta/-32020 parenthetical, and
the protocol documentation now describes the client-side behavior - Ping
returns MethodNotFound locally, without a round trip - instead of
attributing the error to the server. docs/protocol.md regenerated via
go generate ./internal/docs.

Signed-off-by: Alexey Zilber <AlexeyZilber@gmail.com>
@azilber

azilber commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Both applied in 852eafd:

  • The Ping doc comment is now exactly the suggested two sentences (the _meta/-32020 parenthetical is gone).
  • internal/docs/protocol.src.md no longer attributes the error to the server: the note now reads "when a session negotiates 2026-07-28 or later, Ping returns MethodNotFound (-32601) locally, without a round trip, and KeepAlive should not be enabled." docs/protocol.md regenerated with go generate ./internal/docs.

No behavior change; tests unchanged.

@guglielmo-san
guglielmo-san merged commit 37ebae3 into modelcontextprotocol:main Oct 15, 2026
10 checks passed
@azilber
azilber deleted the fix/ping-fail-fast-new-protocol branch October 15, 2026 16:01
jmrplens added a commit to jmrplens/gitlab-mcp-server that referenced this pull request Dec 4, 2026
Moves `github.com/modelcontextprotocol/go-sdk` from v1.8.0 to v1.9.0
(released 2026-11-30, no new protocol revision) and takes in everything
the release changes for this server: the pins that fail on it, the
workarounds it makes unnecessary, and the pages that describe the old
behaviour. The dependency sweep in #1985 held go-sdk at v1.8.0 for this
change.

## What v1.9.0 changes, and what changed here

| go-sdk change | Here |
| --- | --- |
| A handler or middleware error with no JSON-RPC code goes out as
`-32603` with its text, no longer as code 0
([#1407](modelcontextprotocol/go-sdk#1407)) |
Correct per JSON-RPC, adopted. The carried-channel tests in
`internal/tenancy` expect `-32603` (plain error and load shedding at
2025-11-25); the Refusal channels section of the tenant policy spec,
`Validate`'s "no code" reason, the `CodedError` comment and the
subscriptions page (EN and ES) say so |
| `-32022` (unsupported protocol version) is answered with HTTP 400 in
both eras | Correct per the transport spec, adopted. `sdkStatus` maps it
in both eras; the spec says which statuses an in-band error takes. No
register row emits `-32022` |
| A typed nil result from a middleware is answered `null` at 2026-07-28
instead of ending the process | The test is renamed
`TestTypedNilResult_FromAMiddleware_IsAnsweredNullInBothEras` and still
runs each era in a child process; the spec keeps "a refusal is always an
error" with the new reason |
| Results a middleware returns are labeled with `resultType` like the
dispatcher's
([#1226](modelcontextprotocol/go-sdk#1226), for
[#1225](modelcontextprotocol/go-sdk#1225)) |
Workaround retired: `internal/toolutil/result_type.go` and its tests are
deleted, and the rate limiter, `heldRequestsRefusal` (its `req`
parameter dropped) and both toolvisibility middlewares return their
refusals as built. RTC-001, AUT-007, AUT-008 and the F-20 paragraph say
the SDK labels them. `test/e2e/http/result_type_test.go` and the
fine-grained e2e case still hold the label on the wire, and pass |
| The client's `Ping` fails locally on a 2026-07-28 session, which
removed ping
([#1378](modelcontextprotocol/go-sdk#1378)) |
Test-only: `pingWithin` in `cmd/server` asks `server/discover` on such a
session. The server's keepalive stays off; nothing in production changes
|
| The client passes the input requests of a multi round-trip result
through its own receiving middleware as `elicitation/create`
([#1479](modelcontextprotocol/go-sdk#1479)) |
Test-only: `callAs` in `language_test.go` counts the
`elicitation/create` requests the server sends at the transport |
| The multi round-trip interaction is chosen by the negotiated version,
and input requests answered on a session negotiated below 2026-07-28 are
fulfilled by the SDK with `elicitation/create`
([#1266](modelcontextprotocol/go-sdk#1266), for
[#1258](modelcontextprotocol/go-sdk#1258)) |
`internal/elicitation.FlowFromRequest` keeps reading the version the
request states (the SDK exposes no negotiated one per request, and
reconciles the two), with its comment rewritten.
`test/e2e/stdio/elicitation_declared_version_test.go` is no longer a pin
of an SDK defect: it asserts the legacy flow, a first question sent as
`elicitation/create`, and a result with no `resultType` or
`inputRequests`, and a second case accepts the title and the description
and checks that the third question asks for the labels, so the SDK's
fulfillment carries every answer and the signed state. The elicitation
page (EN and ES) says the negotiated version decides |
| Streamed POST responses are kept alive by the SDK, committing the
headers after an interval of silence
([#1477](modelcontextprotocol/go-sdk#1477), for
[#1262](modelcontextprotocol/go-sdk#1262)) |
`streamableHTTPOptions` passes `StreamKeepAlive: sseKeepAliveInterval`
(25 s), and `sseAwareWriter` no longer heartbeats a POST response, so a
stream never carries two; it still clears the write deadline and keeps
the standalone GET alive. A silent tool call now gets bytes on the wire
before its result. The unit and e2e keep-alive tests assert that; the
HTTP server, remote deployment and troubleshooting pages (EN and ES)
drop the "a silent tool call gets no keep-alive" advice, and the spec
notes that a keep-alive committed POST takes a protocol error as an
event at 200 |
| `MCPGODEBUG` switches removed, among them `customresnotfounderrcode`
and `noprotocolerrorbody` | `subscriptions.isResourceNotFound` compares
against `jsonrpc.CodeInvalidParams` (no deprecated variable, no
`nolint`, and `internal/subscriptions` no longer imports `mcp`); the
dead `noprotocolerrorbody` skip in `session_not_found_test.go` is gone |
| `mcp.HasParams`
([#1269](modelcontextprotocol/go-sdk#1269), for
[#1261](modelcontextprotocol/go-sdk#1261)) |
Adopted: `mcpotel.paramsOf` and the e2e harness drop their reflect
checks |
| Notifications go to each session on a goroutine of their own
([#1228](modelcontextprotocol/go-sdk#1228)) and
`_meta` is cloned per session
([#1490](modelcontextprotocol/go-sdk#1490)) |
Already allowed for by `sessionOwners.sendingMiddleware`; its comments,
ADR-0020 (whose "what in the go-sdk this rests on" section is
re-verified against v1.9.0) and the resource hot spots page say it is
released |
| A second listen on a URI no longer clobbers the first
([#1360](modelcontextprotocol/go-sdk#1360), for
[#1359](modelcontextprotocol/go-sdk#1359));
`Subscribe` awaits the listen in the background and clears its entry
when it ends
([#1283](modelcontextprotocol/go-sdk#1283), for
[#1169](modelcontextprotocol/go-sdk#1169)) |
The resubscribe caveat in the e2e harness (on `TrySubscribe`,
`Subscription.Close` and the subscription's cleanup) is retired; the
subscriptions and troubleshooting pages (EN and ES) describe the v1.9.0
client. A resubscribe during the earlier listen's teardown is now
something a client does, and it exposed a race in `sessionBridge`: the
unsubscribe released the last hold and stopped the watch with nothing
held between the two, so a resubscribe joining in that gap was
acknowledged on a stopped watch. The subscribes and unsubscribes of one
watch now run under a lock per session and URI (a waiting subscribe
gives up with its request), pinned by
`TestSessionBridge_ResubscribeDuringTeardown_KeepsTheWatch`, which fails
without it |
| The cancellation reason reaches the handler as the context's cause
([#1255](modelcontextprotocol/go-sdk#1255), for
[#1254](modelcontextprotocol/go-sdk#1254)) |
Not logged: it is text the client writes. The `wasCancelled` comment
says so instead of saying it cannot be read |

Version mentions move to v1.9.0 in CLAUDE.md, the Copilot and agent
instructions, the architecture, HTTP server, subscriptions and
troubleshooting pages (EN and ES), the tenancy package, ADR-0020 and
ADR-0027. `docs/development/upstream-bugs.md` records every go-sdk row
that shipped in v1.9.0 and what it retired; the rows still open upstream
(malformed messages, `notifications/cancelled` for a listen, the client
after a 404) keep their pins, which pass. CLAUDE.md and
`test/e2e/README.md` now name two go-sdk pins, `listen_end_test.go` and
`session_not_found_test.go`.

## Upstream changes this release ships

Ours: [#1266](modelcontextprotocol/go-sdk#1266),
[#1267](modelcontextprotocol/go-sdk#1267) (stdio
at 2026-07-28; HTTP still answers a cancelled call),
[#1255](modelcontextprotocol/go-sdk#1255),
[#1268](modelcontextprotocol/go-sdk#1268),
[#1269](modelcontextprotocol/go-sdk#1269),
[#1360](modelcontextprotocol/go-sdk#1360),
[#1490](modelcontextprotocol/go-sdk#1490),
[#1273](modelcontextprotocol/go-sdk#1273),
[#1274](modelcontextprotocol/go-sdk#1274).

Others' that this server tracked:
[#1477](modelcontextprotocol/go-sdk#1477),
[#1242](modelcontextprotocol/go-sdk#1242),
[#1464](modelcontextprotocol/go-sdk#1464),
[#1524](modelcontextprotocol/go-sdk#1524),
[#1226](modelcontextprotocol/go-sdk#1226),
[#1283](modelcontextprotocol/go-sdk#1283).

## Left for a decision

- **Request id on spans**
([#1464](modelcontextprotocol/go-sdk#1464)):
`Request.GetID` makes `jsonrpc.request.id` recordable, but the id is the
client's own value and the telemetry page and the collector privacy
suite promise no client-controlled value on a span. Not adopted.
- **Per-session resource updates**
([#1524](modelcontextprotocol/go-sdk#1524)):
`ServerSession.NotifyResourceUpdated` could deliver to an owner's
2026-07-28 sessions directly; legacy `resources/subscribe` sessions
still need the sending middleware, so this is an optimisation, not a
retirement.
- **`OnRequestSummary`** and the opt-in
`MCPGODEBUG=demotesessionlifecyclelog=1` are not used.

## Verification

Run on the branch, through the remote runner unless noted:

- `go build ./...`, `go vet -tags e2e,stdioe2e,httpe2e ./...`
- `go test ./internal/... ./cmd/... -count=1`: green except
`cmd/orbit_fixtures`, which reads git and fails only because the remote
copy is not a repository (it passes in CI)
- stdio and HTTP transport e2e modules against a binary built from the
branch: both green
- `golangci-lint`, `govulncheck`, `check-tenancy`, `check-supply-chain`,
the 1:1 audit scopes (`sdk`, `paths`, `grants`, `required`, `params`,
`routes`, `enums`), `check-audit-1to1-baseline`, `check-testing-docs`,
`check-md-tables`, `check-doc-links`, `check-doc-tool-names`,
`check-e2e-static` and the test-shape, i18n, escaping, action-id, godoc
and surface-quality gates
- locally: `check-file-headers`, `check-em-dash`, `check-dco`,
`check-pr-description`, the site's `i18n:check`, `build` and `lint`,
markdownlint on the changed Markdown
- The branch is rebased on main after #1985 landed, with client-go
v3.60.0 and the rest of that sweep, and again after #1987 (R-ROUTE wave
4, 38 new actions) landed. Wave 4 uses none of the helpers this bump
retires, and only the testing reference needed regenerating. On the tree
rebased onto #1987: `go build`, `go vet` with every e2e tag, the unit
suite (with the request inventory recorded from it, which comes out
unchanged), both transport e2e modules, `golangci-lint`, `govulncheck`,
the seven 1:1 scopes, the baseline, `check-supply-chain`,
`check-tenancy`, the generated-artifact gates CI runs, the local gates
and the site gates. All pass
- `go test -race` over `cmd/server` and `internal/subscriptions`
- The release rehearsal (`release.yml` dispatched on dc520bb, before
the rebase onto #1987) passed every job. That includes the Docker GitLab
e2e gate, which drives the real binary through the go-sdk
`ClientSession` this bump changes, the race gates, the reproducible
build and every publisher's dry run. Dispatched again on the rebased
head 6f9fcfd, it passed all 20 jobs.

---------

Signed-off-by: José M. Requena Plens <mail@jmrp.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants