Transport

interface Transport(source)

Describes the minimal contract for MCP transport that a client or server can communicate over.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun close()

Closes the connection.

Link copied to clipboard
abstract fun onClose(block: () -> Unit)

Callback for when the connection is closed for any reason.

Link copied to clipboard
abstract fun onError(block: (Throwable) -> Unit)

Callback for when an error occurs.

Link copied to clipboard
abstract fun onMessage(block: suspend (JSONRPCMessage) -> Unit)

Callback for when a message (request or response) is received over the connection.

Link copied to clipboard
abstract suspend fun send(message: JSONRPCMessage)

Sends a JSON-RPC message (request or response).

Link copied to clipboard
abstract suspend fun start()

Starts processing messages on the transport, including any connection steps that might need to be taken.