Class AsyncMcpLoggingProvider

java.lang.Object
org.springaicommunity.mcp.provider.logging.AsyncMcpLoggingProvider

public class AsyncMcpLoggingProvider extends Object
Provider for asynchronous logging consumer callbacks.

This class scans a list of objects for methods annotated with McpLogging and creates Function callbacks for them. These callbacks can be used to handle logging message notifications from MCP servers in a reactive way.

Example usage:


 // Create a provider with a list of objects containing @McpLoggingConsumer methods
 AsyncMcpLoggingConsumerProvider provider = new AsyncMcpLoggingConsumerProvider(List.of(loggingHandler));

 // Get the list of logging consumer callbacks
 List<Function<LoggingMessageNotification, Mono<Void>>> consumers = provider.getLoggingConsumers();

 // Add the consumers to the client features
 McpClientFeatures.Async clientFeatures = new McpClientFeatures.Async(
     clientInfo, clientCapabilities, roots,
     toolsChangeConsumers, resourcesChangeConsumers, promptsChangeConsumers,
     consumers, samplingHandler);
 
Author:
Christian Tzolov
See Also:
  • Constructor Details

    • AsyncMcpLoggingProvider

      public AsyncMcpLoggingProvider(List<Object> loggingConsumerObjects)
      Create a new AsyncMcpLoggingConsumerProvider.
      Parameters:
      loggingConsumerObjects - the objects containing methods annotated with McpLogging
  • Method Details

    • getLoggingSpecifications

      public List<AsyncLoggingSpecification> getLoggingSpecifications()
      Get the list of logging consumer callbacks.
      Returns:
      the list of logging consumer callbacks
    • doGetClassMethods

      protected Method[] doGetClassMethods(Object bean)
      Returns the methods of the given bean class.
      Parameters:
      bean - the bean instance
      Returns:
      the methods of the bean class