Class QuiteMcpClientAutoConfiguration

  • All Implemented Interfaces:

    @AutoConfiguration(afterName = {""org.springframework.ai.mcp.client.common.autoconfigure.StdioTransportAutoConfiguration"", ""org.springframework.ai.mcp.client.httpclient.autoconfigure.SseHttpClientTransportAutoConfiguration"", ""org.springframework.ai.mcp.client.httpclient.autoconfigure.StreamableHttpHttpClientTransportAutoConfiguration"", ""org.springframework.ai.mcp.client.webflux.autoconfigure.SseWebFluxTransportAutoConfiguration"", ""org.springframework.ai.mcp.client.webflux.autoconfigure.StreamableHttpWebFluxTransportAutoConfiguration""})@ConditionalOnClass(value = McpSchema.class)@EnableConfigurationProperties(value = McpClientCommonProperties.class)@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true) 
    public class QuiteMcpClientAutoConfiguration
    extends McpClientAutoConfiguration
                        

    Enhanced auto-configuration for Model Context Protocol (MCP) client support.

    This configuration extends Spring AI's McpClientAutoConfiguration with additional resilience handling to prevent runtime exceptions during MCP client initialization from disrupting the Agent Platform startup. Failed client initializations are logged but do not prevent the application from starting successfully.

    Key differences from base Spring AI configuration:

    • Exception Resilience: Wraps client initialization in try-catch blocks to handle failures gracefully
    • Startup Protection: Prevents MCP client failures from blocking Agent Platform startup
    • Error Logging: Failed initializations are logged with client names for troubleshooting
    • Partial Success: Successfully initialized clients are added to the context even if others fail

    Configuration Properties:

    • spring.ai.mcp.client.enabled - Enable/disable MCP client support (default: true)
    • spring.ai.mcp.client.type - Client type: SYNC or ASYNC (default: SYNC)
    • spring.ai.mcp.client.name - Client implementation name
    • spring.ai.mcp.client.version - Client implementation version
    • spring.ai.mcp.client.request-timeout - Request timeout duration
    • spring.ai.mcp.client.initialized - Whether to initialize clients on creation

    The configuration is activated after the transport-specific auto-configurations (Stdio, SSE HTTP, and SSE WebFlux) to ensure proper initialization order. At least one transport must be available for the clients to be created.

    Key features:

    • Synchronous and Asynchronous Client Support:
      • Creates and configures MCP clients based on available transports
      • Supports both blocking (sync) and non-blocking (async) operations
      • Automatic client initialization with failure resilience
    • Integration Support:
      • Sets up tool callbacks for Spring AI integration
      • Supports multiple named transports
      • Proper lifecycle management with automatic cleanup
    • Customization Options:
      • Extensible through McpSyncClientCustomizer and McpAsyncClientCustomizer
      • Configurable timeouts and client information
      • Support for custom transport implementations
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      List<McpSyncClient> mcpSyncClients(McpSyncClientConfigurer mcpSyncClientConfigurer, McpClientCommonProperties commonProperties, ObjectProvider<List<NamedClientMcpTransport>> transportsProvider, ObjectProvider<ClientMcpSyncHandlersRegistry> clientMcpSyncHandlersRegistry) Creates a list of McpSyncClient instances based on the available transports.
      List<McpAsyncClient> mcpAsyncClients(McpAsyncClientConfigurer mcpAsyncClientConfigurer, McpClientCommonProperties commonProperties, ObjectProvider<List<NamedClientMcpTransport>> transportsProvider, ObjectProvider<ClientMcpAsyncHandlersRegistry> clientMcpAsyncHandlersRegistry) Creates a list of McpAsyncClient instances based on the available transports.
      • Methods inherited from class org.springframework.ai.mcp.client.common.autoconfigure.McpClientAutoConfiguration

        makeAsyncClientsClosable, makeSyncClientsClosable, mcpAsyncToolChangeEventEmmiter, mcpSyncToolChangeEventEmmiter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QuiteMcpClientAutoConfiguration

        QuiteMcpClientAutoConfiguration()
    • Method Detail

      • mcpSyncClients

        @Bean()@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "type", havingValue = "SYNC", matchIfMissing = true) List<McpSyncClient> mcpSyncClients(McpSyncClientConfigurer mcpSyncClientConfigurer, McpClientCommonProperties commonProperties, ObjectProvider<List<NamedClientMcpTransport>> transportsProvider, ObjectProvider<ClientMcpSyncHandlersRegistry> clientMcpSyncHandlersRegistry)

        Creates a list of McpSyncClient instances based on the available transports.

        This method overrides the base Spring AI implementation to add exception handling during client initialization. Clients that fail to initialize are logged and excluded from the returned list, allowing the application to start with partially available MCP functionality rather than failing completely.

        Each successfully configured client includes:

        • Client information (name and version) from common properties
        • Request timeout settings
        • Custom configurations through McpSyncClientConfigurer
        • Handler registrations for sampling, elicitation, logging, progress, and resource changes

        If initialization is enabled in properties, the clients are automatically initialized with error resilience.

        Parameters:
        mcpSyncClientConfigurer - the configurer for customizing client creation
        commonProperties - common MCP client properties
        transportsProvider - provider of named MCP transports
        clientMcpSyncHandlersRegistry - registry for client-side synchronous handlers
        Returns:

        list of successfully initialized MCP sync clients (may be empty if all fail)

      • mcpAsyncClients

        @Bean()@ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "type", havingValue = "ASYNC") List<McpAsyncClient> mcpAsyncClients(McpAsyncClientConfigurer mcpAsyncClientConfigurer, McpClientCommonProperties commonProperties, ObjectProvider<List<NamedClientMcpTransport>> transportsProvider, ObjectProvider<ClientMcpAsyncHandlersRegistry> clientMcpAsyncHandlersRegistry)

        Creates a list of McpAsyncClient instances based on the available transports.

        This method overrides the base Spring AI implementation to add exception handling during client initialization. Clients that fail to initialize are logged and excluded from the returned list, allowing the application to start with partially available MCP functionality rather than failing completely.

        Each successfully configured client includes:

        • Client information (name and version) from common properties
        • Request timeout settings
        • Custom configurations through McpAsyncClientConfigurer
        • Handler registrations for sampling, elicitation, logging, progress, and resource changes

        If initialization is enabled in properties, the clients are automatically initialized with error resilience using reactive blocking.

        Parameters:
        mcpAsyncClientConfigurer - the configurer for customizing client creation
        commonProperties - common MCP client properties
        transportsProvider - provider of named MCP transports
        clientMcpAsyncHandlersRegistry - registry for client-side asynchronous handlers
        Returns:

        list of successfully initialized MCP async clients (may be empty if all fail)