When creating NamedClientMcpTransport, support ability to customize WebClient per connection name.
Current code creates the WebClient like webClientBuilderProvider.getIfAvailable(WebClient::builder):
public List<NamedClientMcpTransport> streamableHttpWebFluxClientTransports(
McpStreamableHttpClientProperties streamableProperties,
ObjectProvider<WebClient.Builder> webClientBuilderProvider,
ObjectProvider<ObjectMapper> objectMapperProvider) {
var webClientBuilderTemplate = webClientBuilderProvider.getIfAvailable(WebClient::builder);
return streamableProperties.map(streamableProperty -> {
var transport = newTransport(webClientBuilderTemplate, streamableProperty)
streamableHttpTransports.add(new NamedClientMcpTransport(transport))
}).toList();
}
Please make the code read something like webClientFactory.create(connectionName, WebClient::builder):
public List<NamedClientMcpTransport> streamableHttpWebFluxClientTransports(
McpStreamableHttpClientProperties streamableProperties,
WebClientFactory webClientFactory,
ObjectProvider<ObjectMapper> objectMapperProvider) {
return streamableProperties.map(streamableProperty -> {
var connectionName = streamableProperty.connectionName()
var webClientBuilder = webClientFactory.create(connectionName, WebClient::builder);
var transport = newTransport(webClientBuilderTemplate, streamableProperty)
streamableHttpTransports.add(new NamedClientMcpTransport(transport))
}).toList();
}
Context This will allow WebClient and underlying http client to be much more easily customized on a per connectionName basis.
Comment From: limch02
Hi 👋 I'd like to take this issue.
I reviewed the current implementation and understand that all NamedClientMcpTransport instances share the same WebClient.Builder template.
To support per-connection customization (e.g., timeouts, base URLs, and SSL configs), I'll update the factory method to use WebClientFactory.create(connectionName, WebClient::builder) as suggested.
Plan:
1. Replace ObjectProvider<WebClient.Builder> with WebClientFactory injection.
2. Use streamableProperty.connectionName() to create a per-connection WebClient.Builder.
3. Pass the customized builder into newTransport(...) while keeping the existing structure intact.
4. Add/adjust tests to verify that each connection uses a distinct WebClient instance.
If that approach sounds good, I can start working on a PR for this.
Comment From: maxxedev
@limch02 sounds good.
One consideration to make is that the factory method could be just WebClientFactory.create(connectionName) ... and the default implementation of WebClientFactory could always return WebClient.builder()