public static class McpClient.SyncSpec extends Object
The builder supports configuration of:
| Modifier and Type | Method and Description |
|---|---|
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(Duration initializationTimeout) |
McpClient.SyncSpec |
loggingConsumer(Consumer<McpSchema.LoggingMessageNotification> loggingConsumer)
Adds a consumer to be notified when logging messages are received from the
server.
|
McpClient.SyncSpec |
loggingConsumers(List<Consumer<McpSchema.LoggingMessageNotification>> loggingConsumers)
Adds multiple consumers to be notified when logging messages are received from
the server.
|
McpClient.SyncSpec |
promptsChangeConsumer(Consumer<List<McpSchema.Prompt>> promptsChangeConsumer)
Adds a consumer to be notified when the available prompts change.
|
McpClient.SyncSpec |
requestTimeout(Duration requestTimeout)
Sets the duration to wait for server responses before timing out requests.
|
McpClient.SyncSpec |
resourcesChangeConsumer(Consumer<List<McpSchema.Resource>> resourcesChangeConsumer)
Adds a consumer to be notified when the available resources change.
|
McpClient.SyncSpec |
roots(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(Function<McpSchema.CreateMessageRequest,McpSchema.CreateMessageResult> samplingHandler)
Sets a custom sampling handler for processing message creation requests.
|
McpClient.SyncSpec |
toolsChangeConsumer(Consumer<List<McpSchema.Tool>> toolsChangeConsumer)
Adds a consumer to be notified when the available tools change.
|
public McpClient.SyncSpec requestTimeout(Duration requestTimeout)
requestTimeout - The duration to wait before timing out requests. Must not
be null.IllegalArgumentException - if requestTimeout is nullpublic McpClient.SyncSpec initializationTimeout(Duration initializationTimeout)
initializationTimeout - The duration to wait for the initializaiton
lifecycle step to complete.IllegalArgumentException - if initializationTimeout is nullpublic McpClient.SyncSpec capabilities(McpSchema.ClientCapabilities capabilities)
capabilities - The client capabilities configuration. Must not be null.IllegalArgumentException - if capabilities is nullpublic McpClient.SyncSpec clientInfo(McpSchema.Implementation clientInfo)
clientInfo - The client implementation details including name and version.
Must not be null.IllegalArgumentException - if clientInfo is nullpublic McpClient.SyncSpec roots(List<McpSchema.Root> roots)
roots - A list of root definitions. Must not be null.IllegalArgumentException - if roots is nullpublic McpClient.SyncSpec roots(McpSchema.Root... roots)
roots(List).roots - An array of root definitions. Must not be null.IllegalArgumentException - if roots is nullroots(List)public McpClient.SyncSpec sampling(Function<McpSchema.CreateMessageRequest,McpSchema.CreateMessageResult> samplingHandler)
samplingHandler - A function that processes message requests and returns
results. Must not be null.IllegalArgumentException - if samplingHandler is nullpublic McpClient.SyncSpec toolsChangeConsumer(Consumer<List<McpSchema.Tool>> toolsChangeConsumer)
toolsChangeConsumer - A consumer that receives the updated list of
available tools. Must not be null.IllegalArgumentException - if toolsChangeConsumer is nullpublic McpClient.SyncSpec resourcesChangeConsumer(Consumer<List<McpSchema.Resource>> resourcesChangeConsumer)
resourcesChangeConsumer - A consumer that receives the updated list of
available resources. Must not be null.IllegalArgumentException - if resourcesChangeConsumer is nullpublic McpClient.SyncSpec promptsChangeConsumer(Consumer<List<McpSchema.Prompt>> promptsChangeConsumer)
promptsChangeConsumer - A consumer that receives the updated list of
available prompts. Must not be null.IllegalArgumentException - if promptsChangeConsumer is nullpublic McpClient.SyncSpec loggingConsumer(Consumer<McpSchema.LoggingMessageNotification> loggingConsumer)
loggingConsumer - A consumer that receives logging messages. Must not be
null.public McpClient.SyncSpec loggingConsumers(List<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.Copyright © 2025. All rights reserved.