Skip to content

Commit 9e6138e

Browse files
committed
refactor(McpServers): Replace hardcoded default values with constants for base URL and SSE endpoint
1 parent 97f6eb3 commit 9e6138e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/main/java/com/github/codeboyzhou/mcp/declarative/McpServers.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import io.modelcontextprotocol.spec.McpServerTransportProvider;
1717
import org.reflections.Reflections;
1818

19+
import static io.modelcontextprotocol.server.transport.HttpServletSseServerTransportProvider.DEFAULT_BASE_URL;
20+
import static io.modelcontextprotocol.server.transport.HttpServletSseServerTransportProvider.DEFAULT_SSE_ENDPOINT;
21+
1922
public class McpServers {
2023

2124
private static final McpServers INSTANCE = new McpServers();
@@ -24,8 +27,6 @@ public class McpServers {
2427

2528
private static final String DEFAULT_MESSAGE_ENDPOINT = "/message";
2629

27-
private static final String DEFAULT_SSE_ENDPOINT = "/sse";
28-
2930
private static final int DEFAULT_HTTP_SERVER_PORT = 8080;
3031

3132
private static Reflections reflections;
@@ -80,31 +81,29 @@ public void startSyncSseServer(McpSseServerInfo serverInfo) {
8081
public void startSyncSseServer(String name, String version, String messageEndpoint, String sseEndpoint, int port) {
8182
McpSseServerInfo serverInfo = McpSseServerInfo.builder().name(name).version(version)
8283
.instructions("You are using a deprecated API with default server instructions")
83-
.baseUrl("").messageEndpoint(messageEndpoint).sseEndpoint(sseEndpoint).port(port)
84+
.baseUrl(DEFAULT_BASE_URL).messageEndpoint(messageEndpoint)
85+
.sseEndpoint(sseEndpoint).port(port)
8486
.build();
85-
8687
startSyncSseServer(serverInfo);
8788
}
8889

8990
@Deprecated(since = "0.2.0")
9091
public void startSyncSseServer(String name, String version, int port) {
9192
McpSseServerInfo serverInfo = McpSseServerInfo.builder().name(name).version(version)
9293
.instructions("You are using a deprecated API with default server instructions")
93-
.baseUrl("").messageEndpoint(DEFAULT_MESSAGE_ENDPOINT).sseEndpoint(DEFAULT_SSE_ENDPOINT)
94-
.port(port)
94+
.baseUrl(DEFAULT_BASE_URL).messageEndpoint(DEFAULT_MESSAGE_ENDPOINT)
95+
.sseEndpoint(DEFAULT_SSE_ENDPOINT).port(port)
9596
.build();
96-
9797
startSyncSseServer(serverInfo);
9898
}
9999

100100
@Deprecated(since = "0.2.0")
101101
public void startSyncSseServer(String name, String version) {
102102
McpSseServerInfo serverInfo = McpSseServerInfo.builder().name(name).version(version)
103103
.instructions("You are using a deprecated API with default server instructions")
104-
.baseUrl("").messageEndpoint(DEFAULT_MESSAGE_ENDPOINT).sseEndpoint(DEFAULT_SSE_ENDPOINT)
105-
.port(DEFAULT_HTTP_SERVER_PORT)
104+
.baseUrl(DEFAULT_BASE_URL).messageEndpoint(DEFAULT_MESSAGE_ENDPOINT)
105+
.sseEndpoint(DEFAULT_SSE_ENDPOINT).port(DEFAULT_HTTP_SERVER_PORT)
106106
.build();
107-
108107
startSyncSseServer(serverInfo);
109108
}
110109

0 commit comments

Comments
 (0)