@@ -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
*/
@@ -68,6 +69,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
68
69
List <Function <List <McpSchema .ResourceContents >, Mono <Void >>> resourcesUpdateConsumers ,
69
70
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
70
71
List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
72
+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
71
73
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
72
74
Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
73
75
@@ -79,6 +81,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
79
81
* @param resourcesChangeConsumers the resources change consumers.
80
82
* @param promptsChangeConsumers the prompts change consumers.
81
83
* @param loggingConsumers the logging consumers.
84
+ * @param progressConsumers the progressconsumers.
82
85
* @param samplingHandler the sampling handler.
83
86
* @param elicitationHandler the elicitation handler.
84
87
*/
@@ -89,6 +92,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
89
92
List <Function <List <McpSchema .ResourceContents >, Mono <Void >>> resourcesUpdateConsumers ,
90
93
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
91
94
List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
95
+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
92
96
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ,
93
97
Function <McpSchema .ElicitRequest , Mono <McpSchema .ElicitResult >> elicitationHandler ) {
94
98
@@ -106,6 +110,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
106
110
this .resourcesUpdateConsumers = resourcesUpdateConsumers != null ? resourcesUpdateConsumers : List .of ();
107
111
this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
108
112
this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
113
+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
109
114
this .samplingHandler = samplingHandler ;
110
115
this .elicitationHandler = elicitationHandler ;
111
116
}
@@ -149,6 +154,12 @@ public static Async fromSync(Sync syncSpec) {
149
154
.subscribeOn (Schedulers .boundedElastic ()));
150
155
}
151
156
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
+
152
163
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
153
164
.fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
154
165
.subscribeOn (Schedulers .boundedElastic ());
@@ -159,7 +170,7 @@ public static Async fromSync(Sync syncSpec) {
159
170
160
171
return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
161
172
toolsChangeConsumers , resourcesChangeConsumers , resourcesUpdateConsumers , promptsChangeConsumers ,
162
- loggingConsumers , samplingHandler , elicitationHandler );
173
+ loggingConsumers , progressConsumers , samplingHandler , elicitationHandler );
163
174
}
164
175
}
165
176
@@ -174,6 +185,7 @@ public static Async fromSync(Sync syncSpec) {
174
185
* @param resourcesChangeConsumers the resources change consumers.
175
186
* @param promptsChangeConsumers the prompts change consumers.
176
187
* @param loggingConsumers the logging consumers.
188
+ * @param progressConsumers the progress consumers.
177
189
* @param samplingHandler the sampling handler.
178
190
* @param elicitationHandler the elicitation handler.
179
191
*/
@@ -183,6 +195,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
183
195
List <Consumer <List <McpSchema .ResourceContents >>> resourcesUpdateConsumers ,
184
196
List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
185
197
List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
198
+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
186
199
Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
187
200
Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
188
201
@@ -196,6 +209,7 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
196
209
* @param resourcesUpdateConsumers the resource update consumers.
197
210
* @param promptsChangeConsumers the prompts change consumers.
198
211
* @param loggingConsumers the logging consumers.
212
+ * @param progressConsumers the progress consumers.
199
213
* @param samplingHandler the sampling handler.
200
214
* @param elicitationHandler the elicitation handler.
201
215
*/
@@ -205,6 +219,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
205
219
List <Consumer <List <McpSchema .ResourceContents >>> resourcesUpdateConsumers ,
206
220
List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
207
221
List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
222
+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
208
223
Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ,
209
224
Function <McpSchema .ElicitRequest , McpSchema .ElicitResult > elicitationHandler ) {
210
225
@@ -222,6 +237,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
222
237
this .resourcesUpdateConsumers = resourcesUpdateConsumers != null ? resourcesUpdateConsumers : List .of ();
223
238
this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
224
239
this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
240
+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
225
241
this .samplingHandler = samplingHandler ;
226
242
this .elicitationHandler = elicitationHandler ;
227
243
}
0 commit comments