Skip to content

Commit ca7f870

Browse files
committed
Use random port in McpCompletionTests
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
1 parent 08900bc commit ca7f870

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mcp/src/test/java/io/modelcontextprotocol/server/McpCompletionTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class McpCompletionTests {
4141

4242
private HttpServletSseServerTransportProvider mcpServerTransportProvider;
4343

44+
private static final int PORT = TomcatTestUtil.findAvailablePort();
45+
4446
private static final String CUSTOM_MESSAGE_ENDPOINT = "/otherPath/mcp/message";
4547

4648
McpClient.SyncSpec clientBuilder;
@@ -55,7 +57,7 @@ public void before() {
5557
.messageEndpoint(CUSTOM_MESSAGE_ENDPOINT)
5658
.build();
5759

58-
tomcat = TomcatTestUtil.createTomcatServer("", 3400, mcpServerTransportProvider);
60+
tomcat = TomcatTestUtil.createTomcatServer("", PORT, mcpServerTransportProvider);
5961
try {
6062
tomcat.start();
6163
assertThat(tomcat.getServer().getState()).isEqualTo(LifecycleState.STARTED);
@@ -64,7 +66,7 @@ public void before() {
6466
throw new RuntimeException("Failed to start Tomcat", e);
6567
}
6668

67-
this.clientBuilder = McpClient.sync(HttpClientSseClientTransport.builder("http://localhost:" + 3400).build());
69+
this.clientBuilder = McpClient.sync(HttpClientSseClientTransport.builder("http://localhost:" + PORT).build());
6870
}
6971

7072
@AfterEach

0 commit comments

Comments
 (0)