@@ -62,6 +62,7 @@ class McpClientFeatures {
6262 * @param progressConsumers the progress consumers.
6363 * @param samplingHandler the sampling handler.
6464 * @param elicitationHandler the elicitation handler.
65+ * @param elicitationCompleteConsumers the elicitation complete consumers.
6566 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
6667 */
6768 record Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
@@ -73,6 +74,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
7374 List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
7475 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
7576 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ,
77+ List <Function <McpSchema .ElicitationCompleteNotification , Mono <Void >>> elicitationCompleteConsumers ,
7678 boolean enableCallToolSchemaCaching ) {
7779
7880 /**
@@ -86,6 +88,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
8688 * @param progressConsumers the progress consumers.
8789 * @param samplingHandler the sampling handler.
8890 * @param elicitationHandler the elicitation handler.
91+ * @param elicitationCompleteConsumers the elicitation complete consumers.
8992 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
9093 */
9194 public Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
@@ -98,6 +101,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
98101 List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
99102 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
100103 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ,
104+ List <Function <McpSchema .ElicitationCompleteNotification , Mono <Void >>> elicitationCompleteConsumers ,
101105 boolean enableCallToolSchemaCaching ) {
102106
103107 Assert .notNull (clientInfo , "Client info must not be null" );
@@ -117,6 +121,8 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
117121 this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
118122 this .samplingHandler = samplingHandler ;
119123 this .elicitationHandler = elicitationHandler ;
124+ this .elicitationCompleteConsumers = elicitationCompleteConsumers != null ? elicitationCompleteConsumers
125+ : List .of ();
120126 this .enableCallToolSchemaCaching = enableCallToolSchemaCaching ;
121127 }
122128
@@ -134,7 +140,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
134140 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
135141 this (clientInfo , clientCapabilities , roots , toolsChangeConsumers , resourcesChangeConsumers ,
136142 resourcesUpdateConsumers , promptsChangeConsumers , loggingConsumers , List .of (), samplingHandler ,
137- elicitationHandler , false );
143+ elicitationHandler , List . of (), false );
138144 }
139145
140146 /**
@@ -182,6 +188,13 @@ public static Async fromSync(Sync syncSpec) {
182188 .subscribeOn (Schedulers .boundedElastic ()));
183189 }
184190
191+ List <Function <McpSchema .ElicitationCompleteNotification , Mono <Void >>> elicitationCompleteConsumers = new ArrayList <>();
192+ for (Consumer <McpSchema .ElicitationCompleteNotification > consumer : syncSpec
193+ .elicitationCompleteConsumers ()) {
194+ elicitationCompleteConsumers .add (n -> Mono .<Void >fromRunnable (() -> consumer .accept (n ))
195+ .subscribeOn (Schedulers .boundedElastic ()));
196+ }
197+
185198 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
186199 .fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
187200 .subscribeOn (Schedulers .boundedElastic ());
@@ -193,7 +206,7 @@ public static Async fromSync(Sync syncSpec) {
193206 return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
194207 toolsChangeConsumers , resourcesChangeConsumers , resourcesUpdateConsumers , promptsChangeConsumers ,
195208 loggingConsumers , progressConsumers , samplingHandler , elicitationHandler ,
196- syncSpec .enableCallToolSchemaCaching );
209+ elicitationCompleteConsumers , syncSpec .enableCallToolSchemaCaching );
197210 }
198211 }
199212
@@ -211,6 +224,7 @@ public static Async fromSync(Sync syncSpec) {
211224 * @param progressConsumers the progress consumers.
212225 * @param samplingHandler the sampling handler.
213226 * @param elicitationHandler the elicitation handler.
227+ * @param elicitationCompleteConsumers the elicitation complete consumers.
214228 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
215229 */
216230 public record Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
@@ -222,6 +236,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
222236 List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
223237 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
224238 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ,
239+ List <Consumer <McpSchema .ElicitationCompleteNotification >> elicitationCompleteConsumers ,
225240 boolean enableCallToolSchemaCaching ) {
226241
227242 /**
@@ -237,6 +252,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
237252 * @param progressConsumers the progress consumers.
238253 * @param samplingHandler the sampling handler.
239254 * @param elicitationHandler the elicitation handler.
255+ * @param elicitationCompleteConsumers the elicitation complete consumers.
240256 * @param enableCallToolSchemaCaching whether to enable call tool schema caching.
241257 */
242258 public Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
@@ -248,6 +264,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
248264 List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
249265 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
250266 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ,
267+ List <Consumer <McpSchema .ElicitationCompleteNotification >> elicitationCompleteConsumers ,
251268 boolean enableCallToolSchemaCaching ) {
252269
253270 Assert .notNull (clientInfo , "Client info must not be null" );
@@ -267,6 +284,8 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
267284 this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
268285 this .samplingHandler = samplingHandler ;
269286 this .elicitationHandler = elicitationHandler ;
287+ this .elicitationCompleteConsumers = elicitationCompleteConsumers != null ? elicitationCompleteConsumers
288+ : List .of ();
270289 this .enableCallToolSchemaCaching = enableCallToolSchemaCaching ;
271290 }
272291
@@ -283,7 +302,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
283302 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
284303 this (clientInfo , clientCapabilities , roots , toolsChangeConsumers , resourcesChangeConsumers ,
285304 resourcesUpdateConsumers , promptsChangeConsumers , loggingConsumers , List .of (), samplingHandler ,
286- elicitationHandler , false );
305+ elicitationHandler , List . of (), false );
287306 }
288307 }
289308
0 commit comments