@@ -154,7 +154,7 @@ public class McpAsyncClient {
154
154
* @param features the MCP Client supported features.
155
155
*/
156
156
McpAsyncClient (McpClientTransport transport , Duration requestTimeout , Duration initializationTimeout ,
157
- McpClientFeatures .Async features ) {
157
+ McpClientFeatures .Async features ) {
158
158
159
159
Assert .notNull (transport , "Transport must not be null" );
160
160
Assert .notNull (requestTimeout , "Request timeout must not be null" );
@@ -189,7 +189,7 @@ public class McpAsyncClient {
189
189
// Tools Change Notification
190
190
List <Function <List <McpSchema .Tool >, Mono <Void >>> toolsChangeConsumersFinal = new ArrayList <>();
191
191
toolsChangeConsumersFinal
192
- .add ((notification ) -> Mono .fromRunnable (() -> logger .debug ("Tools changed: {}" , notification )));
192
+ .add ((notification ) -> Mono .fromRunnable (() -> logger .debug ("Tools changed: {}" , notification )));
193
193
194
194
if (!Utils .isEmpty (features .toolsChangeConsumers ())) {
195
195
toolsChangeConsumersFinal .addAll (features .toolsChangeConsumers ());
@@ -200,7 +200,7 @@ public class McpAsyncClient {
200
200
// Resources Change Notification
201
201
List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumersFinal = new ArrayList <>();
202
202
resourcesChangeConsumersFinal
203
- .add ((notification ) -> Mono .fromRunnable (() -> logger .debug ("Resources changed: {}" , notification )));
203
+ .add ((notification ) -> Mono .fromRunnable (() -> logger .debug ("Resources changed: {}" , notification )));
204
204
205
205
if (!Utils .isEmpty (features .resourcesChangeConsumers ())) {
206
206
resourcesChangeConsumersFinal .addAll (features .resourcesChangeConsumers ());
@@ -212,7 +212,7 @@ public class McpAsyncClient {
212
212
// Prompts Change Notification
213
213
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumersFinal = new ArrayList <>();
214
214
promptsChangeConsumersFinal
215
- .add ((notification ) -> Mono .fromRunnable (() -> logger .debug ("Prompts changed: {}" , notification )));
215
+ .add ((notification ) -> Mono .fromRunnable (() -> logger .debug ("Prompts changed: {}" , notification )));
216
216
if (!Utils .isEmpty (features .promptsChangeConsumers ())) {
217
217
promptsChangeConsumersFinal .addAll (features .promptsChangeConsumers ());
218
218
}
@@ -355,12 +355,12 @@ public Mono<McpSchema.InitializeResult> initialize() {
355
355
* @return A Mono that completes with the result of the operation
356
356
*/
357
357
private <T > Mono <T > withInitializationCheck (String actionName ,
358
- Function <McpSchema .InitializeResult , Mono <T >> operation ) {
358
+ Function <McpSchema .InitializeResult , Mono <T >> operation ) {
359
359
return this .initializedSink .asMono ()
360
- .timeout (this .initializationTimeout )
361
- .onErrorResume (TimeoutException .class ,
362
- ex -> Mono .error (new McpError ("Client must be initialized before " + actionName )))
363
- .flatMap (operation );
360
+ .timeout (this .initializationTimeout )
361
+ .onErrorResume (TimeoutException .class ,
362
+ ex -> Mono .error (new McpError ("Client must be initialized before " + actionName )))
363
+ .flatMap (operation );
364
364
}
365
365
366
366
// --------------------------
@@ -373,8 +373,8 @@ private <T> Mono<T> withInitializationCheck(String actionName,
373
373
*/
374
374
public Mono <Object > ping () {
375
375
return this .withInitializationCheck ("pinging the server" , initializedResult -> this .mcpSession
376
- .sendRequest (McpSchema .METHOD_PING , null , new TypeReference <Object >() {
377
- }));
376
+ .sendRequest (McpSchema .METHOD_PING , null , new TypeReference <Object >() {
377
+ }));
378
378
}
379
379
380
380
// --------------------------
@@ -540,13 +540,13 @@ private NotificationHandler asyncToolsChangeNotificationHandler(
540
540
List <Function <List <McpSchema .Tool >, Mono <Void >>> toolsChangeConsumers ) {
541
541
// TODO: params are not used yet
542
542
return params -> this .listTools ()
543
- .flatMap (listToolsResult -> Flux .fromIterable (toolsChangeConsumers )
544
- .flatMap (consumer -> consumer .apply (listToolsResult .tools ()))
545
- .onErrorResume (error -> {
546
- logger .error ("Error handling tools list change notification" , error );
547
- return Mono .empty ();
548
- })
549
- .then ());
543
+ .flatMap (listToolsResult -> Flux .fromIterable (toolsChangeConsumers )
544
+ .flatMap (consumer -> consumer .apply (listToolsResult .tools ()))
545
+ .onErrorResume (error -> {
546
+ logger .error ("Error handling tools list change notification" , error );
547
+ return Mono .empty ();
548
+ })
549
+ .then ());
550
550
}
551
551
552
552
// --------------------------
@@ -664,7 +664,7 @@ public Mono<McpSchema.ListResourceTemplatesResult> listResourceTemplates(String
664
664
*/
665
665
public Mono <Void > subscribeResource (McpSchema .SubscribeRequest subscribeRequest ) {
666
666
return this .withInitializationCheck ("subscribing to resources" , initializedResult -> this .mcpSession
667
- .sendRequest (McpSchema .METHOD_RESOURCES_SUBSCRIBE , subscribeRequest , VOID_TYPE_REFERENCE ));
667
+ .sendRequest (McpSchema .METHOD_RESOURCES_SUBSCRIBE , subscribeRequest , VOID_TYPE_REFERENCE ));
668
668
}
669
669
670
670
/**
@@ -678,18 +678,18 @@ public Mono<Void> subscribeResource(McpSchema.SubscribeRequest subscribeRequest)
678
678
*/
679
679
public Mono <Void > unsubscribeResource (McpSchema .UnsubscribeRequest unsubscribeRequest ) {
680
680
return this .withInitializationCheck ("unsubscribing from resources" , initializedResult -> this .mcpSession
681
- .sendRequest (McpSchema .METHOD_RESOURCES_UNSUBSCRIBE , unsubscribeRequest , VOID_TYPE_REFERENCE ));
681
+ .sendRequest (McpSchema .METHOD_RESOURCES_UNSUBSCRIBE , unsubscribeRequest , VOID_TYPE_REFERENCE ));
682
682
}
683
683
684
684
private NotificationHandler asyncResourcesChangeNotificationHandler (
685
685
List <Function <List <McpSchema .Resource >, Mono <Void >>> resourcesChangeConsumers ) {
686
686
return params -> listResources ().flatMap (listResourcesResult -> Flux .fromIterable (resourcesChangeConsumers )
687
- .flatMap (consumer -> consumer .apply (listResourcesResult .resources ()))
688
- .onErrorResume (error -> {
689
- logger .error ("Error handling resources list change notification" , error );
690
- return Mono .empty ();
691
- })
692
- .then ());
687
+ .flatMap (consumer -> consumer .apply (listResourcesResult .resources ()))
688
+ .onErrorResume (error -> {
689
+ logger .error ("Error handling resources list change notification" , error );
690
+ return Mono .empty ();
691
+ })
692
+ .then ());
693
693
}
694
694
695
695
// --------------------------
@@ -720,7 +720,7 @@ public Mono<ListPromptsResult> listPrompts() {
720
720
*/
721
721
public Mono <ListPromptsResult > listPrompts (String cursor ) {
722
722
return this .withInitializationCheck ("listing prompts" , initializedResult -> this .mcpSession
723
- .sendRequest (McpSchema .METHOD_PROMPT_LIST , new PaginatedRequest (cursor ), LIST_PROMPTS_RESULT_TYPE_REF ));
723
+ .sendRequest (McpSchema .METHOD_PROMPT_LIST , new PaginatedRequest (cursor ), LIST_PROMPTS_RESULT_TYPE_REF ));
724
724
}
725
725
726
726
/**
@@ -734,18 +734,18 @@ public Mono<ListPromptsResult> listPrompts(String cursor) {
734
734
*/
735
735
public Mono <GetPromptResult > getPrompt (GetPromptRequest getPromptRequest ) {
736
736
return this .withInitializationCheck ("getting prompts" , initializedResult -> this .mcpSession
737
- .sendRequest (McpSchema .METHOD_PROMPT_GET , getPromptRequest , GET_PROMPT_RESULT_TYPE_REF ));
737
+ .sendRequest (McpSchema .METHOD_PROMPT_GET , getPromptRequest , GET_PROMPT_RESULT_TYPE_REF ));
738
738
}
739
739
740
740
private NotificationHandler asyncPromptsChangeNotificationHandler (
741
741
List <Function <List <McpSchema .Prompt >, Mono <Void >>> promptsChangeConsumers ) {
742
742
return params -> listPrompts ().flatMap (listPromptsResult -> Flux .fromIterable (promptsChangeConsumers )
743
- .flatMap (consumer -> consumer .apply (listPromptsResult .prompts ()))
744
- .onErrorResume (error -> {
745
- logger .error ("Error handling prompts list change notification" , error );
746
- return Mono .empty ();
747
- })
748
- .then ());
743
+ .flatMap (consumer -> consumer .apply (listPromptsResult .prompts ()))
744
+ .onErrorResume (error -> {
745
+ logger .error ("Error handling prompts list change notification" , error );
746
+ return Mono .empty ();
747
+ })
748
+ .then ());
749
749
}
750
750
751
751
// --------------------------
@@ -768,8 +768,8 @@ private NotificationHandler asyncLoggingNotificationHandler(
768
768
});
769
769
770
770
return Flux .fromIterable (loggingConsumers )
771
- .flatMap (consumer -> consumer .apply (loggingMessageNotification ))
772
- .then ();
771
+ .flatMap (consumer -> consumer .apply (loggingMessageNotification ))
772
+ .then ();
773
773
};
774
774
}
775
775
@@ -801,4 +801,4 @@ void setProtocolVersions(List<String> protocolVersions) {
801
801
this .protocolVersions = protocolVersions ;
802
802
}
803
803
804
- }
804
+ }
0 commit comments