Builder
Builder for constructing a Server instance.
All configuration is done via fluent API calls, and once build is called, you get a fully configured Server ready to be started with Server.start.
Example:
val server = Server.Builder()
.withPageSize(25)
.withPrompt(::myPromptFunction)
.withResourceProvider(myLocalFileProvider)
.withServerInfo("MyServer", "1.0.0")
.withTool(::myToolFunction)
.withTransport(myTransport)
.withTransportLogger(
logIncoming = { msg -> println("SERVER INCOMING: $msg") },
logOutgoing = { msg -> println("SERVER OUTGOING: $msg") },
)
.build()
server.start()Functions
Sets the coroutine context (or dispatcher) for the server's internal coroutines. Defaults to Dispatchers.Default if not set.
Sets the default page size for paginated responses. Defaults to 20.
Registers a prompt by referencing its @McpPrompt-annotated function.
Registers multiple prompts by referencing their @McpPrompt-annotated functions.
Registers a resource provider that can list/read resources.
Sets the server's name and version, reported in the initialize response. Defaults to "MyServer" and "1.0.0" if not provided.
Registers a tool by referencing its @McpTool-annotated function.
Registers multiple tools by referencing their @McpTool-annotated functions.
Sets separate loggers for incoming and outgoing transport messages.