Class SyncMcpProgressProvider

java.lang.Object
org.springaicommunity.mcp.provider.progress.SyncMcpProgressProvider

public class SyncMcpProgressProvider extends Object
Provider for synchronous progress callbacks.

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

Example usage:


 // Create a provider with a list of objects containing @McpProgress methods
 SyncMcpProgressProvider provider = new SyncMcpProgressProvider(List.of(progressHandler));

 // Get the list of progress callbacks
 List<SyncProgressSpecification> progressSpecs = provider.getProgressSpecifications();

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

    • SyncMcpProgressProvider

      public SyncMcpProgressProvider(List<Object> progressObjects)
      Create a new SyncMcpProgressProvider.
      Parameters:
      progressObjects - the objects containing methods annotated with McpProgress
  • Method Details

    • getProgressSpecifications

      public List<SyncProgressSpecification> getProgressSpecifications()
      Get the list of progress specifications.
      Returns:
      the list of progress 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