Skip to content

[P9] versions: make 2026-07-28 the client default - #361

Merged
jeanmatthieu merged 5 commits into
rel/1.0.0from
conformance/p9-flip
Nov 25, 2026
Merged

jeanmatthieu merged 5 commits into
rel/1.0.0from
conformance/p9-flip

Conversation

@jeanmatthieu

@jeanmatthieu jeanmatthieu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
Part P9 of P0–P35, merged into rel/1.0.0 in order (previous: P10 (#362) · next: P11 (#360))
Branch conformance/p9-flip
Base conformance/p10-docs (stacked: GitHub retargets this PR to rel/1.0.0 when the previous part merges)
Commits bd224fe versions: make 2026-07-28 the client default
c6d8750 versions: review fixes
7d0007f versions: second round of review fixes
65423e4 versions: second-pass review fixes
3bc076b versions: third-pass review fixes
Size 56 files, +518 / -293

Summary

The release step that ROADMAP.md listed as remaining. Client.Configuration.protocolMode defaults to .automatic, so a client connects with server/discover at 2026-07-28 and falls back to initialize for older servers, and Version.supported lists 2026-07-28. Version.latest stays 2025-11-25. StatefulHTTPServerTransport now validates MCP-Protocol-Version against Version.handshake explicitly, so its behavior does not change with Version.supported. Docs, snippets and tests are updated to the new defaults. A review fix keeps custom validation pipelines on the handshake revisions too: HTTPValidationContext defaults supportedProtocolVersions to Version.handshake instead of the widened Version.supported. The guides state the cost of the new default against handshake-only servers: one extra request per connection.

Motivation

Changes

Library

  • Sources/MCP/Base/Versioning.swift: Version.supported = Set(handshake + stateless). Version.latest is unchanged (v2025_11_25); its doc comment now says it is the newest handshake revision, the version initialize requests and the default MCP-Protocol-Version of session-based HTTP.
  • Sources/MCP/Client/Client.swift: Client.Configuration.init(strict:protocolMode:logLevel:discoveryTimeout:multiRoundTrip:) defaults protocolMode to .automatic, and init(from:) decodes a configuration without protocolMode as .automatic; ProtocolMode.automatic is documented as the default.
  • Sources/MCP/Base/Transports/HTTPServer/StatefulHTTPServerTransport.swift: every validation context (POST, GET, DELETE, and the sessionless context of a 2026-07-28 request, which the transport answers with -32022) passes supportedProtocolVersions: Set(Version.handshake) instead of Version.supported.
  • Sources/MCP/MCP.docc/MCP.md: the client discovers a 2026-07-28 server and falls back to the handshake.

Docs and snippets

  • CLAUDE.md: Version.supported, the .automatic default and the handshake test helper.
  • docs/src/migration.src.md: two rows in the summary table (Client, Version.supported), a "Clients connect at 2026-07-28" section with the migration-handshake-client snippet to keep the old behavior; the opt-in snippet migration-opt-in-client and the "default is still .handshake" note are removed.
  • docs/src/rough_edges.src.md: "Defaults that will change" is replaced by a "Versions" note that Version.latest is not the newest revision (Version.stateless[0] is).
  • docs/src/protocol_versions.src.md, client.src.md, protocol.src.md, quick_start.src.md, troubleshooting.src.md: state .automatic as the default and the new Version.supported; generated docs/*.md and README.md regenerated.
  • ROADMAP.md: "Remaining release step" removed; the revision table shows 2026-07-28 as the client default. VERSIONING.md and design/design.md describe the new defaults and the rationale.
  • Snippets drop the explicit .automatic where it is now the default (QuickStart.swift, Protocol/Streams.swift, Protocol/Transports.swift, Protocol/Lifecycle.swift, Client/MultiRoundTrip.swift). The handshake example in Protocol/Lifecycle.swift sets .handshake explicitly. Client/Client.swift: connectWithHandshake becomes connectWithDefaults. Guides/ProtocolVersions.swift: the comments on Version.supported and the mode constants follow the new default.

Tests

  • New Tests/MCPTests/Helpers/HandshakeConfiguration.swift: Client.Configuration.handshake and .strictHandshake (test-only extension).
  • Tests written for 2025-11-25 connections pin .handshake or .strictHandshake (60 clients in CancellationTests, ClientTests, ElicitationTests, HTTPClientTransportTests, LoggingTests, ProgressTests, PromptTests, RootsTests, RoundtripTests, SamplingTests).
  • ClientConnectionFailureTests: {"strict":true} decodes with protocolMode == .automatic.

Review fixes

Validation context (bd224fe)

  • Sources/MCP/Base/Transports/HTTPServer/HTTPRequestValidation.swift: HTTPValidationContext.init(httpMethod:sessionID:isInitializationRequest:supportedProtocolVersions:) defaulted supportedProtocolVersions to Version.supported, which this PR widens to 2026-07-28. A custom pipeline for a session-based transport that relied on the default would have accepted MCP-Protocol-Version: 2026-07-28. The default is now Set(Version.handshake), the value it had before this PR; the doc comment says that a stateless transport passes Version.stateless too.

Docs

  • docs/src/migration.src.md: the HTTPValidationContext default (a custom stateless pipeline passes Version.stateless + Version.handshake), and the cost of .automatic against a server that serves only the handshake: one extra request per connection (server/discover, answered with an error, then initialize); clients that open many short connections to such servers use .handshake.
  • docs/src/protocol_versions.src.md ("Clients"): the same cost; the client does not remember which servers serve only the handshake.

Tests

  • Tests/MCPTests/StatelessServerTests.swift: new suite "HTTP validation context": a default context holds the handshake revisions only, and ProtocolVersionValidator answers MCP-Protocol-Version: 2026-07-28 with HTTP 400 and -32022 whose data.supported omits 2026-07-28.

Second round (7d0007f)

  • Sources/MCP/Base/Transports/HTTPServer/StatefulHTTPServerTransport.swift: the sessionless context that a 2026-07-28 request is validated in before its -32022 still used Version.supported, so with this PR a custom validator saw 2026-07-28 there. It now passes Set(Version.handshake), like the other contexts.
  • docs/src/migration.src.md ("Clients connect at 2026-07-28"): names the calls that behave differently on a stateless connection (notifyRootsChanged() does nothing, setLoggingLevel(_:), ping(), notifications) and links the lists in client.md and protocol_versions.md.
  • Tests/MCPTests/StatelessGatingTests.swift: "A stateless request is validated against the handshake revisions".

Diagram

flowchart TD
    subgraph pre["Before: default .handshake"]
        B1["connect"] --> B2["initialize at Version.latest"]
    end
    subgraph post["After: default .automatic"]
        A1["connect"] --> A2["server/discover at 2026-07-28"]
        A2 -->|"served"| A3["stateless connection"]
        A2 -->|"-32022 listing a stateless version"| A4["retry once with that version"]
        A4 -->|"served"| A3
        A2 -->|"other JSON-RPC error, HTTP 400/404/405, no answer in discoveryTimeout, or no stateless revision in common"| A5["initialize at Version.latest"]
        A2 -->|"other transport error"| A6["thrown"]
    end
Loading

API changes

Added

None in the library. Test-only: Client.Configuration.handshake, Client.Configuration.strictHandshake.

Changed

Symbol Change
Client.Configuration.init(strict:protocolMode:logLevel:discoveryTimeout:multiRoundTrip:) protocolMode default .handshake to .automatic; breaking (behavior)
Client.Configuration.init(from:) a configuration without protocolMode decodes as .automatic; breaking (behavior)
Version.supported Set(handshake) to Set(handshake + stateless), now contains "2026-07-28"; breaking (behavior) for code that used it as the list of initialize revisions
HTTPValidationContext.init(httpMethod:sessionID:isInitializationRequest:supportedProtocolVersions:) default supportedProtocolVersions written as Set(Version.handshake) instead of Version.supported; same value as before this PR
Version.latest value unchanged ("2025-11-25"); doc comment only

Removed

None.

Behavior changes

  • Client(name:version:) without a configuration sends server/discover at 2026-07-28 on connect. Against a server that serves it, the connection is stateless: every request carries _meta, there is no session, and the server cannot send requests to the client; it returns input-required results, which the client answers with the same handlers.
  • Against a server without a stateless revision, one that answers -32601 (or another JSON-RPC error) to server/discover, one that refuses it with HTTP 400, 404 or 405, or one that does not answer within discoveryTimeout (10 seconds), the client sends initialize as before, after one extra exchange.
  • Other transport errors from server/discover (401 and 403 after the authorization attempts, 408, 429, 5xx, URLError) are thrown; the client does not try initialize.
  • A saved Client.Configuration without protocolMode decodes as .automatic.
  • Client.Configuration(protocolMode: .handshake) keeps the previous behavior.
  • Version.supported.contains("2026-07-28") is true. Version.negotiate still returns only handshake revisions, because it also checks Version.handshake.
  • StatefulHTTPServerTransport accepts the same MCP-Protocol-Version values as before (handshake revisions). StatelessHTTPServerTransport already used Version.stateless + Version.handshake.
  • A custom validation pipeline that builds HTTPValidationContext with the default supportedProtocolVersions accepts the handshake revisions only, as before.

Conformance

No baseline changes. The conformance client chooses its mode from MCP_CONFORMANCE_PROTOCOL_VERSION (conformanceProtocolMode), so the default flip does not change what the harness sees.

Leg Before (P10) After (P9)
2025-11-25 0 / 0 0 / 0
2026-07-28 0 / 0 0 / 0
default 25 / 11 25 / 11

All three legs pass against their baselines; tier score 100% for client and server at 2025-11-25 and 2026-07-28.

Tests

  • VersioningTests: Version.supported has five entries including 2026-07-28 and equals Set(Version.handshake + Version.stateless).
  • ClientSnippetTests: "connect discovers 2026-07-28 by default" (stateless result at 2026-07-28) and new "connect falls back to initialize by default" (handshake-only server, 2025-11-25).
  • GuidesSnippetTests: version lists and Client.Configuration().protocolMode == .automatic; the migration test covers makeHandshakeClient() against a handshake-only server and a server that serves both eras; WireLog now records server/discover first.
  • ProtocolSnippetTests, ServerSnippetTests: the clients that check handshake-only behavior pin .handshake; explicit .automatic removed. ClientSnippetTests configures handshake-only servers with protocolVersions: Version.handshake where a test needs 2025-11-25 (roots).
  • StatelessServerTests "HTTP validation context": the default context and the -32022 answer for a 2026-07-28 header (review fix).
  • ClientConnectionFailureTests: a saved configuration without protocolMode decodes as .automatic.
  • swift test at 7d0007f: 844 swift-testing tests in MCPTests and 100 snippet tests, all passed.

Review notes

  • Version.latest stays a handshake revision on purpose: it is the version initialize requests and the initial MCP-Protocol-Version of HTTPClientTransport. Deriving it as supported.max() would have made 2026-07-28 the initialize version. docs/rough_edges.md documents that the newest revision is Version.stateless[0].
  • Pinning StatefulHTTPServerTransport to Version.handshake keeps sessions on handshake revisions; 2026-07-28 requests belong on StatelessHTTPServerTransport.
  • .automatic falls back on any JSON-RPC error from server/discover, on HTTP 400/404/405 and on discoveryTimeout (P4 ([P4] client: connect with server/discover at 2026-07-28 #367)), so servers that answer the unknown method with another error code, or refuse a request without a session, still connect. Other transport errors are thrown, so a handshake-only server that answers server/discover with 5xx fails connect in the default mode.
  • The 60 pinned test clients exercise 2025-11-25 paths (server-to-client requests, sessions, logging/setLevel) that do not exist on a stateless connection. The tests keep covering the handshake; new default-mode coverage is in ClientSnippetTests.

Verification

swift build
swift test
swift test --filter SnippetTests
swift scripts/weave.swift --check
swift package generate-documentation --target MCP --warnings-as-errors
BIN=$(swift build --show-bin-path)
"$BIN/HelloClient" "$BIN/HelloServer"
export npm_config_registry=https://registry.npmjs.org
scripts/run-conformance.sh --bin-path "$BIN"
scripts/run-conformance.sh --spec-version 2025-11-25 --bin-path "$BIN"
scripts/run-conformance.sh --spec-version 2026-07-28 --bin-path "$BIN"
scripts/run-conformance.sh --requirements 2025-11-25 --bin-path "$BIN"
scripts/run-conformance.sh --requirements 2026-07-28 --bin-path "$BIN"

State: the branch builds and passes swift test (784 swift-testing tests plus the XCTest suites, all passed); swift scripts/weave.swift --check passes; DocC builds with --warnings-as-errors; the three conformance legs pass at their baselines, and the tier score is 100% at both revisions.


AI usage disclosure: the changes, the tests, the commit messages and this description were written with Claude Opus 5.5 and reviewed by the authors.

The release step that ROADMAP.md listed as remaining.
`Client.Configuration.protocolMode` defaults to `.automatic`, so a
client connects with `server/discover` at 2026-07-28 and falls back to
`initialize` for older servers, and `Version.supported` lists
2026-07-28. `Version.latest` stays 2025-11-25.
`StatefulHTTPServerTransport` now validates `MCP-Protocol-Version`
against `Version.handshake` explicitly, so its behavior does not change
with `Version.supported`. Docs, snippets and tests are updated to the
new defaults. Custom validation pipelines stay on the handshake
revisions too: `HTTPValidationContext` defaults
`supportedProtocolVersions` to `Version.handshake` instead of the
widened `Version.supported`. The guides state the cost of the new
default against handshake-only servers: one extra request per
connection.
- Say in the protocol versions guide and the migration guide that a
  server which does not answer requests sent before initialize delays
  an .automatic connect by up to discoveryTimeout (10 seconds by
  default), and that .handshake or a shorter timeout avoids the wait.
- Pin the CompletionTests clients to the handshake, check that they
  negotiate 2025-11-25, and add a completion case with the default mode
  that runs at 2026-07-28, so both paths stay covered after the flip.
- Run the initialize-hook rejection tests with a client in both the
  handshake and the default mode: a default client against a server
  with only an initialize hook falls back to initialize and is refused
  there, instead of connecting statelessly past the hook.
- Name the release in VERSIONING.md, the docs index and the design
  note instead of "this major version".
- StatefulHTTPServerTransport validates a sessionless request against
  Version.handshake, the revisions it serves, instead of
  Version.supported, which now lists 2026-07-28. A custom validator
  sees the same versions as before this change, and the context no
  longer follows Version.supported. Test: "A stateless request is
  validated against the handshake revisions".
- The migration guide names the calls that behave differently on a
  stateless connection (notifyRootsChanged(), setLoggingLevel(_:),
  ping(), notifications) and links the full lists in client.md and
  protocol_versions.md.
- The protected-pipeline snippet test builds its HTTPValidationContext
  with the default supported versions, the handshake revisions, instead
  of Version.supported, which now lists 2026-07-28. It matches what
  StatefulHTTPServerTransport passes to the pipeline.
- The Clients section of the protocol versions guide linked the
  migration guide "for opting in", but .automatic is now the default.
  The link points at "Clients connect at 2026-07-28" and says it
  explains how to keep the handshake behavior.
canarik
canarik previously approved these changes Nov 25, 2026

@canarik canarik 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.

Thank you @jeanmatthieu

Base automatically changed from conformance/p10-docs to rel/1.0.0 November 25, 2026 12:39
@jeanmatthieu
jeanmatthieu dismissed canarik’s stale review November 25, 2026 12:39

The base branch was changed.

@jeanmatthieu
jeanmatthieu merged commit e52c3d6 into rel/1.0.0 Nov 25, 2026
@jeanmatthieu
jeanmatthieu deleted the conformance/p9-flip branch November 25, 2026 12:39
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.

2 participants