public static class McpClient.SyncSpec
extends java.lang.Object
The builder supports configuration of:
限定符和类型 | 方法和说明 |
---|---|
McpSyncClient |
build()
Create an instance of
McpSyncClient with the provided configurations or
sensible defaults. |
McpClient.SyncSpec |
capabilities(McpSchema.ClientCapabilities capabilities)
Sets the client capabilities that will be advertised to the server during
connection initialization.
|
McpClient.SyncSpec |
clientInfo(McpSchema.Implementation clientInfo)
Sets the client implementation information that will be shared with the server
during connection initialization.
|
McpClient.SyncSpec |
initializationTimeout(java.time.Duration initializationTimeout) |
McpClient.SyncSpec |
loggingConsumer(java.util.function.Consumer<McpSchema.LoggingMessageNotification> loggingConsumer)
Adds a consumer to be notified when logging messages are received from the
server.
|
McpClient.SyncSpec |
loggingConsumers(java.util.List<java.util.function.Consumer<McpSchema.LoggingMessageNotification>> loggingConsumers)
Adds multiple consumers to be notified when logging messages are received from
the server.
|
McpClient.SyncSpec |
promptsChangeConsumer(java.util.function.Consumer<java.util.List<McpSchema.Prompt>> promptsChangeConsumer)
Adds a consumer to be notified when the available prompts change.
|
McpClient.SyncSpec |
requestTimeout(java.time.Duration requestTimeout)
Sets the duration to wait for server responses before timing out requests.
|
McpClient.SyncSpec |
resourcesChangeConsumer(java.util.function.Consumer<java.util.List<McpSchema.Resource>> resourcesChangeConsumer)
Adds a consumer to be notified when the available resources change.
|
McpClient.SyncSpec |
roots(java.util.List<McpSchema.Root> roots)
Sets the root URIs that this client can access.
|
McpClient.SyncSpec |
roots(McpSchema.Root... roots)
Sets the root URIs that this client can access, using a varargs parameter for
convenience.
|
McpClient.SyncSpec |
sampling(java.util.function.Function<McpSchema.CreateMessageRequest,McpSchema.CreateMessageResult> samplingHandler)
Sets a custom sampling handler for processing message creation requests.
|
McpClient.SyncSpec |
toolsChangeConsumer(java.util.function.Consumer<java.util.List<McpSchema.Tool>> toolsChangeConsumer)
Adds a consumer to be notified when the available tools change.
|
public McpClient.SyncSpec 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.SyncSpec 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.SyncSpec capabilities(McpSchema.ClientCapabilities capabilities)
capabilities
- The client capabilities configuration. Must not be null.java.lang.IllegalArgumentException
- if capabilities is nullpublic McpClient.SyncSpec 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.SyncSpec 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.SyncSpec 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.SyncSpec sampling(java.util.function.Function<McpSchema.CreateMessageRequest,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.SyncSpec toolsChangeConsumer(java.util.function.Consumer<java.util.List<McpSchema.Tool>> toolsChangeConsumer)
toolsChangeConsumer
- A consumer that receives the updated list of
available tools. Must not be null.java.lang.IllegalArgumentException
- if toolsChangeConsumer is nullpublic McpClient.SyncSpec resourcesChangeConsumer(java.util.function.Consumer<java.util.List<McpSchema.Resource>> resourcesChangeConsumer)
resourcesChangeConsumer
- A consumer that receives the updated list of
available resources. Must not be null.java.lang.IllegalArgumentException
- if resourcesChangeConsumer is nullpublic McpClient.SyncSpec promptsChangeConsumer(java.util.function.Consumer<java.util.List<McpSchema.Prompt>> promptsChangeConsumer)
promptsChangeConsumer
- A consumer that receives the updated list of
available prompts. Must not be null.java.lang.IllegalArgumentException
- if promptsChangeConsumer is nullpublic McpClient.SyncSpec loggingConsumer(java.util.function.Consumer<McpSchema.LoggingMessageNotification> loggingConsumer)
loggingConsumer
- A consumer that receives logging messages. Must not be
null.public McpClient.SyncSpec loggingConsumers(java.util.List<java.util.function.Consumer<McpSchema.LoggingMessageNotification>> loggingConsumers)
loggingConsumers
- A list of consumers that receive logging messages. Must
not be null.public McpSyncClient build()
McpSyncClient
with the provided configurations or
sensible defaults.McpSyncClient
.