Repository navigation
[P20] api: the 1.0 rough edges - #351
Merged
Merged
Conversation
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.
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rel/1.0.0in order (previous: P19 (#352) · next: P21 (#350))conformance/p20-apiconformance/p19-enums(stacked: GitHub retargets this PR torel/1.0.0when the previous part merges)1a9c434api: the 1.0 rough edgesa08e316api: review fixes8fc13d7api: second-pass review fixes136fd09docs: say the authorizer classifies a DPoP nonce retryaf2c01capi: third-pass review fixesSummary
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,getPromptand
readResourcereturn the request's result type instead of a tuple or an array. Theresults have the tuples' labels as properties, so
try await client.listTools().toolscompiles unchanged, and they carry what the tuples dropped (
structuredContent,_meta,ttlMs,cacheScope). ThecallTooloverload that returned aRequestContextisstartToolCall(name:arguments:meta:). The deprecatedClient.initialize()is removed.Connection info
connect(transport:)returnsClient.ConnectionInfo(protocolVersion,capabilities,serverInfo,instructions,isStateless). At 2026-07-28serverInfoisnilwhen theserver sends none, instead of an invented empty name and version.
setLoggingLevel(_:)at 2026-07-28 setsClient.logLevel, carried in every request's_meta, instead of rewritingconfiguration.logLevel.Version.latestisVersion.latestHandshake; the old name is deprecated.Server handlers
start(transport:)keeps handlers registered before it forinitialize,ping,server/discoverandsubscriptions/listen; it used to replace them.loggingcapability answerslogging/setLevelon handshake connectionsand
logdrops messages below the level. ASetLoggingLevelhandler of the applicationreplaces it.
Server.HandlerContexthas a public initializer, for tests.Content
The
text,imageandaudiocases have defaults forannotationsand_meta;the deprecated helpers that took
metadata:or unlabeled values are removed.HTTP errors
HTTPClientTransportthrowstransportError(HTTPStatusError)(statusCode,headers,isSessionExpired) andtransportError(OAuthAuthorizationError)where it threwinternalErrorwith 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 theTool.Contenthelpers removed, the HTTP error types. Additive:startToolCall,ConnectionInfo,Client.logLevel,HTTPStatusError,Version.latestHandshake,HandlerContext.init.Review notes
startToolCall,ConnectionInfo,HTTPStatusErrorinsidetransportError(rather than a newMCPErrorcase, which would breakswitchstatementsagain).
ServerDefaultHandlerTests.startKeepsHandlerswould hang rather than fail under the oldbehavior: 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 testandweave --check. At1a9c434:scripts/ci/run-jobs.sh --stricton macOS andscripts/ci-linux.sh --strict allon ubi9pass every job. Baselines and
interop/RESULTS.mdunchanged.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.