Skip to content

[P20] api: the 1.0 rough edges - #351

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

jeanmatthieu merged 5 commits into
rel/1.0.0from
conformance/p20-api

Conversation

@jeanmatthieu

@jeanmatthieu jeanmatthieu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
Part P20 of P0–P35, merged into rel/1.0.0 in order (previous: P19 (#352) · next: P21 (#350))
Branch conformance/p20-api
Base conformance/p19-enums (stacked: GitHub retargets this PR to rel/1.0.0 when the previous part merges)
Commits 1a9c434 api: the 1.0 rough edges
a08e316 api: review fixes
8fc13d7 api: second-pass review fixes
136fd09 docs: say the authorizer classifies a DPoP nonce retry
af2c01c api: third-pass review fixes
Size 83 files, +1643 / -1028

Summary

The breaking API fixes listed in docs/rough_edges.md, made before 1.0 freezes the API.

Changes

Client results

listTools, listPrompts, listResources, listResourceTemplates, callTool, getPrompt
and readResource return the request's result type instead of a tuple or an array. The
results have the tuples' labels as properties, so try await client.listTools().tools
compiles unchanged, and they carry what the tuples dropped (structuredContent, _meta,
ttlMs, cacheScope). The callTool overload that returned a RequestContext is
startToolCall(name:arguments:meta:). The deprecated Client.initialize() is removed.

Connection info

  • connect(transport:) returns Client.ConnectionInfo (protocolVersion, capabilities,
    serverInfo, instructions, isStateless). At 2026-07-28 serverInfo is nil when the
    server sends none, instead of an invented empty name and version.
  • setLoggingLevel(_:) at 2026-07-28 sets Client.logLevel, carried in every request's
    _meta, instead of rewriting configuration.logLevel.
  • Version.latest is Version.latestHandshake; the old name is deprecated.

Server handlers

  • start(transport:) keeps handlers registered before it for initialize, ping,
    server/discover and subscriptions/listen; it used to replace them.
  • A server with the logging capability answers logging/setLevel on handshake connections
    and log drops messages below the level. A SetLoggingLevel handler of the application
    replaces it.
  • Server.HandlerContext has a public initializer, for tests.

Content

The text, image and audio cases have defaults for annotations and _meta;
the deprecated helpers that took metadata: or unlabeled values are removed.

HTTP errors

HTTPClientTransport throws transportError(HTTPStatusError) (statusCode, headers,
isSessionExpired) and transportError(OAuthAuthorizationError) where it threw
internalError with a message. The descriptions are unchanged.

Docs: the migration guide, docs/rough_edges.md, troubleshooting, design/auth.md.

API changes

Breaking, each in the migration guide with before and after code: the seven convenience
methods' return types, connect(transport:)'s return type, Client.initialize() and the
Tool.Content helpers removed, the HTTP error types. Additive: startToolCall,
ConnectionInfo, Client.logLevel, HTTPStatusError, Version.latestHandshake,
HandlerContext.init.

Review notes

  • Names to confirm: startToolCall, ConnectionInfo, HTTPStatusError inside
    transportError (rather than a new MCPError case, which would break switch statements
    again).
  • ServerDefaultHandlerTests.startKeepsHandlers would hang rather than fail under the old
    behavior: the ping handler it registers would never run.

Tests

896 swift-testing tests plus 101 XCTest at 1a9c434; 981 on Linux.

Verification

The branch builds and passes swift test and weave --check. At 1a9c434:
scripts/ci/run-jobs.sh --strict on macOS and scripts/ci-linux.sh --strict all on ubi9
pass every job. Baselines and interop/RESULTS.md unchanged.


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 breaking API fixes listed in `docs/rough_edges.md`, made before 1.0
freezes the API.
- A 405 to a POST no longer cancels the standalone GET stream: a
  handshake-only server that refuses the sessionless server/discover
  with 405 left the session that followed without its GET stream. The
  GET path keeps its own 405 handling.
- Setting configuration.logLevel after init now changes Client.logLevel,
  which the _meta of stateless requests carries; the later of that and
  setLoggingLevel wins.
- A 404 on the GET stream for a request that carried the session ID
  drops the session, reports isSessionExpired and stops reconnecting,
  as a 404 on a POST does, instead of retrying with the expired session.
- A CancellationError from the authorizer (endpoint check, headers,
  challenge, on POST and GET) is thrown as is instead of wrapped in
  transportError; other authorizer errors stay wrapped.
- The migration guide lists the HTTP client error descriptions that
  changed, instead of saying they are the same.
- HTTPStatusError's debugDescription names the response headers without
  their values, so logging an MCPError no longer prints cookies or
  authentication challenges.
- Document that an application Initialize handler replaces the SDK's
  handshake, so initializeHook and version negotiation do not run.
- The logging server sample captures the server weakly; the strong
  capture kept the server alive through its own handler.
- Update three tests that still destructured callTool's result as a
  tuple, which no longer compiled after callTool returned the result.
- ServerTests: the server-metadata test from main's #258 initializes with
  Version.latestHandshake instead of the deprecated Version.latest.
- OAuthAuthorizationError: the doc example catches the error inside
  MCPError.transportError(_:), as HTTPClientTransport throws it; a bare
  `catch OAuthAuthorizationError.dpopRequired` around connect never matched.
  The migration guide points from its OAuthAuthorizationError section to
  HTTP client errors.
- Migration guide: a transportError is sent on the wire when a server
  handler that calls another server through a Client lets it propagate
  (-32001, "Transport error: ..."), so such handlers translate it.
- HTTPClientTransport: a 404 on the standalone GET stream no longer drops
  the session ID. The next request carries it, gets the 404 the server must
  send for it (2025-11-25 transports, session management), and reports
  HTTPStatusError(isSessionExpired: true) to its caller instead of an
  unrelated 400 for a request without a session.
- Client: connect(transport:) resets logLevel to configuration.logLevel, so a
  reconnect does not carry the previous connection's level in _meta, and a
  handshake reconnect does not report a level the new session never got.
- ServerTests.startKeepsHandlers finishes its stream after ping(), so a
  regression fails the expectation instead of hanging.
design/auth.md described the transport as recognizing a use_dpop_nonce
challenge and failing a second one without calling handleChallenge. The
authorizer now reports the nonce retry in its HTTPChallengeResult, and
the transport asks it before failing a second one.
- HTTPClientTransport: a 404 reports isSessionExpired when the request
  carried Mcp-Session-Id, as HTTPStatusError documents, not when the actor
  still has a session ID. The POST records the header it sent before it
  awaits the reply, so every request in flight on an expired session reports
  the expiry, not only the first reply to arrive (2025-11-25 transports,
  session management: a 404 to a request carrying the session ID ends it).
  The GET stream does the same with the header of the GET it sent.
- HTTPClientTransport: a 404 to a POST that ends the session also stops the
  GET stream, with or without a JSON-RPC error body. Before, the stream
  reconnected without a session ID, its 404 no longer counted as an expiry,
  and it retried until disconnect().
- protocol and troubleshooting guides: a 404 on the GET stream keeps the
  session ID, and the next request reports the expiry; a 404 to a POST stops
  the GET stream.
- client and protocol guides, design notes: connect(transport:) returns a
  Client.ConnectionInfo, whose serverInfo is optional, not an
  Initialize.Result.
- Client.Configuration.logLevel: the doc says that only a change to another
  value sets Client.logLevel; setLoggingLevel(_:) does not change the
  configuration, so assigning the value it already has keeps the level
  setLoggingLevel(_:) set. The test pins that.
- design/auth.md: a CancellationError from the authorizer is thrown as is.
varun06
varun06 previously approved these changes Nov 25, 2026

@varun06 varun06 left a comment

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.

looking good!

Base automatically changed from conformance/p19-enums to rel/1.0.0 November 25, 2026 12:44
@jeanmatthieu
jeanmatthieu dismissed varun06’s stale review November 25, 2026 12:44

The base branch was changed.

@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

@jeanmatthieu
jeanmatthieu merged commit 83f8645 into rel/1.0.0 Nov 25, 2026
@jeanmatthieu
jeanmatthieu deleted the conformance/p20-api branch November 25, 2026 12:45
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