Package-level declarations

Types

Link copied to clipboard
class McpAgentTool(client: McpClient, val tool: McpTool, val server: McpServerConfig) : AgentTool

One MCP tool as an AgentTool. The model sees <server>__<tool> (unique across servers, within the 64-character limit), the UI the tool's title and server name. Progress notifications stream as preliminary output; results the server flags isError become tool errors; questions the server asks the user (elicitation) go to the chat's dev.ai.elements.core.chat.ToolApprover.input.

Link copied to clipboard
@Serializable
enum McpApproval : Enum<McpApproval>

When an MCP tool asks the user before running.

Link copied to clipboard
object McpApps

The MCP Apps extension (SEP-1865, stable revision 2026-01-26): tools whose results an interactive HTML view (ui:// resource) renders. The host side — sandbox, the ui/… message bridge — is ai-elements-mcp-apps; this is what the MCP client needs: the extension id, the negotiation and the view's media type.

Link copied to clipboard
interface McpAuth

Supplies bearer tokens to an McpClient.

Link copied to clipboard
class McpAuthRequiredException(val serverUrl: String, val resourceMetadataUrl: String?, val scope: String?) : McpException

The server requires authorization (HTTP 401) and no usable credentials are configured. resourceMetadataUrl (RFC 9728) and scope come from the WWW-Authenticate challenge and feed McpOAuth.discover.

Link copied to clipboard
class McpClient(val url: String, headers: Map<String, String> = emptyMap(), auth: McpAuth? = null, http: OkHttpClient = DefaultHttpClient, clientInfo: McpImplementation = McpImplementation("ai-elements-kotlin", "0.3.0"), capabilities: JsonObject = JsonObject(emptyMap()))

A Model Context Protocol client over the Streamable HTTP transport.

Link copied to clipboard
sealed interface McpContent

One item of a tool result or prompt message.

Link copied to clipboard
open class McpException(message: String, val code: Int? = null, val data: JsonElement? = null, cause: Throwable? = null) : Exception

A JSON-RPC error from the server, or a transport failure (code null).

Link copied to clipboard
data class McpImplementation(val name: String, val version: String, val title: String? = null)

Name and version of an MCP client or server (Implementation).

Link copied to clipboard
typealias McpInputHandler = suspend (InputRequest) -> InputResponse

Answers a server's question to the user (MCP elicitation) with the user's response.

Link copied to clipboard
class McpOAuth(http: OkHttpClient = DefaultHttpClient)

MCP authorization (OAuth 2.1) discovery and client registration, per the MCP authorization spec:

Link copied to clipboard
@Serializable
data class McpOAuthRegistration(val resource: String, val authorizationEndpoint: String, val tokenEndpoint: String, val clientId: String, val clientSecret: String? = null, val scope: String? = null, val redirectUri: String)

What McpOAuth.discover learned about an MCP server's authorization and the client it registered — persist it with the tokens.

Link copied to clipboard
class McpOAuthTokens(registration: McpOAuthRegistration, store: TokenStore, client: OAuthClient = OAuthClient(), now: () -> Long = System::currentTimeMillis) : McpAuth

McpAuth over OAuth tokens kept in store: refreshes shortly before expiry and after a 401, single-flight, sending the resource indicator.

Link copied to clipboard
data class McpProgress(val progress: Double, val total: Double? = null, val message: String? = null)

A progress notification for a running request (notifications/progress).

Link copied to clipboard
data class McpPrompt(val name: String, val title: String? = null, val description: String? = null, val arguments: List<McpPromptArgument> = emptyList())

A prompt template listed by prompts/list.

Link copied to clipboard
data class McpPromptArgument(val name: String, val description: String? = null, val required: Boolean = false)
Link copied to clipboard
data class McpResource(val uri: String, val name: String, val title: String? = null, val description: String? = null, val mimeType: String? = null)

A resource listed by resources/list.

Link copied to clipboard
@Serializable
data class McpServerConfig(val id: String, val name: String, val url: String, val enabled: Boolean = true, val auth: McpServerConfig.Auth = Auth.NONE, val approval: McpApproval = McpApproval.UNLESS_READ_ONLY, val disabledTools: Set<String> = emptySet())

How an app configures one remote MCP server. Secrets (tokens) are stored separately.

Link copied to clipboard
sealed interface McpServerStatus

What happened when a server's tools were listed for a turn.

Link copied to clipboard
data class McpTool(val name: String, val title: String? = null, val description: String? = null, val inputSchema: JsonObject, val outputSchema: JsonObject? = null, val annotations: McpToolAnnotations? = null, val meta: JsonObject? = null)

A tool offered by an MCP server (tools/list).

Link copied to clipboard
data class McpToolAnnotations(val title: String? = null, val readOnlyHint: Boolean? = null, val destructiveHint: Boolean? = null, val idempotentHint: Boolean? = null, val openWorldHint: Boolean? = null)

Hints a server gives about a tool (ToolAnnotations). They are untrusted unless the server is: use them for defaults (e.g. skip the confirmation for read-only tools), never as a security boundary.

Link copied to clipboard
data class McpToolResult(val content: List<McpContent>, val structuredContent: JsonElement? = null, val isError: Boolean = false, val raw: JsonObject? = null)

The result of tools/call. isError results are tool failures the model should see.

Link copied to clipboard
class McpToolset(servers: List<McpServerConfig>, clientFor: (McpServerConfig) -> McpClient, timeoutMs: Long, cacheMs: Long = 5 * 60_000, now: () -> Long = System::currentTimeMillis) : Capability

The enabled MCP servers as a Capability: their tools, listed in parallel with a timeoutMs per server. A server that fails is skipped (see status) instead of failing the turn. Tool lists are cached for cacheMs; invalidate forces a refresh.

Functions

Link copied to clipboard
fun McpTool.toJson(): JsonObject

The tool as MCP Tool JSON (for an MCP App's hostContext.toolInfo).