In the current implementation of McpClientAutoConfiguration
, there are two critical issues:
- When using
type: ASYNC
, both SSE implementations (WebFlux and HttpClient) attempt to establish connections to the same server endpoint simultaneously. This occurs because the auto-configuration allows both transports to be registered:
java @AutoConfiguration(after = { StdioTransportAutoConfiguration.class, SseHttpClientTransportAutoConfiguration.class, SseWebFluxTransportAutoConfiguration.class })
This results in: - Duplicate SSE connections to the same endpoint - Unnecessary resource consumption - Potential message duplication
- When using
type: SYNC
, the application fails to start. This appears to be related to the order of auto-configuration initialization specified in the@AutoConfiguration(after = {...})
annotation.
Example configuration where these issues occur:
yaml spring: ai: mcp: client: type: ASYNC # or SYNC server: endpoint: "http://localhost:8080/"
Questions: 1. Why are both SSE implementations allowed to register and connect simultaneously? 2. Could we implement a mechanism to ensure only one SSE implementation is active at a time? 3. What is the recommended approach for handling these transport implementations to avoid duplicate connections? 4. Why does SYNC mode fail to start, and what is the proper way to handle the auto-configuration order?
Environment: - Spring AI version: [1.0.0 M6] - Spring Boot version: [3.4.3] - Java version: [JDK 17]