Library / SDK
modelcontextprotocol/swift-sdk avatar
modelcontextprotocol/swift-sdk

MCP Swift SDK: The Official Swift Implementation of Model Context Protocol

The official Swift SDK for Model Context Protocol servers and clients.

1,490 stars241 forksSwiftNOASSERTION

At a glance

What is it?
The Model Context Protocol defines a standard way for applications to talk to AI models, and this official Swift SDK implements both sides of that conversation. It is built for Swift 6.0 and later, with client and server components, multiple transport options, and authentication flows tied to the 2025-11-25 specification.
Who is it for?
Adopt this SDK if you are building an MCP client or server in Swift and want the protocol handling, transport layer, and authentication flows provided rather than assembled yourself. Do not adopt it if your project targets a Swift version below 6.0, or if you need to support a transport or authentication pattern the SDK does not cover.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 131 days ago.
What is it written in?
Mainly Swift, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What the MCP Swift SDK actually solves for Swift developers

The Model Context Protocol defines a standardized way for applications to communicate with AI and ML models. Without an SDK, a Swift developer building an MCP-compatible client or server would need to implement the protocol's message shapes, capability negotiation, and transport handling from scratch. This package provides both client and server components according to the 2025-11-25 version of the MCP specification, which the README identifies as the latest. The SDK is aimed at Swift developers who need either side of that connection: an application that connects to MCP servers, or a server that exposes tools, resources, and prompts to MCP clients. The README's table of contents shows the breadth of coverage: tools, resources, prompts, completions, sampling, elicitation, roots, logging, error handling, cancellation, and progress tracking, each with separate client and server sections. This is not a thin wrapper around JSON-RPC. It is a full protocol implementation with opinionated structure for both roles.

How the client and server components are structured

The README shows a client initialized with a name and version string, then connected to a transport. The connect method returns an initialization result that carries server capabilities, and the README notes this return value is discardable. Capability checks are explicit: the example tests result.capabilities.tools != nil before assuming tool support, and result.capabilities.resources?.subscribe == true before subscribing to resource updates. The server side mirrors this with its own setup, tool, resource, and prompt sections, plus hooks the client does not have. The server section includes an initialize hook, HTTP request context in handlers, and graceful shutdown. That asymmetry is worth noting: servers get lifecycle control that clients do not need, because a server has to manage incoming connections and terminate cleanly. The data flow is transport-mediated. A client creates a transport object, passes it to connect, and the SDK handles the protocol exchange over that transport. Notification handling is registered per message type, as shown by the ResourceUpdatedNotification example, where the handler reads the updated URI and fetches the resource again. That means the SDK does not push resource content to you on update. It tells you the resource changed and leaves the refetch to your code.

Getting a client running with Package.swift and StdioTransport

The README gives the Swift Package Manager dependency as a URL to the repository with a from: "0.11.0" version requirement, and the target dependency as .product(name: "MCP", package: "swift-sdk"). The product name is MCP, not swift-sdk, which is easy to get wrong when copying the package URL into a target declaration. The simplest client path in the README is StdioTransport for local subprocess communication: create the transport, pass it to client.connect(transport:), and the connection is established. For remote servers, the README shows HTTPClientTransport with an endpoint URL and a streaming flag. Setting streaming to true enables Server-Sent Events for real-time updates, per the README comment. Tool calls return a tuple of content and an isError flag, and the content is an array of cases: text, image with data and MIME type and optional metadata, audio, resource, and resourceLink. Handling all five cases is left to the caller. The README's image example reads width and height out of the metadata dictionary with conditional casts, which tells you metadata is not strongly typed at that point.

Authentication flows and where they stop

The README lists eight authentication topics: client credentials flow, authorization code flow, custom token provider, custom token storage, private_key_jwt, endpoint overrides, server-side protected resource metadata, and server-side bearer token validation. That is a broader surface than many protocol SDKs provide, and it suggests the maintainers expect production deployments rather than demos. The custom token provider and custom token storage entries matter most for integration, because they imply the SDK does not force a particular credential store. What the README does not show in the excerpt available here is the actual configuration keys or initializer signatures for these flows. The section headings exist, but the code samples for authentication are not present in the material provided. A developer evaluating this SDK for a production server should read those sections directly in the repository before assuming the flows match their identity provider. The presence of private_key_jwt and endpoint overrides suggests OAuth-oriented deployments, but the README excerpt does not confirm which grant types are fully implemented versus documented as patterns.

Limitations and cases where this is the wrong choice

The requirement is Swift 6.0 or later, with Xcode 16 or later. That is a hard floor. Any project pinned to Swift 5.x, or to an Xcode version before 16, cannot use this package without an upgrade that may cascade through other dependencies. The README points to a Platform Availability section for platform-specific requirements, but that section's contents are not included in the material available here, so the exact supported platforms cannot be confirmed from this excerpt. The license is listed as NOASSERTION, which means the repository's license metadata does not resolve to a standard SPDX identifier. The README has a License section, but its text is not in the excerpt. Anyone planning to ship this in a commercial product should read the actual license file rather than rely on the repository metadata. Another limitation is protocol version coupling: the SDK implements the 2025-11-25 specification. If you need to interoperate with a peer that speaks an earlier MCP revision, the README does not describe a compatibility mode. Finally, the notification model for resource subscriptions requires a manual refetch, which adds a round trip per update and puts the burden of consistency on your handler code.

How this compares to writing your own MCP layer or using a language-agnostic bridge

The alternative most Swift teams consider is implementing the protocol themselves over a JSON-RPC library, or routing through a non-Swift MCP implementation and bridging across a process boundary. Writing your own layer gives you exact control over message shapes and lets you target whichever spec revision your peers actually use. It also means you own capability negotiation, cancellation semantics, progress tracking, and every transport. The README's table of contents shows this SDK covers all of those areas, which is a substantial amount of protocol surface to reimplement. The bridge approach avoids Swift protocol work entirely but adds a subprocess or network hop, and it means your Swift code deals with a foreign runtime's types and error model. The SDK's advantage is that the protocol types are native Swift: content comes back as an enum with text, image, audio, resource, and resourceLink cases, and notifications are registered with typed handlers like ResourceUpdatedNotification. That type safety is the concrete difference. The trade-off is version lock: you get the spec revision the SDK implements, not the one you choose.

Maintenance cost, version drift, and what to check before upgrading

The release history shows 0.12.1 on 2026-05-07, 0.12.0 on 2026-03-24, and 0.11.0 on 2026-02-19. That is roughly one minor release every four to six weeks across the visible window. For a pre-1.0 package, minor version bumps can carry breaking changes, and the README's installation example still specifies from: "0.11.0" while the latest release is 0.12.1. That gap is worth noting: the documented dependency floor lags the current release. A team adopting this should read the changelog, which the README links, before pinning a version, and should decide whether to use a from: requirement that floats across minor versions or an exact pin. Floating across minor versions of a pre-1.0 package means a routine swift package update can pull in API changes. The license situation adds a separate maintenance concern: with NOASSERTION as the identifier, the terms are whatever the license file says, and that file's contents are not available in this excerpt. Verify it directly. The SDK's own upgrade cost is tied to the MCP specification revision it tracks, so a spec update in the protocol means an SDK update you will need to absorb.

Editorial conclusion

Adopt this SDK if you are building an MCP client or server in Swift and want the protocol handling, transport layer, and authentication flows provided rather than assembled yourself. Do not adopt it if your project targets a Swift version below 6.0, or if you need to support a transport or authentication pattern the SDK does not cover. Before committing, verify the platform availability section for your deployment targets, confirm whether the NOASSERTION license identifier matches your legal requirements, and check the changelog for breaking changes between 0.11.0 and 0.12.1, since the package dependency example still points at 0.11.0 while the latest release is 0.12.1.

Official sources

  1. Issues
  2. modelcontextprotocol/swift-sdk on GitHub
  3. README
  4. Releases
Community notes

Community notes