Skip to content

Commit 9795242

Browse files
committed
feat(mcp): update WebFlux and WebMvc server transport providers with URL configuration
- Add baseUrl and sseEndpoint properties to McpServerProperties - Update WebFlux and WebMvc server transport providers to use new URL configuration properties - Remove deprecated backward compatibility code and related tests - Remove deprecated methods from McpToolUtils - Update MCP SDK version to 0.9.0-SNAPSHOT Signed-off-by: Christian Tzolov <[email protected]>
1 parent edc3566 commit 9795242

File tree

11 files changed

+35
-835
lines changed

11 files changed

+35
-835
lines changed

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpBackwardCompatibility.java

Lines changed: 0 additions & 112 deletions
This file was deleted.

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerAutoConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
5454
import org.springframework.boot.context.properties.EnableConfigurationProperties;
5555
import org.springframework.context.annotation.Bean;
56-
import org.springframework.context.annotation.Import;
5756
import org.springframework.core.log.LogAccessor;
5857
import org.springframework.util.CollectionUtils;
5958
import org.springframework.util.MimeType;
@@ -110,7 +109,6 @@
110109
@AutoConfiguration(after = { McpWebMvcServerAutoConfiguration.class, McpWebFluxServerAutoConfiguration.class })
111110
@ConditionalOnClass({ McpSchema.class, McpSyncServer.class })
112111
@EnableConfigurationProperties(McpServerProperties.class)
113-
@Import(McpBackwardCompatibility.class)
114112
@ConditionalOnProperty(prefix = McpServerProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true",
115113
matchIfMissing = true)
116114
public class McpServerAutoConfiguration {

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerProperties.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ public class McpServerProperties {
9898
*/
9999
private boolean promptChangeNotification = true;
100100

101+
/**
102+
*/
103+
private String baseUrl = "";
104+
105+
/**
106+
*/
107+
private String sseEndpoint = "/sse";
108+
101109
/**
102110
* The endpoint path for Server-Sent Events (SSE) when using web transports.
103111
* <p>
@@ -196,6 +204,24 @@ public void setPromptChangeNotification(boolean promptChangeNotification) {
196204
this.promptChangeNotification = promptChangeNotification;
197205
}
198206

207+
public String getBaseUrl() {
208+
return this.baseUrl;
209+
}
210+
211+
public void setBaseUrl(String baseUrl) {
212+
Assert.notNull(baseUrl, "Base URL must not be null");
213+
this.baseUrl = baseUrl;
214+
}
215+
216+
public String getSseEndpoint() {
217+
return this.sseEndpoint;
218+
}
219+
220+
public void setSseEndpoint(String sseEndpoint) {
221+
Assert.hasText(sseEndpoint, "SSE endpoint must not be empty");
222+
this.sseEndpoint = sseEndpoint;
223+
}
224+
199225
public String getSseMessageEndpoint() {
200226
return this.sseMessageEndpoint;
201227
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public class McpWebFluxServerAutoConfiguration {
7474
@Bean
7575
@ConditionalOnMissingBean
7676
public WebFluxSseServerTransportProvider webFluxTransport(McpServerProperties serverProperties) {
77-
return new WebFluxSseServerTransportProvider(new ObjectMapper(), serverProperties.getSseMessageEndpoint());
77+
return new WebFluxSseServerTransportProvider(new ObjectMapper(), serverProperties.getBaseUrl(),
78+
serverProperties.getSseMessageEndpoint(), serverProperties.getSseEndpoint());
7879
}
7980

8081
// Router function for SSE transport used by Spring WebFlux to start an HTTP server.

auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public class McpWebMvcServerAutoConfiguration {
7070
@ConditionalOnMissingBean
7171
public WebMvcSseServerTransportProvider webMvcSseServerTransportProvider(ObjectMapper objectMapper,
7272
McpServerProperties serverProperties) {
73-
return new WebMvcSseServerTransportProvider(objectMapper, serverProperties.getSseMessageEndpoint());
73+
return new WebMvcSseServerTransportProvider(objectMapper, serverProperties.getBaseUrl(),
74+
serverProperties.getSseMessageEndpoint(), serverProperties.getSseEndpoint());
7475
}
7576

7677
@Bean

0 commit comments

Comments
 (0)