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 |
elicitation(java.util.function.Function<McpSchema.ElicitRequest,McpSchema.ElicitResult> elicitationHandler)
Sets a custom elicitation handler for processing elicitation message requests.
|
McpClient.SyncSpec |
enableCallToolSchemaCaching(boolean enableCallToolSchemaCaching)
Enables automatic schema caching during callTool operations.
|
McpClient.SyncSpec |
initializationTimeout(java.time.Duration initializationTimeout) |
McpClient.SyncSpec |
jsonSchemaValidator(JsonSchemaValidator jsonSchemaValidator)
Add a
JsonSchemaValidator to validate the JSON structure of the
structured output. |
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 |
progressConsumer(java.util.function.Consumer<McpSchema.ProgressNotification> progressConsumer)
Adds a consumer to be notified of progress notifications from the server.
|
McpClient.SyncSpec |
progressConsumers(java.util.List<java.util.function.Consumer<McpSchema.ProgressNotification>> progressConsumers)
Adds a multiple consumers to be notified of progress notifications 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 |
resourcesUpdateConsumer(java.util.function.Consumer<java.util.List<McpSchema.ResourceContents>> resourcesUpdateConsumer)
Adds a consumer to be notified when a specific resource is updated.
|
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.
|
McpClient.SyncSpec |
transportContextProvider(java.util.function.Supplier<McpTransportContext> contextProvider)
Add a provider of
McpTransportContext, providing a context before
calling any client operation. |
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 initialization
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 elicitation(java.util.function.Function<McpSchema.ElicitRequest,McpSchema.ElicitResult> elicitationHandler)
elicitationHandler - A function that processes elicitation requests and
returns results. Must not be null.java.lang.IllegalArgumentException - if elicitationHandler 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 resourcesUpdateConsumer(java.util.function.Consumer<java.util.List<McpSchema.ResourceContents>> resourcesUpdateConsumer)
resourcesUpdateConsumer - A consumer function that processes the updated
resource and returns a Mono indicating the completion of the processing. Must
not be null.java.lang.IllegalArgumentException - If the resourcesUpdateConsumer is null.public 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 McpClient.SyncSpec progressConsumer(java.util.function.Consumer<McpSchema.ProgressNotification> progressConsumer)
progressConsumer - A consumer that receives progress notifications. Must
not be null.java.lang.IllegalArgumentException - if progressConsumer is nullpublic McpClient.SyncSpec progressConsumers(java.util.List<java.util.function.Consumer<McpSchema.ProgressNotification>> progressConsumers)
progressConsumers - A list of consumers that receives progress
notifications. Must not be null.java.lang.IllegalArgumentException - if progressConsumer is nullpublic McpClient.SyncSpec transportContextProvider(java.util.function.Supplier<McpTransportContext> contextProvider)
McpTransportContext, providing a context before
calling any client operation. This allows to extract thread-locals and hand
them over to the underlying transport.
There is no direct equivalent in McpClient.AsyncSpec. To achieve the same result,
append contextWrite(McpTransportContext.KEY, context) to any
McpAsyncClient call.
contextProvider - A supplier to create a contextpublic McpClient.SyncSpec jsonSchemaValidator(JsonSchemaValidator jsonSchemaValidator)
JsonSchemaValidator to validate the JSON structure of the
structured output.jsonSchemaValidator - A validator to validate the JSON structure of the
structured output. Must not be null.java.lang.IllegalArgumentException - if jsonSchemaValidator is nullpublic McpClient.SyncSpec enableCallToolSchemaCaching(boolean enableCallToolSchemaCaching)
enableCallToolSchemaCaching - true to enable, false to disablepublic McpSyncClient build()
McpSyncClient with the provided configurations or
sensible defaults.McpSyncClient.