spring-projects / spring-projects/spring-ai

Add ability to customize WebClient per connection name

Open
#4,602 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

improvement mcp
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in auto-configurations/mcp/spring-ai-autoconfigure-mcp-client-webflux/src/main/java/org/springframework/ai/mcp/client/webflux/autoconfigure/StreamableHttpWebFluxTransportAutoConfiguration.java, focusing on streamableHttpWebFluxClientTransports and newTransport. Trace how each streamable property supplies its connection name and how the WebClient.Builder is obtained. Done means WebClient customization can be selected independently for each connection name while existing NamedClientMcpTransport creation continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.