Skip to content

JakeSax/ModelContextProtocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Swift Package for the Model Context Protocol

Swift Platforms License

This was something I was working on, but there is now an official Swift SDK so I can only recommend to use the official version. This package will no longer be maintained or developed, though I would mention that it does have some nice ergonomics + quality of life features that could be integrated into the official SDK.

ModelContextProtocol was an under-development Swift 6.0 implementation of Anthropic's Model Context Protocol (MCP), with the goal of providing an easy-to-use, pluggable Swift Package for MCP use across macOS, iOS, + Linux.

The package is split into three components:

  1. MCPCore: The core data types and functionality shared between the MCPClient and MCPServer.
  2. MCPClient: A relatively simple implementation for an MCPClient.
  3. MCPServer: An interface for a server to provide MCP functionality.

Features

  • 🏃 Modern Swift Concurrency - Built with Swift 6.0, leveraging actors, async/await, + Sendable
  • 🔒 Type-Safe - Full type safety for all MCP messages and operations
  • 🔌 Multiple Transports - Support for stdio and Server-Sent Events (SSE)
  • ⚡️ Performance - Efficient message handling with timeout and retry support
  • 🛠 Rich Capabilities - Support for resources, prompts, tools, and more
  • 📦 SwiftPM Ready - Easy integration through Swift Package Manager

Contributing

  1. Read the MCP Specification
  2. Fork the repository
  3. Create a feature branch
  4. Add tests for new functionality
  5. Submit a pull request

Limitations

  • StdioTransport does not work in sandboxed environments

About

A Swift implementation of Anthropic's Model Context Protocol (MCP)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages