@@ -59,6 +59,7 @@ class McpClientFeatures {
59
59
* @param resourcesChangeConsumers the resources change consumers.
60
60
* @param promptsChangeConsumers the prompts change consumers.
61
61
* @param loggingConsumers the logging consumers.
62
+ * @param progressConsumers the progress consumers.
62
63
* @param samplingHandler the sampling handler.
63
64
* @param elicitationHandler the elicitation handler.
64
65
*/
@@ -67,6 +68,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
67
68
List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
68
69
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
69
70
List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
71
+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
70
72
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
71
73
Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
72
74
@@ -78,6 +80,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
78
80
* @param resourcesChangeConsumers the resources change consumers.
79
81
* @param promptsChangeConsumers the prompts change consumers.
80
82
* @param loggingConsumers the logging consumers.
83
+ * @param progressConsumers the progressconsumers.
81
84
* @param samplingHandler the sampling handler.
82
85
* @param elicitationHandler the elicitation handler.
83
86
*/
@@ -87,6 +90,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
87
90
List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
88
91
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
89
92
List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
93
+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
90
94
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
91
95
Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
92
96
@@ -103,6 +107,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
103
107
this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
104
108
this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
105
109
this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
110
+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
106
111
this .samplingHandler = samplingHandler ;
107
112
this .elicitationHandler = elicitationHandler ;
108
113
}
@@ -141,6 +146,12 @@ public static Async fromSync(Sync syncSpec) {
141
146
.subscribeOn (Schedulers .boundedElastic ()));
142
147
}
143
148
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
+
144
155
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
145
156
.fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
146
157
.subscribeOn (Schedulers .boundedElastic ());
@@ -151,7 +162,7 @@ public static Async fromSync(Sync syncSpec) {
151
162
152
163
return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
153
164
toolsChangeConsumers , resourcesChangeConsumers , promptsChangeConsumers , loggingConsumers ,
154
- samplingHandler , elicitationHandler );
165
+ progressConsumers , samplingHandler , elicitationHandler );
155
166
}
156
167
}
157
168
@@ -166,6 +177,7 @@ public static Async fromSync(Sync syncSpec) {
166
177
* @param resourcesChangeConsumers the resources change consumers.
167
178
* @param promptsChangeConsumers the prompts change consumers.
168
179
* @param loggingConsumers the logging consumers.
180
+ * @param progressConsumers the progress consumers.
169
181
* @param samplingHandler the sampling handler.
170
182
* @param elicitationHandler the elicitation handler.
171
183
*/
@@ -174,6 +186,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
174
186
List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
175
187
List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
176
188
List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
189
+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
177
190
Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
178
191
Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
179
192
@@ -186,6 +199,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
186
199
* @param resourcesChangeConsumers the resources change consumers.
187
200
* @param promptsChangeConsumers the prompts change consumers.
188
201
* @param loggingConsumers the logging consumers.
202
+ * @param progressConsumers the progress consumers.
189
203
* @param samplingHandler the sampling handler.
190
204
* @param elicitationHandler the elicitation handler.
191
205
*/
@@ -194,6 +208,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
194
208
List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
195
209
List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
196
210
List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
211
+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
197
212
Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
198
213
Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
199
214
@@ -210,6 +225,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
210
225
this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
211
226
this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
212
227
this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
228
+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
213
229
this .samplingHandler = samplingHandler ;
214
230
this .elicitationHandler = elicitationHandler ;
215
231
}
0 commit comments