Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aliyun1024qjc opened this issue Mar 17, 2025 · 1 comment

Comments

@aliyun1024qjc
Copy link

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]
@dev-jonghoonpark
Copy link
Contributor

It seems that this issue has been duplicated.
#2486

This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants