Class SyncMcpResourceListChangedProvider

java.lang.Object
org.springaicommunity.mcp.provider.changed.resource.SyncMcpResourceListChangedProvider

public class SyncMcpResourceListChangedProvider extends Object
Provider for synchronous resource list changed consumer callbacks.

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

Example usage:


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

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

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

    • SyncMcpResourceListChangedProvider

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

    • getResourceListChangedSpecifications

      public List<SyncResourceListChangedSpecification> 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