ServerSession

open class ServerSession(serverInfo: Implementation, options: ServerOptions, instructions: String?) : Protocol(source)

Constructors

Link copied to clipboard
constructor(serverInfo: Implementation, options: ServerOptions, instructions: String?)

Properties

Link copied to clipboard
var clientCapabilities: ClientCapabilities?

The client's reported capabilities after initialization.

Link copied to clipboard
var clientVersion: Implementation?

The client's version information after initialization.

Link copied to clipboard
var fallbackNotificationHandler: suspend (notification: JSONRPCNotification) -> Unit?
Link copied to clipboard
var fallbackRequestHandler: suspend (request: JSONRPCRequest, extra: RequestHandlerExtra) -> RequestResult??
Link copied to clipboard
val notificationHandlers: Map<String, suspend (notification: JSONRPCNotification) -> Unit>
Link copied to clipboard
val progressHandlers: Map<RequestId, ProgressCallback>
Link copied to clipboard
val requestHandlers: Map<String, suspend (request: JSONRPCRequest, extra: RequestHandlerExtra) -> RequestResult?>
Link copied to clipboard
val responseHandlers: Map<RequestId, (response: JSONRPCResponse?, error: Exception?) -> Unit>
Link copied to clipboard
var transport: Transport?

Functions

Link copied to clipboard
open override fun assertRequestHandlerCapability(method: Method)

Asserts that the server can handle the specified request method.

Link copied to clipboard
suspend fun close()
Link copied to clipboard
open suspend fun connect(transport: Transport)
Link copied to clipboard
suspend fun createElicitation(message: String, requestedSchema: CreateElicitationRequest.RequestedSchema, options: RequestOptions? = null): CreateElicitationResult
Link copied to clipboard
suspend fun createMessage(params: CreateMessageRequest, options: RequestOptions? = null): CreateMessageResult

Creates a message using the server's sampling capability.

Link copied to clipboard
suspend fun listRoots(params: JsonObject = EmptyJsonObject, options: RequestOptions? = null): ListRootsResult

Lists the available "roots" from the client's perspective (if supported).

Link copied to clipboard
suspend fun notification(notification: Notification)
Link copied to clipboard
open override fun onClose()

Called when the server session is closing.

fun onClose(block: () -> Unit)

Registers a callback to be invoked when the server session is closing.

Link copied to clipboard
open fun onError(error: Throwable)
Link copied to clipboard
fun onInitialized(block: () -> Unit)

Registers a callback to be invoked when the server has completed initialization.

Link copied to clipboard
suspend fun ping(): EmptyRequestResult

Sends a ping request to the client to check connectivity.

Link copied to clipboard
fun removeNotificationHandler(method: Method)
Link copied to clipboard
fun removeRequestHandler(method: Method)
Link copied to clipboard
suspend fun <T : RequestResult> request(request: Request, options: RequestOptions?): T
Link copied to clipboard
suspend fun sendLoggingMessage(notification: LoggingMessageNotification)

Sends a logging message notification to the client.

Link copied to clipboard
suspend fun sendPromptListChanged()

Sends a notification to the client indicating that the list of prompts has changed.

Link copied to clipboard

Sends a notification to the client indicating that the list of resources has changed.

Link copied to clipboard
suspend fun sendResourceUpdated(notification: ResourceUpdatedNotification)

Sends a resource-updated notification to the client, indicating that a specific resource has changed.

Link copied to clipboard
suspend fun sendToolListChanged()

Sends a notification to the client indicating that the list of tools has changed.

Link copied to clipboard
fun <T : Notification> setNotificationHandler(method: Method, handler: (notification: T) -> Deferred<Unit>)
Link copied to clipboard
inline fun <T : Request> setRequestHandler(method: Method, noinline block: suspend (T, RequestHandlerExtra) -> RequestResult?)