Class SyncMcpToolListChangedProvider

java.lang.Object
org.springaicommunity.mcp.provider.changed.tool.SyncMcpToolListChangedProvider

public class SyncMcpToolListChangedProvider extends Object
Provider for synchronous tool list changed consumer callbacks.

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

Example usage:


 // Create a provider with a list of objects containing @McpToolListChanged methods
 SyncMcpToolListChangedProvider provider = new SyncMcpToolListChangedProvider(List.of(toolListHandler));

 // Get the list of tool list changed consumer callbacks
 List<SyncToolListChanagedSpecification> specifications = provider.getToolListChangedSpecifications();

 // 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

    • SyncMcpToolListChangedProvider

      public SyncMcpToolListChangedProvider(List<Object> toolListChangedConsumerObjects)
      Create a new SyncMcpToolListChangedProvider.
      Parameters:
      toolListChangedConsumerObjects - the objects containing methods annotated with McpToolListChanged
  • Method Details

    • getToolListChangedSpecifications

      public List<SyncToolListChangedSpecification> getToolListChangedSpecifications()
      Get the list of tool list changed consumer specifications.
      Returns:
      the list of tool 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