@@ -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 */
@@ -68,6 +69,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
6869 List <Function <List <McpSchema .ResourceContents >, Mono <Void >>> resourcesUpdateConsumers ,
6970 List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
7071 List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
72+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
7173 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
7274 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
7375
@@ -79,6 +81,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
7981 * @param resourcesChangeConsumers the resources change consumers.
8082 * @param promptsChangeConsumers the prompts change consumers.
8183 * @param loggingConsumers the logging consumers.
84+ * @param progressConsumers the progressconsumers.
8285 * @param samplingHandler the sampling handler.
8386 * @param elicitationHandler the elicitation handler.
8487 */
@@ -89,6 +92,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
8992 List <Function <List <McpSchema .ResourceContents >, Mono <Void >>> resourcesUpdateConsumers ,
9093 List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
9194 List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
95+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
9296 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
9397 Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
9498
@@ -106,6 +110,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
106110 this .resourcesUpdateConsumers = resourcesUpdateConsumers != null ? resourcesUpdateConsumers : List .of ();
107111 this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
108112 this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
113+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
109114 this .samplingHandler = samplingHandler ;
110115 this .elicitationHandler = elicitationHandler ;
111116 }
@@ -149,6 +154,12 @@ public static Async fromSync(Sync syncSpec) {
149154 .subscribeOn (Schedulers .boundedElastic ()));
150155 }
151156
157+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers = new ArrayList <>();
158+ for (Consumer <McpSchema .ProgressNotification > consumer : syncSpec .progressConsumers ()) {
159+ progressConsumers .add (p -> Mono .<Void >fromRunnable (() -> consumer .accept (p ))
160+ .subscribeOn (Schedulers .boundedElastic ()));
161+ }
162+
152163 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
153164 .fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
154165 .subscribeOn (Schedulers .boundedElastic ());
@@ -159,7 +170,7 @@ public static Async fromSync(Sync syncSpec) {
159170
160171 return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
161172 toolsChangeConsumers , resourcesChangeConsumers , resourcesUpdateConsumers , promptsChangeConsumers ,
162- loggingConsumers , samplingHandler , elicitationHandler );
173+ loggingConsumers , progressConsumers , samplingHandler , elicitationHandler );
163174 }
164175 }
165176
@@ -174,6 +185,7 @@ public static Async fromSync(Sync syncSpec) {
174185 * @param resourcesChangeConsumers the resources change consumers.
175186 * @param promptsChangeConsumers the prompts change consumers.
176187 * @param loggingConsumers the logging consumers.
188+ * @param progressConsumers the progress consumers.
177189 * @param samplingHandler the sampling handler.
178190 * @param elicitationHandler the elicitation handler.
179191 */
@@ -183,6 +195,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
183195 List <Consumer <List <McpSchema .ResourceContents >>> resourcesUpdateConsumers ,
184196 List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
185197 List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
198+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
186199 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
187200 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
188201
@@ -196,6 +209,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
196209 * @param resourcesUpdateConsumers the resource update consumers.
197210 * @param promptsChangeConsumers the prompts change consumers.
198211 * @param loggingConsumers the logging consumers.
212+ * @param progressConsumers the progress consumers.
199213 * @param samplingHandler the sampling handler.
200214 * @param elicitationHandler the elicitation handler.
201215 */
@@ -205,6 +219,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
205219 List <Consumer <List <McpSchema .ResourceContents >>> resourcesUpdateConsumers ,
206220 List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
207221 List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
222+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
208223 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
209224 Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
210225
@@ -222,6 +237,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
222237 this .resourcesUpdateConsumers = resourcesUpdateConsumers != null ? resourcesUpdateConsumers : List .of ();
223238 this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
224239 this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
240+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
225241 this .samplingHandler = samplingHandler ;
226242 this .elicitationHandler = elicitationHandler ;
227243 }
0 commit comments