Repository navigation
Update README to match the current API - #331
Merged
andreyvelich merged 1 commit intoNov 15, 2026
Merged
Conversation
Fixes README examples that don't compile against the current API, and updates facts that have drifted from the code. Examples (all Swift snippets now type-check against the library): - Tool content patterns: `.text`/`.image`/`.audio` have four associated values; drop the old `metadata` width/height logic. - Completion and prompt arguments are `[String: String]`: remove `.string(...)` / `.stringValue`. - Elicitation `requestedSchema` is not optional. - Cancellation: `callTool`/`send` need `await` from outside the actor, and the `RequestContext` overload needs a type annotation. - Batching: collect tasks in an actor instead of mutating a captured `var` in the `@Sendable` closure. - Replace deprecated `Tool.Content.text(_:)` with `.text(text:annotations:_meta:)`. - Graceful shutdown: `Duration` has no `.days`, and ServiceLifecycle's `Service` only requires `run()`. Wait on `server.waitUntilCompleted()` and stop the server from `withGracefulShutdownHandler`. - `Tool` requires `inputSchema`; give the `customer-support` prompt a real implementation. Facts: - Requirements: Swift 6.1+ (Xcode 16.3+); install from 0.12.0. - Client stdio: `StdioTransport()` uses the current process's stdio; show how to connect to a server subprocess through its pipes. - Sampling and elicitation are client capabilities: show the client declaring them, and remove `sampling:` from `Server` capabilities. - Batching was removed from the spec in 2025-06-18. - Transports table: link 2025-11-25 spec, Linux glibc and musl, SSE on Apple platforms only, stateless server limits, NetworkTransport is a custom transport with heartbeats and reconnection on by default. - Authentication: CIMD, token refresh and scope step-up; warn about the default random-port redirect URI; keep `OriginValidator` and `ProtocolVersionValidator` in custom pipelines and show where the pipeline is passed. - Platform availability: list Linux limitations. - Debugging: log to standard error (stdout carries MCP messages for stdio servers), pass the logger to the transport, and give the client and the server their own transports (follow-up to modelcontextprotocol#155). - TOC: add Custom Transport Implementation; fix heading levels.
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.
Motivation and Context
Several README examples no longer compile against the current API, and some facts have drifted
from the code. I type-checked every Swift snippet in the README against the library's public API
(snippets that build on an earlier one in the same section were checked together). This PR fixes
what failed and updates the facts.
Examples that didn't compile
.text,.image, and.audiohave four associated values; the oldmetadatawidth/height logic no longer applies.
[String: String], so.string(...)and.stringValueare wrong.requestedSchemais not optional.callToolandsendneedawaitfrom outside the actor, and getting theRequestContextoverload requires a type annotation.varinside the@Sendableclosure; they now collecttasks in an actor.
Durationhas no.days, and ServiceLifecycle'sServiceonly requiresrun(),so
shutdown()was never called. The service now waits onserver.waitUntilCompleted()and stopsthe server from
withGracefulShutdownHandler(thanks to @samkudr for raising this in README Fix #161).samplingcapability on the server; sampling is a client capability.ToolrequiresinputSchema; deprecatedTool.Content.text(_:)is replaced with.text(text:annotations:_meta:); acasewith only a comment now has an implementation.Facts
0.12.0.StdioTransport()uses the current process's stdio. Added an example that launchesa server subprocess and connects through its pipes.
url:forURL-mode elicitation).
SSE is Apple-only; the stateless server doesn't deliver server-to-client messages;
NetworkTransportis a custom transport with heartbeats and reconnection on by default.the default random-port redirect URI; keep
OriginValidatorandProtocolVersionValidatorin thecustom pipeline example and show where the pipeline is passed.
private_key_jwt, Network framework).the logger to the transport, and give the client and the server their own transports
(follow-up to Update the README to provide clearer instructions on how to add the l… #155).
How Has This Been Tested?
Every Swift snippet was type-checked with
swiftc -typecheckagainst the builtMCPmodule (Swift 6language mode), with stand-ins only for app-specific placeholders such as
getWeatherData. TheServiceLifecycle example was checked against stand-in types, since that package isn't a dependency
here. Documentation-only change.
Breaking Changes
None.
Types of changes