Skip to content

Update README to match the current API - #331

Merged
andreyvelich merged 1 commit into
modelcontextprotocol:mainfrom
varun06:docs/readme-refresh
Nov 15, 2026
Merged

andreyvelich merged 1 commit into
modelcontextprotocol:mainfrom
varun06:docs/readme-refresh

Conversation

@varun06

@varun06 varun06 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

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

  • Tool content: .text, .image, and .audio have four associated values; the old metadata
    width/height logic no longer applies.
  • Completion and prompt arguments are [String: String], so .string(...) and .stringValue are wrong.
  • Elicitation requestedSchema is not optional.
  • Cancellation: callTool and send need await from outside the actor, and getting the
    RequestContext overload requires a type annotation.
  • Batching: the examples mutated a captured var inside the @Sendable closure; they now collect
    tasks in an actor.
  • Graceful shutdown: Duration has no .days, and ServiceLifecycle's Service only requires run(),
    so shutdown() was never called. The service now waits on server.waitUntilCompleted() and stops
    the server from withGracefulShutdownHandler (thanks to @samkudr for raising this in README Fix #161).
  • Server sampling declared a sampling capability on the server; sampling is a client capability.
  • Tool requires inputSchema; deprecated Tool.Content.text(_:) is replaced with
    .text(text:annotations:_meta:); a case with only a comment now has an implementation.

Facts

  • Requirements: Swift 6.1+ (Xcode 16.3+); install from 0.12.0.
  • Client stdio: StdioTransport() uses the current process's stdio. Added an example that launches
    a server subprocess and connects through its pipes.
  • Sampling and elicitation: show the client declaring the capabilities (including url: for
    URL-mode elicitation).
  • Batching: note that JSON-RPC batching was removed in protocol revision 2025-06-18.
  • Transports table: link the 2025-11-25 spec; stdio supports Linux with glibc and musl; HTTP client
    SSE is Apple-only; the stateless server doesn't deliver server-to-client messages;
    NetworkTransport is a custom transport with heartbeats and reconnection on by default.
  • Authentication: mention Client ID Metadata Documents, token refresh, and scope step-up; warn about
    the default random-port redirect URI; keep OriginValidator and ProtocolVersionValidator in the
    custom pipeline example and show where the pipeline is passed.
  • Platform availability: list the Linux limitations (SSE, PKCE S256, private_key_jwt, Network framework).
  • Debugging: log to standard error (for stdio servers, standard output carries MCP messages), pass
    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).
  • Table of contents: add Custom Transport Implementation; fix heading levels.

How Has This Been Tested?

Every Swift snippet was type-checked with swiftc -typecheck against the built MCP module (Swift 6
language mode), with stand-ins only for app-specific placeholders such as getWeatherData. The
ServiceLifecycle example was checked against stand-in types, since that package isn't a dependency
here. Documentation-only change.

Breaking Changes

None.

Types of changes

  • Documentation update

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.
@varun06
varun06 requested a review from a team as a code owner November 15, 2026 14:14

@andreyvelich andreyvelich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @varun06!

@andreyvelich
andreyvelich merged commit c0ffca7 into modelcontextprotocol:main Nov 15, 2026
6 checks passed
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