Skip to content

Multiple SSE connections issue and SYNC mode startup failure in McpClientAutoConfiguration #2486

Closed
@devnomad-byte

Description

@devnomad-byte

In the current implementation of McpClientAutoConfiguration, there are two critical issues:

  1. 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
  1. 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]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions