public static class McpClient.AsyncSpec
extends java.lang.Object
The builder supports configuration of:
限定符和类型 | 方法和说明 |
---|---|
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(java.time.Duration initializationTimeout) |
McpClient.AsyncSpec |
loggingConsumer(java.util.function.Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<java.lang.Void>> loggingConsumer)
Adds a consumer to be notified when logging messages are received from the
server.
|
McpClient.AsyncSpec |
loggingConsumers(java.util.List<java.util.function.Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<java.lang.Void>>> loggingConsumers)
Adds multiple consumers to be notified when logging messages are received from
the server.
|
McpClient.AsyncSpec |
promptsChangeConsumer(java.util.function.Function<java.util.List<McpSchema.Prompt>,reactor.core.publisher.Mono<java.lang.Void>> promptsChangeConsumer)
Adds a consumer to be notified when the available prompts change.
|
McpClient.AsyncSpec |
requestTimeout(java.time.Duration requestTimeout)
Sets the duration to wait for server responses before timing out requests.
|
McpClient.AsyncSpec |
resourcesChangeConsumer(java.util.function.Function<java.util.List<McpSchema.Resource>,reactor.core.publisher.Mono<java.lang.Void>> resourcesChangeConsumer)
Adds a consumer to be notified when the available resources change.
|
McpClient.AsyncSpec |
roots(java.util.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(java.util.function.Function<McpSchema.CreateMessageRequest,reactor.core.publisher.Mono<McpSchema.CreateMessageResult>> samplingHandler)
Sets a custom sampling handler for processing message creation requests.
|
McpClient.AsyncSpec |
toolsChangeConsumer(java.util.function.Function<java.util.List<McpSchema.Tool>,reactor.core.publisher.Mono<java.lang.Void>> toolsChangeConsumer)
Adds a consumer to be notified when the available tools change.
|
public McpClient.AsyncSpec requestTimeout(java.time.Duration requestTimeout)
requestTimeout
- The duration to wait before timing out requests. Must not
be null.java.lang.IllegalArgumentException
- if requestTimeout is nullpublic McpClient.AsyncSpec initializationTimeout(java.time.Duration initializationTimeout)
initializationTimeout
- The duration to wait for the initializaiton
lifecycle step to complete.java.lang.IllegalArgumentException
- if initializationTimeout is nullpublic McpClient.AsyncSpec capabilities(McpSchema.ClientCapabilities capabilities)
capabilities
- The client capabilities configuration. Must not be null.java.lang.IllegalArgumentException
- if capabilities is nullpublic McpClient.AsyncSpec clientInfo(McpSchema.Implementation clientInfo)
clientInfo
- The client implementation details including name and version.
Must not be null.java.lang.IllegalArgumentException
- if clientInfo is nullpublic McpClient.AsyncSpec roots(java.util.List<McpSchema.Root> roots)
roots
- A list of root definitions. Must not be null.java.lang.IllegalArgumentException
- if roots is nullpublic McpClient.AsyncSpec roots(McpSchema.Root... roots)
roots(List)
.roots
- An array of root definitions. Must not be null.java.lang.IllegalArgumentException
- if roots is nullroots(List)
public McpClient.AsyncSpec sampling(java.util.function.Function<McpSchema.CreateMessageRequest,reactor.core.publisher.Mono<McpSchema.CreateMessageResult>> samplingHandler)
samplingHandler
- A function that processes message requests and returns
results. Must not be null.java.lang.IllegalArgumentException
- if samplingHandler is nullpublic McpClient.AsyncSpec toolsChangeConsumer(java.util.function.Function<java.util.List<McpSchema.Tool>,reactor.core.publisher.Mono<java.lang.Void>> toolsChangeConsumer)
toolsChangeConsumer
- A consumer that receives the updated list of
available tools. Must not be null.java.lang.IllegalArgumentException
- if toolsChangeConsumer is nullpublic McpClient.AsyncSpec resourcesChangeConsumer(java.util.function.Function<java.util.List<McpSchema.Resource>,reactor.core.publisher.Mono<java.lang.Void>> resourcesChangeConsumer)
resourcesChangeConsumer
- A consumer that receives the updated list of
available resources. Must not be null.java.lang.IllegalArgumentException
- if resourcesChangeConsumer is nullpublic McpClient.AsyncSpec promptsChangeConsumer(java.util.function.Function<java.util.List<McpSchema.Prompt>,reactor.core.publisher.Mono<java.lang.Void>> promptsChangeConsumer)
promptsChangeConsumer
- A consumer that receives the updated list of
available prompts. Must not be null.java.lang.IllegalArgumentException
- if promptsChangeConsumer is nullpublic McpClient.AsyncSpec loggingConsumer(java.util.function.Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<java.lang.Void>> loggingConsumer)
loggingConsumer
- A consumer that receives logging messages. Must not be
null.public McpClient.AsyncSpec loggingConsumers(java.util.List<java.util.function.Function<McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<java.lang.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
.