Builder
Builder for creating a Client instance.
Usage:
val client = Client.Builder()
.withClientInfo("MyCustomClient", "1.0.0")
.withRoot(Root(uri = "file:///home/user/project", name = "My Project"))
.withSamplingProvider { createMessageParams ->
// ...
}
.withTransport(StdioTransport()))
.withTransportLogger(
logIncoming = { msg -> println("CLIENT INCOMING: $msg") },
logOutgoing = { msg -> println("CLIENT OUTGOING: $msg") },
)
.build()
client.start()
client.initialize()Roots capabilities is enabled by default and returns an empty list.
Functions
Sets the client's name and version returned during initialization. Defaults to "MyClient" and "1.0.0" if not set.
Sets a coroutine dispatcher or context for the client's internal coroutines. Defaults to Dispatchers.Default.
Callback that is triggered when the server changes the list of tools. Useful for updating the tools when building a full client application.
Callback that should ask the user for permission to approve the given ClientApprovable. The callback should return true if the user approves the request, false otherwise.
Adds a Root the client.
Adds a SamplingProvider to the client's capabilities.
Sets separate loggers for incoming and outgoing transport messages.