11/*
2- * Copyright 2024-2024 the original author or authors.
2+ * Copyright 2024-2026 the original author or authors.
33 */
44
55package io .modelcontextprotocol .client ;
@@ -63,6 +63,9 @@ class McpClientFeatures {
6363 * @param samplingHandler the sampling handler.
6464 * @param elicitationHandler the elicitation handler.
6565 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
66+ * @param applyElicitationDefaults whether the client should fill in missing fields of
67+ * an accepted {@code ElicitResult.content} with the {@code default} values declared
68+ * in the {@code requestedSchema}.
6669 */
6770 record Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
6871 Map <String , McpSchema .Root > roots , List <Function <List <McpSchema .Tool >, Mono <Void >>> toolsChangeConsumers ,
@@ -73,7 +76,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
7376 List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
7477 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
7578 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ,
76- boolean enableCallToolSchemaCaching ) {
79+ boolean enableCallToolSchemaCaching , boolean applyElicitationDefaults ) {
7780
7881 /**
7982 * Create an instance and validate the arguments.
@@ -87,6 +90,9 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
8790 * @param samplingHandler the sampling handler.
8891 * @param elicitationHandler the elicitation handler.
8992 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
93+ * @param applyElicitationDefaults whether the client should fill in missing
94+ * fields of an accepted {@code ElicitResult.content} with the {@code default}
95+ * values declared in the {@code requestedSchema}.
9096 */
9197 public Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
9298 Map <String , McpSchema .Root > roots ,
@@ -98,7 +104,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
98104 List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
99105 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
100106 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ,
101- boolean enableCallToolSchemaCaching ) {
107+ boolean enableCallToolSchemaCaching , boolean applyElicitationDefaults ) {
102108
103109 Assert .notNull (clientInfo , "Client info must not be null" );
104110 this .clientInfo = clientInfo ;
@@ -119,6 +125,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
119125 this .samplingHandler = samplingHandler ;
120126 this .elicitationHandler = elicitationHandler ;
121127 this .enableCallToolSchemaCaching = enableCallToolSchemaCaching ;
128+ this .applyElicitationDefaults = applyElicitationDefaults ;
122129 }
123130
124131 /**
@@ -135,7 +142,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
135142 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
136143 this (clientInfo , clientCapabilities , roots , toolsChangeConsumers , resourcesChangeConsumers ,
137144 resourcesUpdateConsumers , promptsChangeConsumers , loggingConsumers , List .of (), samplingHandler ,
138- elicitationHandler , false );
145+ elicitationHandler , false , false );
139146 }
140147
141148 /**
@@ -194,7 +201,7 @@ public static Async fromSync(Sync syncSpec) {
194201 return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
195202 toolsChangeConsumers , resourcesChangeConsumers , resourcesUpdateConsumers , promptsChangeConsumers ,
196203 loggingConsumers , progressConsumers , samplingHandler , elicitationHandler ,
197- syncSpec .enableCallToolSchemaCaching );
204+ syncSpec .enableCallToolSchemaCaching , syncSpec . applyElicitationDefaults );
198205 }
199206 }
200207
@@ -213,6 +220,9 @@ public static Async fromSync(Sync syncSpec) {
213220 * @param samplingHandler the sampling handler.
214221 * @param elicitationHandler the elicitation handler.
215222 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
223+ * @param applyElicitationDefaults whether the client should fill in missing fields of
224+ * an accepted {@code ElicitResult.content} with the {@code default} values declared
225+ * in the {@code requestedSchema}.
216226 */
217227 public record Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
218228 Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
@@ -223,7 +233,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
223233 List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
224234 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
225235 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ,
226- boolean enableCallToolSchemaCaching ) {
236+ boolean enableCallToolSchemaCaching , boolean applyElicitationDefaults ) {
227237
228238 /**
229239 * Create an instance and validate the arguments.
@@ -239,6 +249,9 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
239249 * @param samplingHandler the sampling handler.
240250 * @param elicitationHandler the elicitation handler.
241251 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
252+ * @param applyElicitationDefaults whether the client should fill in missing
253+ * fields of an accepted {@code ElicitResult.content} with the {@code default}
254+ * values declared in the {@code requestedSchema}.
242255 */
243256 public Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
244257 Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
@@ -249,7 +262,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
249262 List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
250263 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
251264 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ,
252- boolean enableCallToolSchemaCaching ) {
265+ boolean enableCallToolSchemaCaching , boolean applyElicitationDefaults ) {
253266
254267 Assert .notNull (clientInfo , "Client info must not be null" );
255268 this .clientInfo = clientInfo ;
@@ -270,6 +283,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
270283 this .samplingHandler = samplingHandler ;
271284 this .elicitationHandler = elicitationHandler ;
272285 this .enableCallToolSchemaCaching = enableCallToolSchemaCaching ;
286+ this .applyElicitationDefaults = applyElicitationDefaults ;
273287 }
274288
275289 /**
@@ -285,7 +299,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
285299 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
286300 this (clientInfo , clientCapabilities , roots , toolsChangeConsumers , resourcesChangeConsumers ,
287301 resourcesUpdateConsumers , promptsChangeConsumers , loggingConsumers , List .of (), samplingHandler ,
288- elicitationHandler , false );
302+ elicitationHandler , false , false );
289303 }
290304 }
291305
0 commit comments