diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfiguration.java index 00c8e44d7ed..6ffb53293e1 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfiguration.java @@ -94,8 +94,11 @@ public List mcpHttpClientTransports(McpSseClientPropert for (Map.Entry serverParameters : sseProperties.getConnections().entrySet()) { - var transport = new HttpClientSseClientTransport(HttpClient.newBuilder(), serverParameters.getValue().url(), - objectMapper); + var transport = HttpClientSseClientTransport.builder(serverParameters.getValue().url()) + .sseEndpoint(serverParameters.getValue().sseEndpoint()) + .clientBuilder(HttpClient.newBuilder()) + .objectMapper(objectMapper) + .build(); sseTransports.add(new NamedClientMcpTransport(serverParameters.getKey(), transport)); } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfiguration.java index b49ceb552cb..a725b652e0d 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfiguration.java @@ -90,7 +90,8 @@ public List webFluxClientTransports(McpSseClientPropert for (Map.Entry serverParameters : sseProperties.getConnections().entrySet()) { var webClientBuilder = webClientBuilderTemplate.clone().baseUrl(serverParameters.getValue().url()); - var transport = new WebFluxSseClientTransport(webClientBuilder, objectMapper); + var transport = new WebFluxSseClientTransport(webClientBuilder, objectMapper, + serverParameters.getValue().sseEndpoint()); sseTransports.add(new NamedClientMcpTransport(serverParameters.getKey(), transport)); } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientProperties.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientProperties.java index 22c655c1bbc..7fd5037af63 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientProperties.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientProperties.java @@ -18,7 +18,10 @@ import java.util.HashMap; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.bind.DefaultValue; /** * Configuration properties for Server-Sent Events (SSE) based MCP client connections. @@ -50,8 +53,11 @@ public class McpSseClientProperties { * Parameters for configuring an SSE connection to an MCP server. * * @param url the URL endpoint for SSE communication with the MCP server + * @param sseEndpoint the SSE endpoint for SSE communication with the MCP server */ - public record SseParameters(String url) { + @JsonInclude(JsonInclude.Include.NON_ABSENT) + public record SseParameters(@JsonProperty("url") String url, + @JsonProperty("sse-endpoint") @DefaultValue("/sse") String sseEndpoint) { } /** diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfiguration.java index 563fafe9e18..bde016bbaa0 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfiguration.java @@ -77,7 +77,8 @@ public class McpWebFluxServerAutoConfiguration { public WebFluxSseServerTransportProvider webFluxTransport(ObjectProvider objectMapperProvider, McpServerProperties serverProperties) { ObjectMapper objectMapper = objectMapperProvider.getIfAvailable(ObjectMapper::new); - return new WebFluxSseServerTransportProvider(objectMapper, serverProperties.getSseMessageEndpoint()); + return new WebFluxSseServerTransportProvider(objectMapper, serverProperties.getBaseUrl(), + serverProperties.getSseMessageEndpoint(), serverProperties.getSseEndpoint()); } // Router function for SSE transport used by Spring WebFlux to start an HTTP server. diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfiguration.java index 259fc3b37a2..42ac7a451ab 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfiguration.java @@ -72,7 +72,8 @@ public class McpWebMvcServerAutoConfiguration { public WebMvcSseServerTransportProvider webMvcSseServerTransportProvider( ObjectProvider objectMapperProvider, McpServerProperties serverProperties) { ObjectMapper objectMapper = objectMapperProvider.getIfAvailable(ObjectMapper::new); - return new WebMvcSseServerTransportProvider(objectMapper, serverProperties.getSseMessageEndpoint()); + return new WebMvcSseServerTransportProvider(objectMapper, serverProperties.getBaseUrl(), + serverProperties.getSseMessageEndpoint(), serverProperties.getSseEndpoint()); } @Bean