Class AsyncMcpResourceListChangedProvider

java.lang.Object
org.springframework.ai.mcp.annotation.provider.changed.resource.AsyncMcpResourceListChangedProvider

public class AsyncMcpResourceListChangedProvider extends Object
Provider for asynchronous resource list changed consumer callbacks.

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

Example usage:

// Create a provider with a list of objects containing @McpResourceListChanged methods
AsyncMcpResourceListChangedProvider provider = new AsyncMcpResourceListChangedProvider(List.of(resourceListHandler));

// Get the list of resource list changed consumer callbacks
List<AsyncResourceListChangedSpecification> specifications = provider.getResourceListChangedSpecifications();

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

    • AsyncMcpResourceListChangedProvider

      public AsyncMcpResourceListChangedProvider(List<Object> resourceListChangedConsumerObjects)
      Create a new AsyncMcpResourceListChangedProvider.
      Parameters:
      resourceListChangedConsumerObjects - the objects containing methods annotated with McpResourceListChanged
  • Method Details

    • getResourceListChangedSpecifications

      public List<AsyncResourceListChangedSpecification> getResourceListChangedSpecifications()
      Get the list of resource list changed consumer specifications.
      Returns:
      the list of resource list changed consumer specifications
    • 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