McpServer

class McpServer(val configuration: McpServerConfiguration = McpServerConfiguration(), configureTools: Server.() -> Unit = {})

An opt-in, loopback-only MCP Streamable HTTP server for Android compositions.

No socket is opened until start. The caller owns Screen/camera permission and lifecycle; detach the Screen before stopping or disposing its mixer. No token or image is logged.

configureTools registers application-owned tools using the official MCP SDK. It is called for each stateless request; register handlers only, without performing operations here. Tool handlers must enforce their application's permission and threading requirements. The built-in names hello_android and capture_frame are reserved.

Constructors

Link copied to clipboard
constructor(configuration: McpServerConfiguration = McpServerConfiguration(), configureTools: Server.() -> Unit = {})

Properties

Link copied to clipboard
Link copied to clipboard

Local URL; forward this port with adb to connect from a development computer.

Link copied to clipboard

Whether the endpoint has successfully started.

Functions

Link copied to clipboard
fun attachScreen(screen: Screen)

Makes screen available to capture_frame. Does not start capture or own the Screen.

Link copied to clipboard
fun detachScreen(screen: Screen)

Invalidates captures from screen. Call before stopping or disposing its mixer. Schedule detachment/disposal on an independent lifecycle/controller thread, never inline in rendering/readback callbacks or on a thread synchronous readback waits for.

Link copied to clipboard
suspend fun start()

Starts the endpoint off the UI thread. Idempotent; bind/setup failures are thrown.

Link copied to clipboard
suspend fun stop()

Stops the endpoint off the UI thread. The attached Screen remains caller-owned.