v1.8.0
This release is equivalent to v1.8.0-pre.2. Thank you to those who tested the pre-release.
In this release we introduce several fixes and improvements on top of v1.7.0. It adds no new protocol revision: the supported set is unchanged, and 2026-07-28 remains the newest version the SDK negotiates.
The bulk of the work is hardening the transports against resource exhaustion, closing session leaks, deadlocks and teardown hangs found by users running the new protocol at scale, and giving servers explicit control over which protocol versions they advertise.
Two behavior changes are guarded by new MCPGODEBUG flags; see the section below.
Hardening against resource exhaustion
Every decoding path that buffers incoming input is now bounded. JSON payloads are rejected past 1000 levels of nesting, before the parser recurses. Both SSE readers cap the bytes buffered for a single event via MaxEventSize on SSEClientTransport and StreamableClientTransport, and the stdio transport caps a single JSON-RPC frame via StdioTransport.MaxLineLength.
On the OAuth side, dynamic client registration responses are bounded to 1 MB, and the discovery code now validates metadata documents rather than trusting them.
Restricting the protocol versions a server supports
ServerOptions.SupportedProtocolVersions lets a server narrow the set of versions it advertises and negotiates. The list can only narrow, never widen; naming a version the SDK does not implement panics at construction.
Relatedly, a stateful streamable handler receiving a 2026-07-28 request now returns that same JSON-RPC error instead of a plain-text 400, so the client can renegotiate down instead of losing the connection.
- mcp: allow restricting the protocol versions a server supports by
@guglielmo-san (#1199)
- mcp: return json-rpc error on stateful server serving protocolVersion20260728 requests by
@guglielmo-san (#1143)
- mcp: limit SSE discover supportedVersions to SSE-defined revisions by
@arimu1 (#1121)
- mcp: prefer the negotiated protocol version over the request context by
@gwyszynski-sa (#1163)
- mcp: export ClientSessionOptions.ProtocolVersion by
@arimu1 (#1127)
Per-request cache control
ServerOptions.SetCacheable is a new hook that decides the ttlMs and cacheScope fields of every result carrying them: server/discover, the four list methods, and resources/read. It runs once per result, after the handler returns, with the values that handler produced, so it can set a policy globally while still letting an individual handler override it. Anything left unset falls back to the protocol default of public.
Behavior changes guarded by MCPGODEBUG
Two new escape-hatch flags restore the previous behavior of the changes above. Both will be removed in v1.9.0.
plaintextstatefulrejection=1 — restore the plain-text http.Error 400 body a stateful StreamableHTTPHandler previously returned for a request carrying per-request metadata. The default is now a JSON-RPC -32022 CodeUnsupportedProtocolVersion error with an UnsupportedProtocolVersionData payload advertising the legacy versions the server supports. Introduced by #1143.
blockingcancelnotify=1 — restore the previous behavior where a cancelled call waits synchronously for notifications/cancelled to be delivered (up to 5s) before returning, joining any delivery error into the caller's error. The default now retires the call immediately and sends the notification asynchronously. Introduced by #1151.
Options below were removed, according to plan:
seterroroverwrite
enableoriginverification
disablecontenttypecheck
... (truncated)