swift-sdk  by modelcontextprotocol

Swift SDK for Model Context Protocol (MCP) servers and clients

created 5 months ago
862 stars

Top 42.5% on sourcepulse

GitHubView on GitHub
Project Summary

This Swift SDK provides a robust implementation of the Model Context Protocol (MCP) for building AI-powered applications. It enables seamless communication between MCP clients and servers, allowing developers to integrate AI models, manage resources, and handle prompts and tools within their Swift applications.

How It Works

The SDK leverages a transport layer abstraction to facilitate communication. It offers built-in transports like StdioTransport for standard input/output, HTTPClientTransport for streaming HTTP communication via Server-Sent Events, and NetworkTransport for custom TCP/UDP communication using Apple's Networking framework. This modular design allows for platform-specific optimizations and custom transport implementations.

Quick Start & Requirements

  • Installation: Add to Package.swift dependencies: .package(url: "https://github.com/modelcontextprotocol/swift-sdk.git", from: "0.7.1")
  • Prerequisites: Swift 6.0+ (Xcode 16+). Apple platform minimum versions: macOS 13.0+, iOS/Mac Catalyst 16.0+, watchOS 9.0+, tvOS 16.0+, visionOS 1.0+. StdioTransport requires glibc on Linux.
  • Docs: https://github.com/modelcontextprotocol/swift-sdk

Highlighted Details

  • Supports both client and server implementations of MCP.
  • Enables real-time communication via Server-Sent Events (SSE) with HTTPClientTransport.
  • Provides methods for listing and interacting with tools, resources, and prompts.
  • Includes handlers for resource updates and custom method calls.

Maintenance & Community

  • Maintained in collaboration with @loopwork-ai.
  • Follows Semantic Versioning; pre-1.0 minor versions may contain breaking changes. Changelog available on GitHub Releases.

Licensing & Compatibility

  • MIT License. Permissive for commercial use and closed-source linking.

Limitations & Caveats

StdioTransport support for Alpine Linux and Windows is currently in progress. NetworkTransport is exclusively available on Apple platforms.

Health Check
Last commit

1 week ago

Responsiveness

1 day

Pull Requests (30d)
4
Issues (30d)
1
Star History
418 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.