@@ -59,13 +59,15 @@ 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
*/
64
65
record Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
65
66
Map <String , McpSchema .Root > roots , List <Function <List <McpSchema .Tool >, Mono <Void >>> toolsChangeConsumers ,
66
67
List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
67
68
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
68
69
List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
70
+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
69
71
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ) {
70
72
71
73
/**
@@ -76,6 +78,7 @@ record Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
76
78
* @param resourcesChangeConsumers the resources change consumers.
77
79
* @param promptsChangeConsumers the prompts change consumers.
78
80
* @param loggingConsumers the logging consumers.
81
+ * @param progressConsumers the progressconsumers.
79
82
* @param samplingHandler the sampling handler.
80
83
*/
81
84
public Async (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
@@ -84,6 +87,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
84
87
List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ,
85
88
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ,
86
89
List <Function <McpSchema .LoggingMessageNotification , Mono <Void >>> loggingConsumers ,
90
+ List <Function <McpSchema .ProgressNotification , Mono <Void >>> progressConsumers ,
87
91
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler ) {
88
92
89
93
Assert .notNull (clientInfo , "Client info must not be null" );
@@ -98,6 +102,7 @@ public Async(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities c
98
102
this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
99
103
this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
100
104
this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
105
+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
101
106
this .samplingHandler = samplingHandler ;
102
107
}
103
108
@@ -135,12 +140,18 @@ public static Async fromSync(Sync syncSpec) {
135
140
.subscribeOn (Schedulers .boundedElastic ()));
136
141
}
137
142
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
+
138
149
Function <McpSchema .CreateMessageRequest , Mono <McpSchema .CreateMessageResult >> samplingHandler = r -> Mono
139
150
.fromCallable (() -> syncSpec .samplingHandler ().apply (r ))
140
151
.subscribeOn (Schedulers .boundedElastic ());
141
152
return new Async (syncSpec .clientInfo (), syncSpec .clientCapabilities (), syncSpec .roots (),
142
153
toolsChangeConsumers , resourcesChangeConsumers , promptsChangeConsumers , loggingConsumers ,
143
- samplingHandler );
154
+ progressConsumers , samplingHandler );
144
155
}
145
156
}
146
157
@@ -155,13 +166,15 @@ public static Async fromSync(Sync syncSpec) {
155
166
* @param resourcesChangeConsumers the resources change consumers.
156
167
* @param promptsChangeConsumers the prompts change consumers.
157
168
* @param loggingConsumers the logging consumers.
169
+ * @param progressConsumers the progress consumers.
158
170
* @param samplingHandler the sampling handler.
159
171
*/
160
172
public record Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
161
173
Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
162
174
List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
163
175
List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
164
176
List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
177
+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
165
178
Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ) {
166
179
167
180
/**
@@ -173,13 +186,15 @@ public record Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabili
173
186
* @param resourcesChangeConsumers the resources change consumers.
174
187
* @param promptsChangeConsumers the prompts change consumers.
175
188
* @param loggingConsumers the logging consumers.
189
+ * @param progressConsumers the progress consumers.
176
190
* @param samplingHandler the sampling handler.
177
191
*/
178
192
public Sync (McpSchema .Implementation clientInfo , McpSchema .ClientCapabilities clientCapabilities ,
179
193
Map <String , McpSchema .Root > roots , List <Consumer <List <McpSchema .Tool >>> toolsChangeConsumers ,
180
194
List <Consumer <List <McpSchema .Resource >>> resourcesChangeConsumers ,
181
195
List <Consumer <List <McpSchema .Prompt >>> promptsChangeConsumers ,
182
196
List <Consumer <McpSchema .LoggingMessageNotification >> loggingConsumers ,
197
+ List <Consumer <McpSchema .ProgressNotification >> progressConsumers ,
183
198
Function <McpSchema .CreateMessageRequest , McpSchema .CreateMessageResult > samplingHandler ) {
184
199
185
200
Assert .notNull (clientInfo , "Client info must not be null" );
@@ -194,6 +209,7 @@ public Sync(McpSchema.Implementation clientInfo, McpSchema.ClientCapabilities cl
194
209
this .resourcesChangeConsumers = resourcesChangeConsumers != null ? resourcesChangeConsumers : List .of ();
195
210
this .promptsChangeConsumers = promptsChangeConsumers != null ? promptsChangeConsumers : List .of ();
196
211
this .loggingConsumers = loggingConsumers != null ? loggingConsumers : List .of ();
212
+ this .progressConsumers = progressConsumers != null ? progressConsumers : List .of ();
197
213
this .samplingHandler = samplingHandler ;
198
214
}
199
215
}
0 commit comments