Skip to content

Commit 453aa59

Browse files
committed
mcp-client: support sseEndpoint config
Signed-off-by: lambochen <[email protected]>
1 parent 5864255 commit 453aa59

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Diff for: auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfiguration.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ public List<NamedClientMcpTransport> mcpHttpClientTransports(McpSseClientPropert
9494

9595
for (Map.Entry<String, SseParameters> serverParameters : sseProperties.getConnections().entrySet()) {
9696

97-
var transport = new HttpClientSseClientTransport(HttpClient.newBuilder(), serverParameters.getValue().url(),
98-
objectMapper);
97+
var transport = HttpClientSseClientTransport.builder(serverParameters.getValue().url())
98+
.sseEndpoint(serverParameters.getValue().sseEndpoint())
99+
.clientBuilder(HttpClient.newBuilder())
100+
.objectMapper(objectMapper)
101+
.build();
99102
sseTransports.add(new NamedClientMcpTransport(serverParameters.getKey(), transport));
100103
}
101104

Diff for: auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public List<NamedClientMcpTransport> webFluxClientTransports(McpSseClientPropert
9090

9191
for (Map.Entry<String, SseParameters> serverParameters : sseProperties.getConnections().entrySet()) {
9292
var webClientBuilder = webClientBuilderTemplate.clone().baseUrl(serverParameters.getValue().url());
93-
var transport = new WebFluxSseClientTransport(webClientBuilder, objectMapper);
93+
var transport = new WebFluxSseClientTransport(webClientBuilder, objectMapper,
94+
serverParameters.getValue().sseEndpoint());
9495
sseTransports.add(new NamedClientMcpTransport(serverParameters.getKey(), transport));
9596
}
9697

Diff for: auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientProperties.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ public class McpSseClientProperties {
5050
* Parameters for configuring an SSE connection to an MCP server.
5151
*
5252
* @param url the URL endpoint for SSE communication with the MCP server
53+
* @param sseEndpoint the SSE endpoint for SSE communication with the MCP server
5354
*/
54-
public record SseParameters(String url) {
55+
public record SseParameters(String url, String sseEndpoint) {
56+
public SseParameters(String url) {
57+
this(url, "/sse");
58+
}
5559
}
5660

5761
/**

0 commit comments

Comments
 (0)