@@ -63,6 +63,8 @@ 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 elicitationCompleteConsumers the elicitation complete notification
67+ * consumers.
6668 */
6769 record Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
6870 Map <String , McpSchema .Root > roots , List <Function <List <McpSchema .Tool >, Mono <Void >>> toolsChangeConsumers ,
@@ -73,7 +75,8 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
7375 List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
7476 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
7577 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ,
76- boolean enableCallToolSchemaCaching ) {
78+ boolean enableCallToolSchemaCaching ,
79+ List <Function <McpSchema .ElicitationCompleteNotification , Mono <Void >>> elicitationCompleteConsumers ) {
7780
7881 /**
7982 * Create an instance and validate the arguments.
@@ -87,6 +90,8 @@ 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 elicitationCompleteConsumers the elicitation complete notification
94+ * consumers.
9095 */
9196 public Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
9297 Map <String , McpSchema .Root > roots ,
@@ -98,7 +103,8 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
98103 List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
99104 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
100105 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ,
101- boolean enableCallToolSchemaCaching ) {
106+ boolean enableCallToolSchemaCaching ,
107+ List <Function <McpSchema .ElicitationCompleteNotification , Mono <Void >>> elicitationCompleteConsumers ) {
102108
103109 Assert .notNull (clientInfo , "Client info must not be null" );
104110 this .clientInfo = clientInfo ;
@@ -119,6 +125,8 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
119125 this .samplingHandler = samplingHandler ;
120126 this .elicitationHandler = elicitationHandler ;
121127 this .enableCallToolSchemaCaching = enableCallToolSchemaCaching ;
128+ this .elicitationCompleteConsumers = elicitationCompleteConsumers != null ? elicitationCompleteConsumers
129+ : List .of ();
122130 }
123131
124132 /**
@@ -135,7 +143,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
135143 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
136144 this (clientInfo , clientCapabilities , roots , toolsChangeConsumers , resourcesChangeConsumers ,
137145 resourcesUpdateConsumers , promptsChangeConsumers , loggingConsumers , List .of (), samplingHandler ,
138- elicitationHandler , false );
146+ elicitationHandler , false , List . of () );
139147 }
140148
141149 /**
@@ -191,10 +199,17 @@ public static Async fromSync(Sync syncSpec) {
191199 .fromCallable (() -> syncSpec .elicitationHandler ().apply (r ))
192200 .subscribeOn (Schedulers .boundedElastic ());
193201
202+ List <Function <McpSchema .ElicitationCompleteNotification , Mono <Void >>> elicitationCompleteConsumers = new ArrayList <>();
203+ for (Consumer <McpSchema .ElicitationCompleteNotification > consumer : syncSpec
204+ .elicitationCompleteConsumers ()) {
205+ elicitationCompleteConsumers .add (n -> Mono .<Void >fromRunnable (() -> consumer .accept (n ))
206+ .subscribeOn (Schedulers .boundedElastic ()));
207+ }
208+
194209 return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
195210 toolsChangeConsumers , resourcesChangeConsumers , resourcesUpdateConsumers , promptsChangeConsumers ,
196211 loggingConsumers , progressConsumers , samplingHandler , elicitationHandler ,
197- syncSpec .enableCallToolSchemaCaching );
212+ syncSpec .enableCallToolSchemaCaching (), elicitationCompleteConsumers );
198213 }
199214 }
200215
@@ -213,6 +228,8 @@ public static Async fromSync(Sync syncSpec) {
213228 * @param samplingHandler the sampling handler.
214229 * @param elicitationHandler the elicitation handler.
215230 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
231+ * @param elicitationCompleteConsumers the elicitation complete notification
232+ * consumers.
216233 */
217234 public record Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
218235 Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
@@ -223,7 +240,8 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
223240 List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
224241 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
225242 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ,
226- boolean enableCallToolSchemaCaching ) {
243+ boolean enableCallToolSchemaCaching ,
244+ List <Consumer <McpSchema .ElicitationCompleteNotification >> elicitationCompleteConsumers ) {
227245
228246 /**
229247 * Create an instance and validate the arguments.
@@ -239,6 +257,8 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
239257 * @param samplingHandler the sampling handler.
240258 * @param elicitationHandler the elicitation handler.
241259 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
260+ * @param elicitationCompleteConsumers the elicitation complete notification
261+ * consumers.
242262 */
243263 public Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
244264 Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
@@ -249,7 +269,8 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
249269 List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
250270 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
251271 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ,
252- boolean enableCallToolSchemaCaching ) {
272+ boolean enableCallToolSchemaCaching ,
273+ List <Consumer <McpSchema .ElicitationCompleteNotification >> elicitationCompleteConsumers ) {
253274
254275 Assert .notNull (clientInfo , "Client info must not be null" );
255276 this .clientInfo = clientInfo ;
@@ -270,6 +291,8 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
270291 this .samplingHandler = samplingHandler ;
271292 this .elicitationHandler = elicitationHandler ;
272293 this .enableCallToolSchemaCaching = enableCallToolSchemaCaching ;
294+ this .elicitationCompleteConsumers = elicitationCompleteConsumers != null ? elicitationCompleteConsumers
295+ : List .of ();
273296 }
274297
275298 /**
@@ -285,7 +308,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
285308 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
286309 this (clientInfo , clientCapabilities , roots , toolsChangeConsumers , resourcesChangeConsumers ,
287310 resourcesUpdateConsumers , promptsChangeConsumers , loggingConsumers , List .of (), samplingHandler ,
288- elicitationHandler , false );
311+ elicitationHandler , false , List . of () );
289312 }
290313 }
291314
0 commit comments