@@ -59,6 +59,7 @@ class McpClientFeatures {
5959 * @param resourcesChangeConsumers the resources change consumers.
6060 * @param promptsChangeConsumers the prompts change consumers.
6161 * @param loggingConsumers the logging consumers.
62+ * @param progressConsumers the progress consumers.
6263 * @param samplingHandler the sampling handler.
6364 * @param elicitationHandler the elicitation handler.
6465 */
@@ -67,6 +68,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
6768 List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
6869 List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
6970 List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
71+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
7072 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
7173 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
7274
@@ -78,6 +80,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
7880 * @param resourcesChangeConsumers the resources change consumers.
7981 * @param promptsChangeConsumers the prompts change consumers.
8082 * @param loggingConsumers the logging consumers.
83+ * @param progressConsumers the progressconsumers.
8184 * @param samplingHandler the sampling handler.
8285 * @param elicitationHandler the elicitation handler.
8386 */
@@ -87,6 +90,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
8790 List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
8891 List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
8992 List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
93+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
9094 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
9195 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
9296
@@ -103,6 +107,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
103107 this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
104108 this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
105109 this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
110+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
106111 this .samplingHandler = samplingHandler ;
107112 this .elicitationHandler = elicitationHandler ;
108113 }
@@ -141,6 +146,12 @@ public static Async fromSync(Sync syncSpec) {
141146 .subscribeOn (Schedulers .boundedElastic ()));
142147 }
143148
149+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers = new ArrayList <>();
150+ for (Consumer <McpSchema .ProgressNotification > consumer : syncSpec .progressConsumers ()) {
151+ progressConsumers .add (p -> Mono .<Void >fromRunnable (() -> consumer .accept (p ))
152+ .subscribeOn (Schedulers .boundedElastic ()));
153+ }
154+
144155 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
145156 .fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
146157 .subscribeOn (Schedulers .boundedElastic ());
@@ -151,7 +162,7 @@ public static Async fromSync(Sync syncSpec) {
151162
152163 return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
153164 toolsChangeConsumers , resourcesChangeConsumers , promptsChangeConsumers , loggingConsumers ,
154- samplingHandler , elicitationHandler );
165+ progressConsumers , samplingHandler , elicitationHandler );
155166 }
156167 }
157168
@@ -166,6 +177,7 @@ public static Async fromSync(Sync syncSpec) {
166177 * @param resourcesChangeConsumers the resources change consumers.
167178 * @param promptsChangeConsumers the prompts change consumers.
168179 * @param loggingConsumers the logging consumers.
180+ * @param progressConsumers the progress consumers.
169181 * @param samplingHandler the sampling handler.
170182 * @param elicitationHandler the elicitation handler.
171183 */
@@ -174,6 +186,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
174186 List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
175187 List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
176188 List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
189+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
177190 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
178191 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
179192
@@ -186,6 +199,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
186199 * @param resourcesChangeConsumers the resources change consumers.
187200 * @param promptsChangeConsumers the prompts change consumers.
188201 * @param loggingConsumers the logging consumers.
202+ * @param progressConsumers the progress consumers.
189203 * @param samplingHandler the sampling handler.
190204 * @param elicitationHandler the elicitation handler.
191205 */
@@ -194,6 +208,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
194208 List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
195209 List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
196210 List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
211+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
197212 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
198213 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
199214
@@ -210,6 +225,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
210225 this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
211226 this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
212227 this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
228+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
213229 this .samplingHandler = samplingHandler ;
214230 this .elicitationHandler = elicitationHandler ;
215231 }
0 commit comments