Skip to content

Commit 20b664c

Browse files
committed
docs: document that device_id in discover triggers device wake-up
Added a Discovery API section to initiation-protocol.md explaining that device_id must be included to wake the target device. Updated SDK docstrings in TypeScript, Python, and Rust to clarify that omitting device_id skips the FCM/SSE notification.
1 parent a8ee9b2 commit 20b664c

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

docs/initiation-protocol.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ Phone/CLI Discovery API WS Server Redis
2626
│ │ │ │
2727
```
2828

29+
## Discovery API
30+
31+
`POST /api/discover` — returns a worker WebSocket URL for connecting.
32+
33+
**Request body:**
34+
```json
35+
{ "device_id": "a1b2c3d4e5f67890..." }
36+
```
37+
38+
**Response:**
39+
```json
40+
{ "wsUrl": "wss://worker0.screenmcp.com" }
41+
```
42+
43+
When `device_id` is included, the server sends a wake-up notification (FCM push or SSE event) to the target device, telling it to connect to the worker. **If `device_id` is omitted, the server returns a worker URL but does NOT wake the device** — the caller must ensure the device is already connected.
44+
45+
Controllers should always pass `device_id` to ensure the target device is online and routed to the same worker.
46+
2947
## Message Format
3048

3149
All messages are JSON over WebSocket.

sdk/python/src/screenmcp/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ async def connect(self, device_id: str = "") -> "DeviceConnection":
115115
----------
116116
device_id:
117117
Target device UUID. If empty the server picks the first device
118-
registered to the authenticated user.
118+
registered to the authenticated user, but does **not** send a
119+
wake-up notification — the device must already be connected.
120+
Pass a device_id to ensure the server wakes the target device
121+
via FCM/SSE.
119122
120123
Returns
121124
-------

sdk/rust/src/client.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ impl ScreenMCPClient {
113113

114114
/// Discover a worker for the given device, open a WebSocket connection,
115115
/// authenticate, and return a ready-to-use [`DeviceConnection`].
116+
///
117+
/// The `device_id` is sent to the server which triggers a wake-up
118+
/// notification (FCM/SSE) to the target device. If you pass an empty
119+
/// string, the server returns a worker URL but does **not** wake the
120+
/// device — it must already be connected.
116121
pub async fn connect(&self, device_id: &str) -> Result<DeviceConnection> {
117122
let ws_url = self.discover(device_id).await?;
118123
let mut conn = DeviceConnection::new(

sdk/typescript/src/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export class ScreenMCPClient {
8888
* Returns a {@link DeviceConnection} that provides all command methods.
8989
*
9090
* @param options - Optional connect options. If `deviceId` is omitted the
91-
* server picks the first available device.
91+
* server picks the first available device but does NOT send a wake-up
92+
* notification — the device must already be connected. Pass `deviceId`
93+
* to ensure the server wakes the target device via FCM/SSE.
9294
*/
9395
async connect(options?: ConnectOptions): Promise<DeviceConnection> {
9496
const deviceId = options?.deviceId;

0 commit comments

Comments
 (0)