SwiftMCP — Connect Apple's Foundation Models to any MCP server

Hi everyone,

I've open-sourced SwiftMCP, a library that bridges Apple's on-device Foundation Models (iOS 26+) with the Model Context Protocol ecosystem.

The core problem: Apple's Tool protocol requires @Generable — a compile-time macro. MCP tools are discovered at runtime, so they can't use macros. SwiftMCP solves this using DynamicGenerationSchema to build tool schemas entirely at runtime.

swift

let bridge = try await MCPToolBridge.connect(to: [
    .http(URL(string: "https://weather.example.com/mcp")!),
])
let session = LanguageModelSession(tools: bridge.tools)
let response = try await session.respond(to: "What's the weather in Tokyo?")

Key details:

  • Supports HTTP/SSE and stdio transports

  • Handles anyOf/oneOf/allOf JSON Schema composition

  • Swift 6 strict concurrency (actors, Sendable)

  • Graceful tool call error recovery

  • Structured logging via os.Logger

  • MIT licensed, single dependency (official MCP Swift SDK)

GitHub: https://github.com/sutheesh/SwiftMCP

I'd welcome any feedback — especially from anyone working with Foundation Models or the MCP Swift SDK.

1 Like