Awesome MCPSwift

modelcontextprotocol/swift-sdk

⭐ 1489 Swift added to this list on 2025-04-09 repository created 2025-02-05

The project "modelcontextprotocol/swift-sdk" is the official Swift Software Development Kit (SDK) for the Model Context Protocol (MCP). MCP is a standardized protocol designed to facilitate communication between applications and AI or machine learning models. This SDK implements both client and server components based on the latest MCP specification version dated 2025-03-26. It supports multiple transport mechanisms including local subprocess communication via stdio transport and remote communication through streaming HTTP transport, enabling real-time updates and interactions. The SDK allows developers to build MCP-compliant servers and clients in Swift, providing a comprehensive set of features such as connecting to MCP servers, listing and calling tools (functions callable by clients), managing resources (data accessible and subscribable), handling prompts (templated conversation starters), and supporting sampling workflows. Sampling is a key feature that enables servers to request AI completions from clients with human-in-the-loop control, ensuring users can review, modify, approve, or reject AI-generated content before it is sent back to the server. The SDK is designed for Swift 6.0+ and integrates easily with Swift Package Manager. It provides detailed client usage examples, including how to connect to servers, interact with tools, manage resources, and handle prompts. The SDK also supports error handling specific to MCP operations. Overall, this SDK is a critical tool for developers looking to implement MCP in Swift environments, enabling seamless, real-time, and controlled interactions with AI models through a standardized protocol. It emphasizes user control, extensibility, and support for multiple communication transports, making it suitable for a wide range of AI-driven applications.

https://github.com/modelcontextprotocol/swift-sdk

ai-communicationai-completionsapple-platformsclient-serverclient-setuphttp-transporthttpclienttransporthuman-in-the-loopioslinuxmacosmcpmit-licenseml-modelsmodel-context-protocolmultiple-transportsnetworking-frameworknetworktransportopen-sourcepromptsreal-time-communicationresourcessamplingsemantic-versioningserver-sent-eventsserver-setupssestdio-transportstdiotransportsubscriptionswiftswift-6.0swift-package-managerswift-sdktcptoolstvosudpvisionoswatchoswindows