public static class McpClient.AsyncSpec extends Object
The builder supports configuration of:
| Modifier and Type | Method and Description |
|---|---|
McpAsyncClient |
build()
Create an instance of
McpAsyncClient with the provided configurations
or sensible defaults. |
McpClient.AsyncSpec |
capabilities(McpSchema.ClientCapabilities capabilities)
Sets the client capabilities that will be advertised to the server during
connection initialization.
|
McpClient.AsyncSpec |
clientInfo(McpSchema.Implementation clientInfo)
Sets the client implementation information that will be shared with the server
during connection initialization.
|
McpClient.AsyncSpec |
initializationTimeout(Duration initializationTimeout) |
McpClient.AsyncSpec |
loggingConsumer(Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>> loggingConsumer)
Adds a consumer to be notified when logging messages are received from the
server.
|
McpClient.AsyncSpec |
loggingConsumers(List<Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>>> loggingConsumers)
Adds multiple consumers to be notified when logging messages are received from
the server.
|
McpClient.AsyncSpec |
promptsChangeConsumer(Function<List<McpSchema.Prompt>,reactor.core.publisher.Mono<Void>> promptsChangeConsumer)
Adds a consumer to be notified when the available prompts change.
|
McpClient.AsyncSpec |
requestTimeout(Duration requestTimeout)
Sets the duration to wait for server responses before timing out requests.
|
McpClient.AsyncSpec |
resourcesChangeConsumer(Function<List<McpSchema.Resource>,reactor.core.publisher.Mono<Void>> resourcesChangeConsumer)
Adds a consumer to be notified when the available resources change.
|
McpClient.AsyncSpec |
roots(List<McpSchema.Root> roots)
Sets the root URIs that this client can access.
|
McpClient.AsyncSpec |
roots(McpSchema.Root... roots)
Sets the root URIs that this client can access, using a varargs parameter for
convenience.
|
McpClient.AsyncSpec |
sampling(Function<McpSchema.CreateMessageRequest,reactor.core.publisher.Mono<McpSchema.CreateMessageResult>> samplingHandler)
Sets a custom sampling handler for processing message creation requests.
|
McpClient.AsyncSpec |
toolsChangeConsumer(Function<List<McpSchema.Tool>,reactor.core.publisher.Mono<Void>> toolsChangeConsumer)
Adds a consumer to be notified when the available tools change.
|
public McpClient.AsyncSpec requestTimeout(Duration requestTimeout)
requestTimeout - The duration to wait before timing out requests. Must not
be null.IllegalArgumentException - if requestTimeout is nullpublic McpClient.AsyncSpec initializationTimeout(Duration initializationTimeout)
initializationTimeout - The duration to wait for the initializaiton
lifecycle step to complete.IllegalArgumentException - if initializationTimeout is nullpublic McpClient.AsyncSpec capabilities(McpSchema.ClientCapabilities capabilities)
capabilities - The client capabilities configuration. Must not be null.IllegalArgumentException - if capabilities is nullpublic McpClient.AsyncSpec clientInfo(McpSchema.Implementation clientInfo)
clientInfo - The client implementation details including name and version.
Must not be null.IllegalArgumentException - if clientInfo is nullpublic McpClient.AsyncSpec roots(List<McpSchema.Root> roots)
roots - A list of root definitions. Must not be null.IllegalArgumentException - if roots is nullpublic McpClient.AsyncSpec roots(McpSchema.Root... roots)
roots(List).roots - An array of root definitions. Must not be null.IllegalArgumentException - if roots is nullroots(List)public McpClient.AsyncSpec sampling(Function<McpSchema.CreateMessageRequest,reactor.core.publisher.Mono<McpSchema.CreateMessageResult>> samplingHandler)
samplingHandler - A function that processes message requests and returns
results. Must not be null.IllegalArgumentException - if samplingHandler is nullpublic McpClient.AsyncSpec toolsChangeConsumer(Function<List<McpSchema.Tool>,reactor.core.publisher.Mono<Void>> toolsChangeConsumer)
toolsChangeConsumer - A consumer that receives the updated list of
available tools. Must not be null.IllegalArgumentException - if toolsChangeConsumer is nullpublic McpClient.AsyncSpec resourcesChangeConsumer(Function<List<McpSchema.Resource>,reactor.core.publisher.Mono<Void>> resourcesChangeConsumer)
resourcesChangeConsumer - A consumer that receives the updated list of
available resources. Must not be null.IllegalArgumentException - if resourcesChangeConsumer is nullpublic McpClient.AsyncSpec promptsChangeConsumer(Function<List<McpSchema.Prompt>,reactor.core.publisher.Mono<Void>> promptsChangeConsumer)
promptsChangeConsumer - A consumer that receives the updated list of
available prompts. Must not be null.IllegalArgumentException - if promptsChangeConsumer is nullpublic McpClient.AsyncSpec loggingConsumer(Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>> loggingConsumer)
loggingConsumer - A consumer that receives logging messages. Must not be
null.public McpClient.AsyncSpec loggingConsumers(List<Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>>> loggingConsumers)
loggingConsumers - A list of consumers that receive logging messages. Must
not be null.public McpAsyncClient build()
McpAsyncClient with the provided configurations
or sensible defaults.McpAsyncClient.Copyright © 2025. All rights reserved.