Class SyncMcpPromptListChangedProvider

java.lang.Object
org.springaicommunity.mcp.provider.changed.prompt.SyncMcpPromptListChangedProvider

public class SyncMcpPromptListChangedProvider extends Object
Provider for synchronous prompt list changed consumer callbacks.

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

Example usage:


 // Create a provider with a list of objects containing @McpPromptListChanged methods
 SyncMcpPromptListChangedProvider provider = new SyncMcpPromptListChangedProvider(List.of(promptListHandler));

 // Get the list of prompt list changed consumer callbacks
 List<SyncPromptListChangedSpecification> specifications = provider.getPromptListChangedSpecifications();

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

    • SyncMcpPromptListChangedProvider

      public SyncMcpPromptListChangedProvider(List<Object> promptListChangedConsumerObjects)
      Create a new SyncMcpPromptListChangedProvider.
      Parameters:
      promptListChangedConsumerObjects - the objects containing methods annotated with McpPromptListChanged
  • Method Details

    • getPromptListChangedSpecifications

      public List<SyncPromptListChangedSpecification> getPromptListChangedSpecifications()
      Get the list of prompt list changed consumer specifications.
      Returns:
      the list of prompt 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