@@ -59,13 +59,15 @@ 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 */
6465 record Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
6566 Map <String , McpSchema .Root > roots , List <Function <List <McpSchema .Tool >, Mono <Void >>> toolsChangeConsumers ,
6667 List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
6768 List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
6869 List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
70+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
6971 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ) {
7072
7173 /**
@@ -76,6 +78,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
7678 * @param resourcesChangeConsumers the resources change consumers.
7779 * @param promptsChangeConsumers the prompts change consumers.
7880 * @param loggingConsumers the logging consumers.
81+ * @param progressConsumers the progressconsumers.
7982 * @param samplingHandler the sampling handler.
8083 */
8184 public Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
@@ -84,6 +87,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
8487 List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
8588 List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
8689 List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
90+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
8791 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ) {
8892
8993 Assert .notNull (clientInfo , "Client info must not be null" );
@@ -98,6 +102,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
98102 this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
99103 this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
100104 this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
105+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
101106 this .samplingHandler = samplingHandler ;
102107 }
103108
@@ -135,12 +140,18 @@ public static Async fromSync(Sync syncSpec) {
135140 .subscribeOn (Schedulers .boundedElastic ()));
136141 }
137142
143+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers = new ArrayList <>();
144+ for (Consumer <McpSchema .ProgressNotification > consumer : syncSpec .progressConsumers ()) {
145+ progressConsumers .add (p -> Mono .<Void >fromRunnable (() -> consumer .accept (p ))
146+ .subscribeOn (Schedulers .boundedElastic ()));
147+ }
148+
138149 Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
139150 .fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
140151 .subscribeOn (Schedulers .boundedElastic ());
141152 return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
142153 toolsChangeConsumers , resourcesChangeConsumers , promptsChangeConsumers , loggingConsumers ,
143- samplingHandler );
154+ progressConsumers , samplingHandler );
144155 }
145156 }
146157
@@ -155,13 +166,15 @@ public static Async fromSync(Sync syncSpec) {
155166 * @param resourcesChangeConsumers the resources change consumers.
156167 * @param promptsChangeConsumers the prompts change consumers.
157168 * @param loggingConsumers the logging consumers.
169+ * @param progressConsumers the progress consumers.
158170 * @param samplingHandler the sampling handler.
159171 */
160172 public record Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
161173 Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
162174 List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
163175 List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
164176 List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
177+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
165178 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ) {
166179
167180 /**
@@ -173,13 +186,15 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
173186 * @param resourcesChangeConsumers the resources change consumers.
174187 * @param promptsChangeConsumers the prompts change consumers.
175188 * @param loggingConsumers the logging consumers.
189+ * @param progressConsumers the progress consumers.
176190 * @param samplingHandler the sampling handler.
177191 */
178192 public Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
179193 Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
180194 List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
181195 List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
182196 List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
197+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
183198 Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ) {
184199
185200 Assert .notNull (clientInfo , "Client info must not be null" );
@@ -194,6 +209,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
194209 this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
195210 this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
196211 this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
212+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
197213 this .samplingHandler = samplingHandler ;
198214 }
199215 }
0 commit comments