Skip to content

Commit df60c48

Browse files
ochafikclaude
andcommitted
feat: Add Swift SDK for MCP Apps
Swift SDK for hosting MCP Apps in iOS/macOS applications: SDK (swift/): - AppBridge: Host-side protocol handler - WKWebViewTransport: WebView communication - Generated types from schema.json - Full MCP Apps protocol support Example App (examples/basic-host-swift/): - SwiftUI app demonstrating SDK usage - Bottom toolbar UI (server/tool pickers) - WebView with AppBridge integration - Tool forwarding to MCP servers - Server name displayed in tool call cards Type Generator: - scripts/generate-swift-types.ts - Generates Swift types from JSON Schema CI: - Swift job on macos-latest - Builds and tests SDK 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 402bf48 commit df60c48

28 files changed

+5842
-0
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,37 @@ jobs:
3636
- run: npm test
3737

3838
- run: npm run prettier
39+
40+
swift:
41+
runs-on: macos-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Build Swift SDK
46+
working-directory: swift
47+
run: swift build
48+
49+
- name: Test Swift SDK
50+
working-directory: swift
51+
run: swift test
52+
53+
kotlin:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Set up JDK 21
59+
uses: actions/setup-java@v4
60+
with:
61+
java-version: "21"
62+
distribution: "temurin"
63+
64+
- name: Build Kotlin SDK
65+
working-directory: kotlin
66+
run: |
67+
chmod +x gradlew
68+
./gradlew build
69+
70+
- name: Test Kotlin SDK
71+
working-directory: kotlin
72+
run: ./gradlew test

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ examples/basic-server-react/**/*.ts
44
examples/basic-server-react/**/*.tsx
55
examples/basic-server-vanillajs/**/*.ts
66
examples/basic-server-vanillajs/**/*.tsx
7+
8+
# Swift package manager build artifacts
9+
sdk/swift/.build/
10+
examples/basic-host-swift/.build/
11+
examples/basic-host-swift/build/
12+
examples/basic-host-kotlin/.gradle/
13+
examples/basic-host-kotlin/build/
14+
15+
# Swift build artifacts
16+
swift/.build/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Xcode
2+
.DS_Store
3+
*/build/*
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata/
13+
*.xccheckout
14+
*.moved-aside
15+
DerivedData/
16+
*.hmap
17+
*.ipa
18+
*.xcuserstate
19+
project.xcworkspace/
20+
21+
# Swift Package Manager
22+
.build/
23+
.swiftpm/
24+
25+
# CocoaPods
26+
Pods/
27+
28+
# Intermediate outputs
29+
intermediate-outputs/
30+
build/
31+
.build/
32+
*.xcodeproj/
33+
DerivedData/
34+
Package.resolved
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// swift-tools-version: 6.0
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "BasicHostSwift",
6+
platforms: [
7+
.iOS(.v16),
8+
.macOS(.v13)
9+
],
10+
products: [
11+
.executable(
12+
name: "BasicHostSwift",
13+
targets: ["BasicHostApp"]
14+
),
15+
],
16+
dependencies: [
17+
// Local MCP Apps Swift SDK
18+
.package(path: "../../swift"),
19+
// MCP Swift SDK for MCP client (using spec-update branch with _meta support)
20+
.package(url: "https://github.com/ajevans99/swift-sdk.git", branch: "spec-update"),
21+
],
22+
targets: [
23+
.executableTarget(
24+
name: "BasicHostApp",
25+
dependencies: [
26+
.product(name: "McpApps", package: "swift"),
27+
.product(name: "MCP", package: "swift-sdk"),
28+
],
29+
path: "Sources/BasicHostApp"
30+
),
31+
]
32+
)

0 commit comments

Comments
 (0)