MCP Swift SDK

Normal
GitHub Swift NOASSERTION

Description

Official Swift SDK for the Model Context Protocol, targeting Apple platforms with SwiftPM and Swift Concurrency-based async APIs.

Key Features

  • Official Swift package maintained by the MCP working group
  • Swift Concurrency native — async/await, AsyncSequence, and structured task cancellation
  • {"Cross-platform Apple support":"iOS, macOS, watchOS, tvOS, and visionOS targets"}
  • Stdio and Streamable HTTP transports for connecting to local CLI and remote MCP servers
  • Codable-based schema types for tools, resources, and prompts with full spec coverage
  • Designed for SwiftUI-based agent UIs and on-device LLM integrations

Use Cases

💡 Embedding MCP clients into iOS and macOS apps that talk to local LLM toolchains
💡 Building SwiftUI agents that discover and call tools exposed by an MCP server
💡 Authoring MCP servers in Swift to expose Apple-native capabilities such as Shortcuts
💡 Connecting visionOS apps to a shared MCP tool registry
💡 Bridging CoreML on-device models with MCP-based tool orchestration

Quick Start

// Package.swift
.package(url: "https://github.com/modelcontextprotocol/swift-sdk", from: "0.4.0")

// main.swift
import MCP
let client = Client(name: "demo", version: "1.0")
let transport = StdioTransport()
try await client.connect(transport: transport)
let tools = try await client.listTools()

Related Projects