-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Add Kotlin SDK for MCP Apps #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Kotlin SDK for hosting MCP Apps in Android applications. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Kotlin SDK for hosting MCP Apps in Android applications. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Kotlin SDK for hosting MCP Apps in Android applications: SDK (kotlin/): - AppBridge: Host-side protocol handler - Transport abstraction (McpAppsTransport interface) - Generated types from schema.json - Full MCP Apps protocol support Example App (examples/basic-host-kotlin/): - Jetpack Compose app demonstrating SDK usage - Bottom toolbar UI (server/tool pickers) - WebViewTransport for Android WebView - Tool forwarding to MCP servers - Server name displayed in tool call cards - Toast notifications for messages/logs Type Generator: - scripts/generate-kotlin-types.ts - Generates Kotlin data classes from JSON Schema CI: - Kotlin job with JDK 21 on ubuntu-latest - Builds and tests SDK 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: "21" | ||
| distribution: "temurin" | ||
|
|
||
| - name: Build Kotlin SDK | ||
| working-directory: kotlin | ||
| run: | | ||
| chmod +x gradlew | ||
| ./gradlew build | ||
| - name: Test Kotlin SDK | ||
| working-directory: kotlin | ||
| run: ./gradlew test |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best fix is to explicitly add a permissions block at the root level of the workflow file .github/workflows/ci.yml. This will apply the specified minimal permissions to all jobs (unless any override them individually). As recommended, setting contents: read is the least privilege needed for typical CI build/test workflows. No other changes are required unless future workflow steps are added that require additional permissions.
To implement this, insert the following YAML section directly after the name: CI line (so it applies globally):
permissions:
contents: readThis ensures the workflow restricts GitHub token permissions to only those required for read access to repository contents.
-
Copy modified lines R2-R3
| @@ -1,4 +1,6 @@ | ||
| name: CI | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: |
commit: |
01fdb96 to
66fc58c
Compare
…rotocol/ext-apps into ochafik/kotlin-sdk
…rotocol/ext-apps into ochafik/kotlin-sdk
Apply the same two-phase close pattern introduced in basic-host: - Add isDestroying state to ToolCallState for tracking teardown phase - Implement requestClose() and completeClose() for two-phase teardown - Send ui/resource-teardown request when closing apps - Wait for app response before removing (with 3s timeout) - Dim card and show "Closing" status during teardown - Non-app results close immediately This follows the spec: "Host SHOULD wait for a response before tearing down the resource (to prevent data loss)." 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Removed the basic-host-swift example app and the Swift type generation script as they are no longer needed for this branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The swift job referenced a swift/ directory that doesn't exist. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…cture Add testable protocol handler and comprehensive test coverage: - McpAppBridgeProtocol: Extracted protocol logic into testable class - Handles JSON-RPC message parsing and dispatch - Manages protocol state (initialization, teardown) - Provides callbacks for all protocol events - Unit tests (17 tests, all passing): - Initialization handshake (initialize, initialized) - App→Host: size-changed, message, open-link, logging, tools/call - Host→App: tool-input, tool-result, tool-cancelled - Teardown flow with request/response tracking - Edge cases: unknown methods, malformed JSON - Test HTML app (test-app.html): - Implements full MCP Apps protocol - Visual protocol log for debugging - Buttons to trigger App→Host messages - Can be used for manual testing and instrumentation tests - Android instrumentation test skeleton: - Loads test app in WebView - Verifies protocol handshake - Tests two-way communication 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Add link to basic-host-kotlin in top-level README examples section - Add collapsible Mac installation instructions for Android SDK/emulator - Fix stale ext-apps2 references to ext-apps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…rotocol/ext-apps into ochafik/kotlin-sdk
The size-changed notification from Apps was being logged but not applied. Now the WebView properly resizes when the App requests a different height. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Changed from a fixed 3-second delay to polling every 50ms with a 500ms max timeout. This makes card dismissal feel much snappier while still giving apps time to respond to teardown requests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Expose an optional timeout parameter with a sensible 500ms default. This allows hosts to control how long to wait for the App to complete cleanup. `sendResourceTeardown(timeout: Duration = 500.milliseconds)` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Summary
Kotlin low-level SDK (AppBridge) for hosting MCP Apps in Android applications, and basic example Android app.
To test, ensure you have an Android emulator & run:
Show commands to install an Android emulator on Mac
What's included
SDK (
kotlin/)McpAppsTransportinterface for different transport implementationsscripts/generate-kotlin-types.tsExample App (
examples/basic-host-kotlin/)CI
Architecture Note
The
WebViewTransportis in the example app rather than the SDK because:WKWebViewTransportbecause Swift compiles natively for iOSHow to test
🤖 Generated with Claude Code