github modelcontextprotocol/go-sdk v1.9.0-pre.1

pre-release29 minutes ago

In this release we introduce fixes, hardening, and small API additions on top of v1.8.0. It adds no new protocol revision: 2026-07-28 remains the newest version the SDK negotiates.

Most changes tighten spec compliance (standard JSON-RPC error codes, exact JSON number decoding without float64 rounding, SEP-2243 HTTP headers, MRTR, and OAuth/OIDC validation), bound peer-controlled inputs, and add hooks for stream keep-alives, per-session notifications, and middleware.

Eight new MCPGODEBUG flags let you revert individual behavior changes, and seven flags from v1.7.0 are removed as scheduled; see below.

Hardening

HTTP clients no longer follow cross-origin or method-changing redirects unless the http.Client sets its own CheckRedirect (StreamableClientTransport, SSEClientTransport, and OAuth requests). The stdio frame cap now holds across arbitrary read boundaries, CommandTransport gains MaxLineLength, StreamableClientTransport applies DefaultMaxEventSize when unset, and ParseWWWAuthenticate runs in linear time. On the client, the prompts/list, resources/list, resources/templates/list, and resources/read caches are capped at 512 entries each and no longer retain results with ttlMs <= 0.

Streams, per-session notifications, and middleware APIs

StreamableHTTPOptions.StreamKeepAlive sends periodic SSE comments on idle POST response streams (30s by default; negative disables) so proxies do not drop subscriptions/listen or slow calls.
ServerSession.NotifyToolListChanged, NotifyPromptListChanged, NotifyResourceListChanged, and NotifyResourceUpdated notify a single 2026-07-28 session's open subscriptions/listen streams.
StreamableHTTPOptions.OnRequestSummary, HasParams, and Request.GetID (ClientRequest.ID / ServerRequest.ID) expose request metadata to middleware and observability hooks.
ClientSession.Discover, ParseURLElicitationRequiredError, and Annotations.SetPriority / HasPriority (to serialize an explicit 0 priority).

Behavior changes guarded by MCPGODEBUG

The new flags below revert the corresponding change (except demotesessionlifecyclelog, which is opt-in). All will be removed in v1.11.0; see docs/mcpgodebug.md for details.

  • structuredcontentfloat64=1 — decode numbers in CallToolResult.StructuredContent as float64 instead of json.Number (#1239).
  • disablepromptargsvalidation=1 — call the prompt handler even when a required argument is missing instead of returning -32602 (#1297).
  • allowmissingclientparams=1 — accept elicitation/create, notifications/elicitation/complete, and notifications/resources/updated with missing or null params (#1315).
  • nopreinitinvalidrequest=1 — refuse pre-initialize requests on legacy sessions with code 0 instead of -32600 (#1393).
  • nointernalerrorcode=1 — send handler errors carrying no code with code 0 instead of -32603 (#1407).
  • fatalnewprotocolerrors=1 — fail the streamable client connection when an independent 2026-07-28 request fails (#1353).
  • followallredirects=1 — follow cross-origin and method-changing HTTP redirects (#1440).
  • demotesessionlifecyclelog=1 (opt-in) — emit per-session lifecycle logs at debug level instead of info (#1208).

Options below were removed, according to plan:

  • customresnotfounderrcode
  • hintomitempty
  • allowsessionsinstateless
  • nomethodnotfoundcodeinerror
  • noprotocolerrorbody
  • nowrapinvalidparams
  • disablecompleteparamsvalidation

The removal of plaintextstatefulrejection and blockingcancelnotify, added in v1.8.0, was postponed to v1.10.0.

Other Changes to the SDK

Spec compliance, JSON numbers, and SEP-2243 headers:

  • mcp: preserve structured content number precision by @CaliLuke (#1239)
  • mcp: preserve number precision during schema validation by @guglielmo-san (#1462)
  • fix: support exact JSON number decoding for large request IDs above 2^53 by @guglielmo-san (#1401)
  • mcp: preserve explicit null structured content across transport by @Tangerg (#1285)
  • mcp: omit structured output from error results by @Ilyuha888 (#1397)
  • internal/json: decode in place instead of through a streaming Decoder by @raveesh-me (#1454)
  • mcp: reject prompts/get requests missing a required argument by @po-et (#1297)
  • mcp: reject server messages missing required params on the client by @fadiroot (#1315)
  • mcp: answer a request sent before initialize with Invalid Request by @talhayme (#1393)
  • mcp: refuse a call on a legacy session before initialize by @jmrplens (#1273)
  • mcp: send handler errors that carry no code as Internal error by @talhayme (#1407)
  • internal/jsonrpc2: send error response when result fails to marshal by @beiryu (#1400)
  • mcp: report an error when a sampling or elicitation handler returns nil by @po-et (#1304)
  • mcp: send an empty result, not null, for a nil tool, prompt or completion result by @po-et (#1301)
  • mcp: send empty arrays for completions and prompts with nothing to return by @po-et (#1290)
  • mcp: preserve required text field when marshaling empty ResourceContents by @shoemoney (#1149)
  • mcp: marshal ResourceNotFoundError data as JSON by @kerthans (#1427)
  • mcp: label resultType on results that bypass the dispatcher by @roncodingenthusiast (#1226)
  • mcp: reject null entries in InputRequests during unmarshaling by @guglielmo-san (#1398)
  • mcp: reject null titled enum entries in elicitation schemas by @jyotir-aditya (#1447)
  • mcp: accept titled multi-select items that declare type string by @jyotir-aditya (#1312)
  • mcp: apply defaults to null tool arguments by @pkarpovich (#1343)
  • mcp: reject legacy-format requests on 2026-only servers by @Enigmage (#1345)
  • mcp: fail Ping fast on 2026-07-28 sessions by @azilber (#1378)
  • mcp: do not require Mcp-Method on notifications by @toledompm (#1504)
  • mcp: accept empty Mcp-Param-* and Mcp-Name header values by @po-et (#1289)
  • mcp: decode a Base64-wrapped Mcp-Name before comparing it to the body by @arpankernel (#1242)
  • mcp: base64-encode a non-header-safe Mcp-Name by @akashjainn (#1246)
  • fix(mcp): process singleton headers correctly by @yarolegovich (#1459)

Sessions, transports, cancellation, subscriptions, and MRTR:

  • mcp: prevent a failed request from breaking a stateless streamable client by @jeongukjae (#1353)
  • mcp: re-list and retry tools/call on HeaderMismatch by @nahapetyan-serob (#1502)
  • mcp: keep a delivered response when the caller's context is cancelled by @vbcherepanov (#1370)
  • mcp: bind peer cancellation before request ID reuse by @skosovsky (#1390)
  • mcp: carry a cancelled notification's reason as the request's cancel cause by @jmrplens (#1255)
  • mcp: send no response for a cancelled request on 2026-07-28 stdio sessions by @jmrplens (#1267)
  • mcp: wrap ErrConnectionClosed for notifications and interrupted calls by @Jackmeson1 (#1449)
  • refactor: simplify errors on connection closed by @guglielmo-san (#1468)
  • mcp: make waiting for the ioConn write lock cancelable by @Tangerg (#1499)
  • mcp: cancel pending keepalive ping when the session closes by @vshalpnjabi (#1478)
  • mcp: notify sessions concurrently so one stalled peer cannot starve the rest by @yhxlele (#1228)
  • mcp: notify every listen held open on a session by @jmrplens (#1490)
  • mcp: retire only the subscriptions a listen registered by @cgair (#1275)
  • mcp: retire a listen's subscriptions only while they are its own by @jmrplens (#1360)
  • mcp: clear a resource subscription when its listen stream ends by @jeremy (#1283)
  • mcp: route multi round-trip input requests through client receiving middleware by @guglielmo-san (#1479)
  • mcp: repeat legacy multi-round-trip rounds until the handler completes by @SergeevDmitry (#1355)
  • mcp: retry input-required results that carry only requestState by @SergeevDmitry (#1365)
  • mcp: do not cache resources/read results of multi round-trip retries by @vbcherepanov (#1371)
  • mcp: choose the interaction pattern from the negotiated protocol version by @jmrplens (#1266)
  • mcp: allow nil params for ListRoots inputRequests by @guglielmo-san (#1517)
  • fix(mcp): use internaljson for mrtr by @yarolegovich (#1458)
  • mcp: avoid mutating client request parameters by @ar8327 (#1473)
  • mcp: reuse server selection for new streamable requests by @Adebayo120 (#1414)
  • fix: use server protocol version instead of context in streamable delivery by @guglielmo-san (#1491)
  • mcp: record the negotiated protocol version on every path that records one by @jmrplens (#1274)
  • mcp: classify the per-request protocol version by membership by @jmrplens (#1268)
  • mcp: clear the caller's protocol version for the initialize handshake by @gwyszynski-sa (#1165)
  • mcp: ignore the session ID on server/discover responses by @simon0191 (#1523)
  • mcp: forward session state through LoggingTransport by @Zhuoxi2000 (#1434)
  • mcp: accept custom methods over the SSE transport by @fadiroot (#1292)
  • mcp: detach SSE client event stream from the Connect context by @beiryu (#1403)
  • mcp: preserve SSE events buffered after the endpoint by @yyydddkkk (#1270)
  • mcp: read a colon-less SSE line as a field with an empty value by @gu-feng418 (#1374)
  • mcp: parse SSE field values per the SSE spec by @surlymochan (#1412)
  • mcp: skip non-message events in SSEClientTransport by @MaxFreedomPollard (#1439)
  • mcp: ignore notification in stdio batches by @guglielmo-san (#1277)
  • mcp: gate session lifecycle log demotion behind MCPGODEBUG by @anneheartrecord (#1208)
  • mcp: map custom slog levels to the nearest lower MCP level in LoggingHandler by @kaankucukx (#1446)
  • mcp: log a keepalive session close at Warn, not Error by @oplatonov (#1282)
  • mcp: log warnings when writing responses to disconnected clients fails by @guglielmo-san (#1469)
  • mcp: remove unused middleware for url elicitation by @guglielmo-san (#1494)
  • fix(mcp): name the offending path in computeURIFilepath localize error by @PratikDhanave (#1381)
  • fix(mcp): use %v and ID.Raw() for jsonrpc response summary by @PratikDhanave (#1382)
  • mcp: remove MCPGODEBUG options scheduled for removal in v1.9.0 by @guglielmo-san ([#1533])

Authorization (auth, auth/extauth, oauthex):

  • auth: re-authorize when the access token expires without a refresh token by @luiacuaniello (#1418)
  • auth: reuse the dynamically registered client across authorizations by @luiacuaniello (#1419)
  • auth: require PKCE only in the authorization code flows by @luiacuaniello (#1465)
  • oauthex: require S256 PKCE support in GetAuthServerMeta by @akshita317 (#1327)
  • auth/extauth: fix token source lifetime and concurrent access in the handlers by @luiacuaniello (#1432)
  • auth/extauth: send resource in client credentials token requests by @shlee1223 (#1451)
  • auth/extauth: only forward an ID-JAG to the MCP authorization server by @akshita317 (#1438)
  • auth/extauth: validate the RFC 9207 iss in PerformOIDCLogin by @akshita317 (#1442)
  • conformance: run the client credentials scenario by @luiacuaniello (#1433)
  • auth: strip a terminating slash from the issuer before building metadata URLs by @MaxFreedomPollard (#1245)
  • auth: check token expiry before required scopes by @ilaigold (#1350)
  • auth: reject userinfo, fragments, and dot segments in client ID URLs by @ilaigold (#1362)
  • auth: use Bearer challenges for resource metadata by @jay23606 (#1396)
  • mcp: include insufficient_scope error in WWW-Authenticate header for StatusForbidden by @guglielmo-san (#1421)
  • auth: include error="invalid_token" in 401 challenges by @xianshujun (#1507)
  • oauthex: encode and decode client metadata "jwks" as a JSON object by @kerthans (#1435)
  • oauthex: keep challenges apart after a quoted value ending in a backslash by @akshita317 (#1307)
  • oauthex: allow whitespace around "=" in auth-params after a comma by @akshita317 (#1322)
  • oauthex: accept an empty quoted-string auth-param value by @akshita317 (#1344)
  • oauthex: accept empty list elements in WWW-Authenticate by @akshita317 (#1351)
  • oauthex: accept token68 challenges in WWW-Authenticate by @akshita317 (#1357)
  • internal/authutil: treat an empty scope in a token response as absent by @akshita317 (#1308)
  • oauthex: build defaultDiscoveryTransport lazily instead of at import by @kilarusravankumar (#1278)
  • examples: check token audience and set UserID in auth examples by @kanywst (#1388)

Docs, conformance scripts, and CI:

New Contributors

Full Changelog: v1.8.0...v1.9.0

Don't miss a new go-sdk release

NewReleases is sending notifications on new releases.