Skip to content

Commit 7dc8540

Browse files
committed
Merge branch 'ochafik/kotlin-sdk' of https://github.com/modelcontextprotocol/ext-apps into ochafik/kotlin-sdk
2 parents 3eebaa9 + 66fc58c commit 7dc8540

File tree

5 files changed

+414
-0
lines changed

5 files changed

+414
-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: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
# Development script: builds, installs, runs, and watches for changes
3+
# Usage: ./scripts/dev.sh [emulator-name]
4+
#
5+
# Requires: fswatch (brew install fswatch)
6+
7+
set -e
8+
9+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
10+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
11+
ROOT_DIR="$(dirname "$(dirname "$PROJECT_DIR")")"
12+
EMULATOR_NAME="${1:-}"
13+
PACKAGE_ID="com.example.mcpappshost"
14+
ACTIVITY="$PACKAGE_ID.MainActivity"
15+
16+
cd "$ROOT_DIR"
17+
18+
# Colors for output
19+
RED='\033[0;31m'
20+
GREEN='\033[0;32m'
21+
YELLOW='\033[1;33m'
22+
BLUE='\033[0;34m'
23+
NC='\033[0m' # No Color
24+
25+
log() { echo -e "${BLUE}[dev]${NC} $1"; }
26+
success() { echo -e "${GREEN}[dev]${NC} $1"; }
27+
warn() { echo -e "${YELLOW}[dev]${NC} $1"; }
28+
error() { echo -e "${RED}[dev]${NC} $1"; }
29+
30+
# Check for fswatch
31+
if ! command -v fswatch &> /dev/null; then
32+
error "fswatch is required. Install with: brew install fswatch"
33+
exit 1
34+
fi
35+
36+
# Check for adb
37+
if ! command -v adb &> /dev/null; then
38+
error "adb not found. Install Android SDK platform-tools."
39+
exit 1
40+
fi
41+
42+
# Start emulator if specified
43+
start_emulator() {
44+
if [ -n "$EMULATOR_NAME" ]; then
45+
if ! adb devices | grep -q "emulator"; then
46+
log "Starting emulator '$EMULATOR_NAME'..."
47+
emulator -avd "$EMULATOR_NAME" -no-snapshot-load &
48+
49+
log "Waiting for emulator to boot..."
50+
adb wait-for-device
51+
52+
while [ "$(adb shell getprop sys.boot_completed 2>/dev/null)" != "1" ]; do
53+
sleep 1
54+
done
55+
success "Emulator ready!"
56+
fi
57+
fi
58+
}
59+
60+
# Check for connected device
61+
check_device() {
62+
if ! adb devices | grep -q -E "device$"; then
63+
error "No Android device/emulator connected."
64+
echo ""
65+
echo " Available emulators:"
66+
emulator -list-avds 2>/dev/null || echo " (none found)"
67+
echo ""
68+
echo " Start with: ./scripts/dev.sh <emulator-name>"
69+
exit 1
70+
fi
71+
}
72+
73+
# Build the app
74+
build_app() {
75+
log "Building..."
76+
if ./gradlew :examples:basic-host-kotlin:assembleDebug --quiet 2>&1; then
77+
return 0
78+
fi
79+
return 1
80+
}
81+
82+
# Install and launch
83+
install_and_launch() {
84+
log "Installing..."
85+
./gradlew :examples:basic-host-kotlin:installDebug --quiet
86+
87+
log "Launching..."
88+
adb shell am force-stop "$PACKAGE_ID" 2>/dev/null || true
89+
adb shell am start -n "$PACKAGE_ID/$ACTIVITY"
90+
}
91+
92+
# Full rebuild cycle
93+
rebuild() {
94+
echo ""
95+
log "Rebuilding... ($(date '+%H:%M:%S'))"
96+
97+
if build_app; then
98+
success "Build succeeded"
99+
install_and_launch
100+
success "App reloaded!"
101+
else
102+
error "Build failed"
103+
fi
104+
}
105+
106+
# Initial setup
107+
start_emulator
108+
check_device
109+
rebuild
110+
111+
# Watch for changes
112+
log "Watching for changes in src/..."
113+
log "Press Ctrl+C to stop"
114+
echo ""
115+
116+
fswatch -o "$PROJECT_DIR/src" | while read -r; do
117+
rebuild
118+
done
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Take a screenshot from the device/emulator
3+
# Usage: ./scripts/screenshot.sh [output-file]
4+
5+
OUTPUT="${1:-screenshot.png}"
6+
7+
echo "📸 Taking screenshot..."
8+
9+
# Take screenshot on device and pull it
10+
adb shell screencap -p /sdcard/screenshot.png
11+
adb pull /sdcard/screenshot.png "$OUTPUT"
12+
adb shell rm /sdcard/screenshot.png
13+
14+
echo "✅ Saved to $OUTPUT"
15+
16+
# Open the screenshot (macOS)
17+
if [ "$(uname)" = "Darwin" ]; then
18+
open "$OUTPUT"
19+
fi

0 commit comments

Comments
 (0)