SwiftMCP logo

SwiftMCP

by compiler-inc

SwiftMCP is a Swift Package that implements an MCP client for iOS and macOS, enabling native API integration through a JSON-RPC interface. It also includes an OpenAI-compatible function calling bridge for interacting with native iOS APIs.

View on GitHub

Last updated: N/A

What is SwiftMCP?

SwiftMCP is a Swift package providing an MCP (Model Context Protocol) client for iOS and macOS that allows for seamless integration with native device APIs through a JSON-RPC interface. The package also includes an OpenAI function calling bridge, enabling LLMs to interact with native iOS features.

How to use SwiftMCP?

To use SwiftMCP, add the package as a dependency to your Swift project via Swift Package Manager. After installation, you can create an MCPClient, register tools such as the HealthKitTool, and then handle incoming JSON-RPC requests or integrate with OpenAI's function calling via the OpenAIToolRegistry. Example code is available in the README.

Key features of SwiftMCP

  • Implements an MCP client in Swift

  • Supports JSON-RPC 2.0 for communication

  • Includes pre-built tools like HealthKitTool for accessing native APIs

  • Provides an OpenAI-compatible function calling bridge

  • Easy to install and use with Swift Package Manager

Use cases of SwiftMCP

  • Integrating HealthKit data into AI applications

  • Building AI agents that can retrieve native device information

  • Enabling OpenAI to call native iOS APIs through function calling

  • Creating custom tools to expose device functionality through MCP

  • Developing automated workflows that leverage mobile device data

FAQ from SwiftMCP

What is MCP?

MCP stands for Model Context Protocol. It provides a standardized way for applications to interact with external tools and services.

What native APIs are immediately accessible via SwiftMCP?

The provided HealthKitTool offers access to device health data.

Does SwiftMCP support other native iOS APIs?

SwiftMCP can be extended to support other native iOS APIs by creating new MCPTool implementations.

What versions of iOS and macOS are supported?

SwiftMCP supports iOS 15.0+ and macOS 12.0+.

What is the license for SwiftMCP?

SwiftMCP is licensed under the MIT License.