McpAppHost

interface McpAppHost(source)

What the host does for a view. Every method has a safe default (decline, ignore), so a host implements only what it offers.

Functions

Link copied to clipboard
open suspend fun approveToolCall(tool: McpTool, arguments: JsonObject): Boolean

Whether the view may run tool now. The default follows the library's rule — tools that change data ask the user — so read-only tools pass and others are declined unless the host asks the user.

Link copied to clipboard
open fun audit(method: String, params: JsonElement?)

Every request and notification the view sends, for an audit trail (§"Auditable Communication").

Link copied to clipboard
open fun log(level: String, data: JsonElement?)

notifications/message from the view.

Link copied to clipboard
open suspend fun message(text: String, content: JsonArray): Boolean

ui/message: add a user message with text (the text blocks of content) to the chat.

Link copied to clipboard
open suspend fun openLink(url: String): Boolean

ui/open-link (http or https only; already checked): open url for the user.

Link copied to clipboard
open suspend fun requestDisplayMode(mode: String, current: String): String

ui/request-display-mode: switch to mode if possible; returns the resulting mode.

Link copied to clipboard
open fun requestTeardown()

ui/notifications/request-teardown: the view asks to be closed.

Link copied to clipboard
open fun sizeChanged(width: Double?, height: Double?)

ui/notifications/size-changed, in CSS pixels.

Link copied to clipboard
open suspend fun updateModelContext(content: JsonArray?, structuredContent: JsonElement?)

ui/update-model-context: what the model should know in later turns (replaces the previous one).