Class AsyncMcpProgressProvider

java.lang.Object
org.springframework.ai.mcp.annotation.provider.progress.AsyncMcpProgressProvider

public class AsyncMcpProgressProvider extends Object
Provider for asynchronous progress callbacks.

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

Example usage:

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

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

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

    • AsyncMcpProgressProvider

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

    • getProgressSpecifications

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