Skip to content

Add ability to customize WebClient per connection name #4602

@maxxedev

Description

@maxxedev

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions