Find a file
Jason Monk da28a140b0 Fix TLS handshake: handle multi-record mux DATA frames, use Channel.receive()
Two bugs prevented the TLS handshake from completing:

1. TlsAcceptor NEED_UNWRAP always called stream.read() even when netIn
   already had data from a previous read. When the client sends
   ClientKeyExchange + ChangeCipherSpec + Finished in a single mux DATA
   frame, the first unwrap consumed part of it, the loop hit NEED_UNWRAP
   again and blocked on stream.read() forever. Fix: only read from the
   stream when netIn is empty.

2. MuxStreamImpl.read() used flow.first() which throws
   NoSuchElementException on empty flow completion. Changed to
   Channel.receive() which throws ClosedReceiveChannelException with a
   clearer error message.

Verified: full TLS handshake completes end-to-end through the relay
passthrough to the device (CN=main-board.rousecontext.com, TLSv1.2).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 15:15:56 -04:00
.claude Add .claude/worktrees/ to .gitignore, remove stale worktree refs from index 2026-04-05 15:25:14 -04:00
.github/workflows Add Android CI and Relay CI workflows 2026-04-05 19:46:36 -04:00
api Remove stale mcp-core/ and mcp-health/ directories, fix conflict markers in health build files 2026-04-05 12:42:38 -04:00
app Extract core:bridge module for TLS accept + MCP session bridging 2026-04-06 14:22:37 -04:00
config/detekt Add Compose screens with mock data, Roborazzi screenshot tests, and HTML dashboard 2026-04-04 16:50:39 -04:00
core Fix TLS handshake: handle multi-record mux DATA frames, use Channel.receive() 2026-04-06 15:15:56 -04:00
deploy Fix systemd unit: ReadWritePaths for device CA, positional config arg 2026-04-06 13:34:40 -04:00
device-tests Fix device integration tests: manifest, permissions, and plain-HTTP relay 2026-04-05 17:31:54 -04:00
docs Document e2e status: mTLS connection works, passthrough routing is the current blocker 2026-04-06 14:10:36 -04:00
gradle Switch tunnel WebSocket from Ktor CIO to OkHttp for mTLS support 2026-04-05 21:37:23 -04:00
health Add RealHealthConnectRepository with Health Connect SDK wrapper 2026-04-05 15:54:55 -04:00
integration-tests Add tunnel mux protocol and integration tests against mock relay 2026-04-05 09:58:53 -04:00
notifications Regenerate screenshots and fix ktlint violations across modules 2026-04-05 20:12:34 -04:00
relay Seed main-board device in InMemoryFirestore for e2e testing 2026-04-06 15:07:45 -04:00
tunnel/src/test/java/com/rousecontext/tunnel/mux Merge T-16: Tunnel + relay integration tests with mock relay server 2026-04-05 10:00:46 -04:00
work Extract core:bridge module for TLS accept + MCP session bridging 2026-04-06 14:22:37 -04:00
.editorconfig Add Compose screens with mock data, Roborazzi screenshot tests, and HTML dashboard 2026-04-04 16:50:39 -04:00
.gitignore Add Firebase: google-services.json, Google Services plugin, debug applicationIdSuffix 2026-04-05 15:38:40 -04:00
BLOCKERS.md Configure mTLS client cert for relay WebSocket connection 2026-04-05 19:58:55 -04:00
build.gradle.kts Add Firebase: google-services.json, Google Services plugin, debug applicationIdSuffix 2026-04-05 15:38:40 -04:00
gradle.properties Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
gradlew Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
gradlew.bat Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
last_session Merge T-1 interfaces: TunnelState, TunnelError, CertificateStore, TunnelClient (KMP) 2026-04-05 07:25:50 -04:00
LICENSE Initial commit 2026-04-03 19:35:18 -04:00
README.md Initial project scaffold: multi-module Android/Kotlin Gradle project 2026-04-03 19:38:30 -04:00
settings.gradle.kts Extract core:bridge module for TLS accept + MCP session bridging 2026-04-06 14:22:37 -04:00

Rouse Context

On-demand MCP (Model Context Protocol) server for Android.

Overview

Rouse Context turns your Android device into an MCP server that AI assistants can connect to on demand. Sessions are triggered via FCM push notifications — the device wakes up, provisions a per-device ACME TLS certificate, and establishes an end-to-end encrypted connection through an SNI passthrough relay. No persistent cloud sync of user data ever occurs; all context stays on the device until explicitly served over a live session.

Architecture

Module Purpose
:app Main application shell — UI, session history/audit log, trust notifications, settings
:tunnel FCM wakeup, ACME cert provisioning, SNI passthrough relay client, session lifecycle, wakelock management
:mcp-core Thin abstractions over the MCP Kotlin SDK — defines McpServerProvider, the bindable-service contract for MCP servers
:mcp-health Health Connect MCP server implementation

Key properties

  • FCM-triggered — no persistent connection; the device is woken only when a session is requested.
  • E2E encrypted — TLS terminates on the device via per-device ACME certificates. The relay performs SNI passthrough only and never sees plaintext.
  • No cloud sync — user data is read from on-device sources (Health Connect, etc.) and served live. Nothing is persisted in the cloud.
  • Extensible — additional MCP servers can be added as new modules implementing McpServerProvider, or installed as third-party apps binding to the same service protocol.

Building

./gradlew assembleDebug

Requires Android SDK with API 35 and JDK 17+.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.