This repository demonstrates the issue with duplicate SSE connections and MCP tools creation in Spring AI when both WebFlux and HTTP Client implementations are available.
When both WebFlux and HTTP Client transport implementations are available, the following issues occur:
-
Duplicate SSE Connections Problem
McpClientAutoConfiguration
loads both implementationsSseWebFluxTransportAutoConfiguration
andSseHttpClientTransportAutoConfiguration
create duplicate connections- Results in unnecessary resource consumption and potential performance issues
-
Duplicate MCP Tools Creation
- Multiple identical MCP tools are created due to duplicate transport implementations
- This affects system efficiency and resource utilization
- May cause confusion in tool management and callbacks
This repository contains a minimal project that reproduces the issue:
- Open
spring-ai-mcp-clinet/src/main/resources/application.yml
- Set
spring.ai.mcp.client.type
toSYNC
- Run the application
- Observe the error:
Multiple tools with the same name (get_addr_date)
- Open
spring-ai-mcp-clinet/src/main/resources/application.yml
- Set
spring.ai.mcp.client.type
toASYNC
- Run the application
- Access the endpoint
http://localhost:8080/getServerList
- Observe in logs that duplicate tools with the same name are registered
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mcp-client-webflux-spring-boot-starter</artifactId>
</dependency>
Temporary workarounds (until PR #2493 is merged):
-
Exclude one of the auto-configurations:
spring.autoconfigure.exclude=org.springframework.ai.autoconfigure.mcp.client.SseHttpClientTransportAutoConfiguration
-
Or in application class:
@SpringBootApplication(exclude = { org.springframework.ai.autoconfigure.mcp.client.SseHttpClientTransportAutoConfiguration.class })
The proposed solution in PR #2493 adds explicit transport mode configuration:
spring.ai.mcp.client.sse.transport-mode=WEBFLUX # or HTTP_CLIENT
This ensures only one transport implementation is active at a time.